Re: best way to create a dict from string

2010-02-19 Thread MRAB
Tim Arnold wrote: Hi, I've got some text to parse that looks like this text = ''' blah blah blah \Template[Name=RAD,LMRB=False,LMRG=True]{tables} ho dee ho ''' If you're going to include backslashes in the string literal then use a raw string for safety. I want to extract the bit between the

best way to create a dict from string

2010-02-18 Thread Tim Arnold
Hi, I've got some text to parse that looks like this text = ''' blah blah blah \Template[Name=RAD,LMRB=False,LMRG=True]{tables} ho dee ho ''' I want to extract the bit between the brackets and create a dictionary. Here's what I'm doing now: def options(text): d = dict() options = text[te