Re: NEWB: how to convert a string to dict (dictionary)

2006-05-25 Thread Aahz
In article <[EMAIL PROTECTED]>, manstey <[EMAIL PROTECTED]> wrote: > >Thanks. I didn't know eval could do that. But why do many posts say >they want a solution that doesn't use eval? Because it is a security risk! eval("os.system('rm -rf /')") -- Aahz ([EMAIL PROTECTED]) <*> h

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-25 Thread Duncan Booth
manstey wrote: > Thanks. I didn't know eval could do that. But why do many posts say > they want a solution that doesn't use eval? > Because it is a sledgehammer: capable of driving in nails or breaking rocks. Most times people say 'I want to use eval' they are using it to drive nails and some

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-24 Thread manstey
Thanks. I didn't know eval could do that. But why do many posts say they want a solution that doesn't use eval? -- http://mail.python.org/mailman/listinfo/python-list

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-24 Thread vbgunz
I am sure something much more elaborate will show it's face but this I made in about 10 minutes. Didn't do much testing on it but it certainly does convert your string modeled after a dictionary into a real dictionary. You might wish to check against more variations and possibilities and tweak and

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-24 Thread Kent Johnson
manstey wrote: > Hi, > > How do I convert a string like: > a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" > > into a dictionary: > b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} Try this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Reci

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-23 Thread Heiko Wundram
Am Mittwoch 24 Mai 2006 07:52 schrieb manstey: > Hi, > > How do I convert a string like: > a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" > > into a dictionary: > b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} b = eval(a) (if a contains a dict-repr)

Re: NEWB: how to convert a string to dict (dictionary)

2006-05-23 Thread Jorge Godoy
manstey wrote: > Hi, > > How do I convert a string like: > a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" > > into a dictionary: > b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} > > Thanks, Matthew > > PS why in Python is it so often easy to conv

NEWB: how to convert a string to dict (dictionary)

2006-05-23 Thread manstey
Hi, How do I convert a string like: a="{'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'}" into a dictionary: b={'syllable': u'cv-i b.v^ y^-f', 'ketiv-qere': 'n', 'wordWTS': u'8'} Thanks, Matthew PS why in Python is it so often easy to convert one way but not the other? -- ht