String To Dict Problem

lalo.martins at gmail.com lalo.martins at gmail.com
Wed Mar 29 07:24:12 CEST 2006


>     def default(self, node, **kw):
>         for child in node.getChildNodes():
>             return self.visit(child, **kw)
>
>     visitExpression = default

I'm not sure I grok this part.  It leads to unexpected results:
>>> safe_dict("""gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS', text2
= 'more text without quotes', fmtline = "@VALUE @SIGNAL", signals =
[('FPS',None), ('FPS2', 'something')], danger = 2+2""")
{'text2': 'more text without quotes', 'danger': 2, 'fmtline': '@VALUE
@SIGNAL', 'text': 'FPS', 'pos': [0, 20], 'signals': [('FPS', None),
('FPS2', 'something')], 'gid': 'FPS', 'type': 'Label'}
>>> safe_dict("""gid = 'FPS', type = 'Label', pos = [0, 20], text = 'FPS', text2
= 'more text without quotes', fmtline = "@VALUE @SIGNAL", signals =
[('FPS',None), ('FPS2', 'something')], danger = foo()""")
{'text2': 'more text without quotes', 'danger': None, 'fmtline':
'@VALUE @SIGNAL', 'text': 'FPS', 'pos': [0, 20], 'signals': [('FPS',
None), ('FPS2', 'something')], 'gid': 'FPS', 'type': 'Label'}




More information about the Python-list mailing list