Re: [Tutor] my own error code when no argument is sent

2008-06-17 Thread broek





when i execute my program without an argument i receive,


infile = sys.argv[1]

IndexError: list index out of range
is there a way that i could suppress this and add my own error code




Hi Bryan,

You are probably better off pursuing Danny's suggestion. But, this is  
what you asked for:


IDLE 1.1.4

class CustomError(Exception):

pass


import sys
try:

infile = sys.argv[1]
except IndexError:
raise CustomError, "Some msg (this is optional)"


Traceback (most recent call last):
  File "", line 4, in -toplevel-
raise CustomError, "Some msg (this is optional)"
CustomError: Some msg (this is optional)


Best,

Brian vdB
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] my own error code when no argument is sent

2008-06-17 Thread Alan Gauld

<[EMAIL PROTECTED]> wrote


infile = sys.argv[1]

IndexError: list index out of range
is there a way that i could suppress this and add my own error code



Hi Bryan,
You are probably better off pursuing Danny's suggestion. But, this 
is  what you asked for:


IDLE 1.1.4

class CustomError(Exception):

pass



Or, combining the suggestions you get:

import sys
try:
   infile = sys.argv[1]
except IndexError:
   # handle the error by assigning a default value
   # just as you would do if checking len()

Lots of options :-)

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter problem

2008-06-17 Thread Kent Johnson
On Tue, Jun 17, 2008 at 12:57 AM, Arden Hall <[EMAIL PROTECTED]> wrote:
> A followup on the message below.  The source code has errors in it because I
> keyed it in rather than copying and pasting, as pointed out by Alan Gauld.
>  Joe replied with corrected code and said it worked for him.  I took his
> code and ran it on the Mac and had the same problem as before:  everything
> but the background color worked.  I then installed Python on a Windows PC
> and tried the same code:  with the PC, the background color works.  So the
> problem seems to be bug in Tkinter for the Mac.  Thanks Alan and Joe for
> your help.

It fails on my Mac also.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Visualizing the Python Project

2008-06-17 Thread bhaaluu
This is very interesting!

http://www.vimeo.com/1093745

Visualizing the commit history of the Python scripting language project.

http://vis.cs.ucdavis.edu/~ogawa/codeswarm/

Happy Programming!
-- 
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] a question about iterators

2008-06-17 Thread Kent Johnson
On Tue, Jun 17, 2008 at 1:46 AM, Christopher Spears
<[EMAIL PROTECTED]> wrote:

> I am confused by this statement:
 i = iter(a)
>
> Why do I need to turn 'a' into an iterator?  Didn't I already do this when I 
> constructed the class?

Yes, a is already an iterator.

> As a test, I tried the following:
>
 for j in range(1,5):
> ... print j, ':', a.next(j)
> ...
> 1 :
> Traceback (most recent call last):
>  File "", line 2, in ?
>  File "", line 13, in next
> StopIteration

>
> Why didn't that work?

Did you make a new a or reuse the same one? The old a has reached the
end of its values so it raises StopIteration.

Note that passing parameters to next() is not part of the iterator protocol.

Kent
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visualizing the Python Project

2008-06-17 Thread W W
On Tue, Jun 17, 2008 at 6:40 AM, bhaaluu <[EMAIL PROTECTED]> wrote:
> This is very interesting!
>
> http://www.vimeo.com/1093745
>
> Visualizing the commit history of the Python scripting language project.
>
> http://vis.cs.ucdavis.edu/~ogawa/codeswarm/

That would only be cooler if it was written in python ;) (maybe it
was, but it wasn't specified on the page I read :P)
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Visualizing the Python Project

2008-06-17 Thread bhaaluu
On Tue, Jun 17, 2008 at 8:26 AM, W W <[EMAIL PROTECTED]> wrote:
> On Tue, Jun 17, 2008 at 6:40 AM, bhaaluu <[EMAIL PROTECTED]> wrote:
>> This is very interesting!
>>
>> http://www.vimeo.com/1093745
>>
>> Visualizing the commit history of the Python scripting language project.
>>
>> http://vis.cs.ucdavis.edu/~ogawa/codeswarm/
>
> That would only be cooler if it was written in python ;) (maybe it
> was, but it wasn't specified on the page I read :P)
>

I know, right?

Michael Ogawa, the UC Davis student who made code_swarm says he
is seriously considering releasing the source code to his project as
open source.
We'll see. He says the source code, as it is now, needs to be cleaned-up
(which indicates it probably wasn't written in Python - since Python, by
its very nature is clean, right?).

Nevertheless, the video of the Python Project is really cool! I like it when
the project explodes in 2000. It's like a SuperNova.
-- 
b h a a l u u at g m a i l dot c o m
Kid on Bus: What are you gonna do today, Napoleon?
Napoleon Dynamite: Whatever I feel like I wanna do. Gosh!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Automating GUI Command Regression Testing

2008-06-17 Thread Gordon Agress
 Could someone please point me to resources that would
help me learn to pipe keyboard input for commands to a Tkinter GUI, and then
to automate saving a screen shot of the resulting GUI display?  Is this even
possible?

I'm trying to automate regression testing of a simple Tkinter GUI.  I'd like
to supplant manual entry of keyboard commands (hotkeys like Alt-F, tabs and
arrows to move among fields and buttons, data entry, 'enter', etc) with a
file holding all that stuff, and store an image of the outcome for later
review or comparison.

Simply piping a file to the GUI didn't work, but I don't know if this is
because the pipe doesn't work or because I don't know how to properly
represent events like Alt-F or Tab in the text file.  I've looked in
Programming Python and the Python Cookbook, and on the 'net, but haven't
found anything that seems helpful.

Any help would be appreciated -- I don't want to manually step through a
bunch of menu trees every time I make a change!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] BootCampArama Early Bird Registration Reminder

