Re: numbering variables

2005-03-29 Thread Steve
Ron_Adam wrote: On Mon, 28 Mar 2005 13:39:17 +0200, remi <[EMAIL PROTECTED]> wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is fi

Re: numbering variables

2005-03-28 Thread Ron_Adam
On Mon, 28 Mar 2005 13:39:17 +0200, remi <[EMAIL PROTECTED]> wrote: >Hello, > >I have got a list like : mylist = ['item 1', 'item 2','item n'] and >I would like to store the string 'item1' in a variable called s_1, >'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-)

Re: numbering variables

2005-03-28 Thread remi
Fredrik Lundh a écrit : variable['s_i']=mylist.pop() variable['s_' + str(i)]=mylist.pop() but that while and pop stuff is pretty weird; Why ? Because it destroys the list ? maybe you should read the sections on lists, for loops, and string formatting in the Python tutorial? here's a shorter

Re: numbering variables

2005-03-28 Thread remi
Fredrik Lundh a écrit : "remi" <[EMAIL PROTECTED]> wrote: I want to store each item of mylist in a variable (and after "xmlize" it little by little). why not just process the items in the list? That's right. for item in mylist: print tex2xml(item) where tex2xml() is the main converting

Re: numbering variables

2005-03-28 Thread Fredrik Lundh
"remi" <[EMAIL PROTECTED]> wrote: > I want to store each item of mylist in a variable (and after "xmlize" it > little by little). why not just process the items in the list? for item in mylist: print tex2xml(item) -- http://mail.python.org/mailman/listinfo/python-list

Re: numbering variables

2005-03-28 Thread Fredrik Lundh
"remi" <[EMAIL PROTECTED]> wrote: > i = 0 > while i<=len(mylist) >variable['s_i']=mylist.pop() >i = i+1 variable['s_' + str(i)]=mylist.pop() but that while and pop stuff is pretty weird; maybe you should read the sections on lists, for loops, and string formatting in the Python tutor

Re: numbering variables

2005-03-28 Thread remi
Fredrik Lundh a écrit : "remi" <[EMAIL PROTECTED]> wrote: I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... why? I want to convert a very simple *.tex file into a ver

Re: numbering variables

2005-03-28 Thread remi
Patrick Useldinger a écrit : remi wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-) Any ideas ? Thanks a lot. Rémi.

Re: numbering variables

2005-03-28 Thread Patrick Useldinger
remi wrote: Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-) Any ideas ? Thanks a lot. Rémi. Use a dictionary: variable['s_1

Re: numbering variables

2005-03-28 Thread Fredrik Lundh
"remi" <[EMAIL PROTECTED]> wrote: > I have got a list like : mylist = ['item 1', 'item 2','item n'] and I > would like to store the > string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in > 's_i',... why? -- http://mail.python.org/mailman/listinfo/python-list

numbering variables

2005-03-28 Thread remi
Hello, I have got a list like : mylist = ['item 1', 'item 2','item n'] and I would like to store the string 'item1' in a variable called s_1, 'item2' in s_2,...,'item i' in 's_i',... The lenght of mylist is finite ;-) Any ideas ? Thanks a lot. Rémi. -- http://mail.python.org/mailman/listinfo/