Re: [Tutor] changing list index start

2010-09-11 Thread Steven D'Aprano
On Sun, 12 Sep 2010 02:00:02 am Lie Ryan wrote: > As an alternative solution, you can derive from UserList and overload > the __getitem__ and __setitem__ operator: We've been able to inherit from list directly since at least Python 2.2. Why are you using UserList? -- Steven D'Aprano

Re: [Tutor] changing list index start

2010-09-11 Thread Rance Hall
On Sat, Sep 11, 2010 at 10:40 AM, Joel Goldstick wrote: > > I think the first message in the original post is instructive: > > "I'm using the following function style I found on the net to create > menus for a command line python script:" > > I (sometimes!) love looking at other peoples code to

Re: [Tutor] changing list index start

2010-09-11 Thread Lie Ryan
On 09/11/10 23:25, Rance Hall wrote: > On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan wrote: >> On 09/11/10 07:36, Rance Hall wrote: > > > >> In most cases in Python, you would almost never need to reference the >> list's index directly since python makes it easy to use iterators; >> however in your

Re: [Tutor] changing list index start

2010-09-11 Thread Joel Goldstick
On Sat, Sep 11, 2010 at 11:15 AM, Steven D'Aprano wrote: > On Sat, 11 Sep 2010 11:25:12 pm Rance Hall wrote: > > > Thanks everyone for responding, Because this menu structure is > > repeated many times in my code, the ideal solution would have been to > > "set index start = 1" in the beginning of

Re: [Tutor] changing list index start

2010-09-11 Thread Steven D'Aprano
On Sat, 11 Sep 2010 11:25:12 pm Rance Hall wrote: > Thanks everyone for responding, Because this menu structure is > repeated many times in my code, the ideal solution would have been to > "set index start = 1" in the beginning of the script. That is exactly the wrong solution. That will break a

Re: [Tutor] changing list index start

2010-09-11 Thread Knacktus
Am 11.09.2010 15:46, schrieb Joel Goldstick: On Sat, Sep 11, 2010 at 9:25 AM, Rance Hall mailto:ran...@gmail.com>> wrote: On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan mailto:lie.1...@gmail.com>> wrote: > On 09/11/10 07:36, Rance Hall wrote: > In most cases in Python, you woul

Re: [Tutor] changing list index start

2010-09-11 Thread Joel Goldstick
On Sat, Sep 11, 2010 at 9:25 AM, Rance Hall wrote: > On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan wrote: > > On 09/11/10 07:36, Rance Hall wrote: > > > > > In most cases in Python, you would almost never need to reference the > > list's index directly since python makes it easy to use iterators; >

Re: [Tutor] changing list index start

2010-09-11 Thread Rance Hall
On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan wrote: > On 09/11/10 07:36, Rance Hall wrote: > In most cases in Python, you would almost never need to reference the > list's index directly since python makes it easy to use iterators; > however in your particular case, which is a valid exception, enu

Re: [Tutor] changing list index start

2010-09-11 Thread Francesco Loffredo
On 10/09/2010 23.36, Rance Hall wrote: I'm using the following function style I found on the net to create menus for a command line python script: def mainmenu(): # the main menu todolist() mainmenuoptions = ['Clients','Jobs','Billing','Quotes','To Do Items','Employee','Exit']

Re: [Tutor] changing list index start

2010-09-10 Thread Lie Ryan
On 09/11/10 07:36, Rance Hall wrote: > I'm using the following function style I found on the net to create > menus for a command line python script: > > It works well, but the first item is the list is item 0. This is > normal in most computing situations, but because this index is part of > the

Re: [Tutor] changing list index start

2010-09-10 Thread Luke Paireepinart
Yeah, just add 1 to it. When printing just do index+1 and when inputting the user's choice, subtract 1 and use it as the array index. Sent from my iPhone On Sep 10, 2010, at 4:36 PM, Rance Hall wrote: > I'm using the following function style I found on the net to create > menus for a command