2008-06-17 Thread Chris Calloway
Just a reminder, we're at the two week warning on early bird 
registration for PyCamp:


http://trizpug.org/boot-camp/2008/

Registration is now open for:

PyCamp: Python Boot Camp, August 4 - 8

Plone Boot Camp: Customizing Plone, July 28 - August 1

Advanced Plone Boot Camp: Plone 3 Techniques, August 4 - 7

All of these take place on the campus of the University of North 
Carolina at Chapel Hill in state of the art high tech classrooms, with 
free mass transit, low-cost accommodations with free wireless, and 
convenient dining options.


Plone Boot Camp is taught by Joel Burton, twice chair of the Plone 
Foundation. Joel has logged more the 200 days at the head of Plone 
classrooms on four continents. See plonebootcamps.com for dozens of 
testimonials from Joel's students.


PyCamp is taught by Chris Calloway, facilitator for TriZPUG and 
application analyst for the Southeast Coastal Ocean Observing System. 
Chris has developed PyCamp for over 1500 hours on behalf of Python user 
groups. Early bird registration runs through June 30. So register today!


PyCamp is TriZPUG's Python Boot Camp, which takes a programmer familiar 
with basic programming concepts to the status of Python developer with 
one week of training. If you have previous scripting or programming 
experience and want to step into Python programming as quickly and 
painlessly as possible, this boot camp is for you. PyCamp is also the 
perfect follow-on to Plone Boot Camp: Customizing Plone the previous week.


At Plone Boot Camp: Customizing Plone you will learn the essentials you 
need to build your Plone site and deploy it. This course is the most 
popular in the Plone world--for a good reason: it teaches you practical 
skills in a friendly, hands-on format. This bootcamp is aimed at:

* people with HTML or web design experience
* people with some or no Python experience
* people with some or no Zope/Plone experience
It covers using Plone, customizing, and deploying Plone sites.

At Advanced Plone Boot Camp: Plone 3 Techniques you will learn to build 
a site using the best practices of Plone 3 as well as advance your 
skills in scripting and developing for Plone. The course covers the new 
technologies in Plone 3.0 and 3.1 intended for site integrators and 
developers: our new portlet infrastructure, viewlets, versioning, and a 
friendly introduction to Zope 3 component architecture. Now, updated for 
Plone 3.1! The course is intended for people who have experience with 
the basics of Plone site development and HTML/CSS. It will cover what 
you need to know to take advantage of these new technologies in Plone 3.


For more information contact: [EMAIL PROTECTED]

--
Sincerely,

Chris Calloway
http://www.secoora.org
office: 332 Chapman Hall   phone: (919) 599-3530
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Automating GUI Command Regression Testing

2008-06-17 Thread Alan Gauld


"Gordon Agress" <[EMAIL PROTECTED]> wrote
help me learn to pipe keyboard input for commands to a Tkinter GUI, 
and then
to automate saving a screen shot of the resulting GUI display?  Is 
this even

possible?


Its possible but not trivial.
It depends a lot on your OS since X Wndows and MS Windows work
very differently. And if you are on Aqua under MacOS your best bet
might be to use Applescript to automate things.

to supplant manual entry of keyboard commands (hotkeys like Alt-F, 
tabs and
arrows to move among fields and buttons, data entry, 'enter', etc) 
with a
file holding all that stuff, and store an image of the outcome for 
later

review or comparison.


If you are on Windows then you can use the FindWindow and PostMessage
API calls to send windows events to the window. You can find the API
documentation in the python winall documentaton and the native C
documentation on the MS MSDN werb site.

See also the recent thread (this last week) about moving a window 
using

the Win32 API for a very short example...

If you are on X wuindows then it is much more complex and you might
be better lookingh for a 3rd party tool. There are several commercial 
ones

and there might be some freeware ones too, but I don't know the
area well enough to recommend anything. If you have money to spend
I can get some recommendations from my test team if needed...

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter problem

2008-06-17 Thread Alan Gauld

"Arden Hall" <[EMAIL PROTECTED]> wrote


I'm trying to learn to use Tkinter from "Thinking in Tkinter"


I'll make a couple of comments on the code then add a
hypothesis about the reason for your "error"


   button1 = Button(myContainer1)
   button1["text"} = "Hello, World!"
   button1[background"] = "green"
   button1.pack


Its common in Tkinter to set all the attributes in
the init method lie so:

button1 = Button(myContainer1, text="Hello, World!",background= 
"green")


Or if modifying several attributes at once to use configure(),
like this:

button1.configure(text="Hello, World!",background= "green")

Its shorter and just as easy to read.

The dictionary style access tends to be reserved for single
attribute changes.

I can execute this, but the button isn't green (or any other color I 
try) although it turns blue when I click the mouse on it.  .


I think this means you are running an Aqua build of Tkinter.
It would not surprise me if such a build did not support more than
a limited subset of colours since Apple are very keen to ensure
that Aqua applications conform to their style guide. And they
like buttons to be blue or white and not much else!

I suspect that if you can find a build of Tkinter for X under
Darwin(probably via Fink) then that would behave as expected.
But not having such a build myself I can only confirm that it
works OK on my eeePC Linux box running Xandros Linux...

--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor