[Tutor] Creating sub-menus?

2008-12-30 Thread nathan virgil
I was reading the Non-Programmer's Tutorial for Python, and became really proud of myself when I realized I could create a menu for functions. I decided to try to take this one step further and see if I could create not just a menu, but a menu with sub-menus, too! Ultimately, the idea I came up wit

Re: [Tutor] Exception Handling

2008-12-30 Thread Jervis Whitley
On Wed, Dec 31, 2008 at 11:18 AM, David wrote: > > . I still need to get it to prduce an error if the year is 0 or 2009, the > month is 0 or 13 and the day is 0 or 32. Try using the datetime module to check validity of entered data. example: >>> import datetime >>> datetime.datetime(2008, 12,

Re: [Tutor] Exception Handling

2008-12-30 Thread David
Jervis Whitley wrote: On Wed, Dec 31, 2008 at 8:33 AM, David > wrote: On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: > On Mon, 29 Dec 2008 09:10:45 - > "Alan Gauld" mailto:alan.ga...@btinternet.com>> wrote: > >

Re: [Tutor] Exception Handling

2008-12-30 Thread Kent Johnson
On Tue, Dec 30, 2008 at 4:33 PM, David wrote: > Thank you all for the tips. Next to do is to get the dates in one raw_input > with the correct format and to check for a valid year, month, and day. Here > is what I have now; >ynum = int(time.strftime("%Y", time.gmtime())) - int(yr) >

Re: [Tutor] optimize code

2008-12-30 Thread Kent Johnson
On Tue, Dec 30, 2008 at 3:42 PM, Norman Khine wrote: > Hi, > I have an updated version at http://paste.lisp.org/display/72843 > Thanks for the advice, the code is much smaller and leaner than the first > attempt. The level2-4 code could all be consolidated into a loop: for levelName in 'level2 l

Re: [Tutor] Exception Handling

2008-12-30 Thread Jervis Whitley
On Wed, Dec 31, 2008 at 8:33 AM, David wrote: > On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: >> >> > On Mon, 29 Dec 2008 09:10:45 - >>> > "Alan Gauld" wrote: >>> > > >>> >> "bob gailer" wrote >> > >> > Also IMHO it is bad design to put a lot of code inside a try

Re: [Tutor] Exception Handling

2008-12-30 Thread David
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: > On Mon, 29 Dec 2008 09:10:45 - > "Alan Gauld" wrote: > > >> "bob gailer" wrote >> >> > Also IMHO it is bad design to put a lot of code inside a try block. >> > In this case the user might make a mistake on day and then is forced >> > t

Re: [Tutor] optimize code

2008-12-30 Thread Norman Khine
Hi, I have an updated version at http://paste.lisp.org/display/72843 Thanks for the advice, the code is much smaller and leaner than the first attempt. Norman Kent Johnson wrote: On Tue, Dec 30, 2008 at 9:32 AM, Norman Khine wrote: Hello, I have this piece of code which I would like to furth

Re: [Tutor] IDLE problems

2008-12-30 Thread Kent Johnson
On Tue, Dec 30, 2008 at 12:05 PM, Pearce Michal wrote: > ok, so I just started working with python, however I have been working with > Java for awhile, and am fairly familiar with it. my problem with Python is > for the IDLE editor, and it is this: the return key, or enter key not only > moves the

[Tutor] IDLE problems

2008-12-30 Thread Pearce Michal
ok, so I just started working with python, however I have been working with Java for awhile, and am fairly familiar with it. my problem with Python is for the IDLE editor, and it is this: the return key, or enter key not only moves the editor to the next line, but also executes the script. so if I

Re: [Tutor] optimize code

2008-12-30 Thread Norman Khine
Kent Johnson wrote: On Tue, Dec 30, 2008 at 9:32 AM, Norman Khine wrote: Hello, I have this piece of code which I would like to further streamline it. There is no need to re-create the mapping at each level of if; you can just add new key/value pairs. For example if leve

Re: [Tutor] optimize code

2008-12-30 Thread Kent Johnson
On Tue, Dec 30, 2008 at 9:32 AM, Norman Khine wrote: > Hello, > I have this piece of code which I would like to further streamline it. There is no need to re-create the mapping at each level of if; you can just add new key/value pairs. For example if level2 is not None:

[Tutor] optimize code

2008-12-30 Thread Norman Khine
Hello, I have this piece of code which I would like to further streamline it. http://paste.lisp.org/display/72830 More specifically, I feel there is too many if statements. What the code does is that it takes a form value and builds a dictionary http://localhost/;search?level1=air-brokers-or-c

Re: [Tutor] Exception Handling

2008-12-30 Thread Lie Ryan
On Mon, 29 Dec 2008 16:57:44 +0100, spir wrote: > On Mon, 29 Dec 2008 09:10:45 - > "Alan Gauld" wrote: > > >> "bob gailer" wrote >> >> > Also IMHO it is bad design to put a lot of code inside a try block. >> > In this case the user might make a mistake on day and then is forced >> > to re

[Tutor] reply

2008-12-30 Thread prasad rao
Hello. Thank you.Just a small change at the optional parameter made all the difference. It seems to be a mirracle.It is an enlitenment to me. Thank you. Prasad ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor