numbering variables

remi remi at non.com
Mon Mar 28 07:49:36 EST 2005


Fredrik Lundh a écrit :
> "remi" <remi at non.com> 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 very simple *.xml file
mylist is made by :

file_in = open('in.tex','r')
file_string = file_in.read()

corps = r"""\\begin{document}(?P<contents>.*)\\end{document}""" 
compile_obj = re.compile(corps,  re.IGNORECASE| re.DOTALL)
match_obj = compile_obj.search(file_string)
contents = match_obj.group('contents')

sect = r'\\section{(.*)}'
motif1 = re.compile(sect)
mylist = re.split(motif1,contents)

I want to store each item of mylist in a variable (and after "xmlize" it 
little by little). The lengh of mylist isn't fixed it depends on the 
*.tex file.
Thanks.
Rémi.



More information about the Python-list mailing list