On Wed, Aug 19, 2009 at 11:10, Frank Wierzbicki<fwierzbicki@gmail.com> wrote:
Before I start complaining, I want to mention what a huge help it has been to be able to directly compare the AST exposed by ast.py in making Jython a better Python. Thanks for that!
Now on to the complaints: Though I recently added support for this in Jython, I don't like that nodes can be defined without required attributes, for example:
node = ast.Assign()
Is valid, even though it requires "node.targets" and "node.value" (I'm less concerned about the required lineno and col_offset, as I can understand holding off on these so that you can just use fix_missing_locations to fill these in for you).
My other (bigger) gripe is that you can define these values with arbitrary objects that will blow up at parse time. So for example you can write:
node = ast.Assign() node.targets = "whatever"
Which, when you try to parse, blows up with "TypeError: Assign field "targets" must be a list, not a str". I'd be much happier if this blew up right away when you try to make the assignment. At the moment, this is how it works in Jython (though I could support this with some contorting).
BTW -- I *am* volunteering to attempt to implement these things in CPython if there is support :)
+1 from me for adding this support. While I can see people wanting to create the node as soon as it is known to be needed and then plug in the parts as they get parsed, postponing the node creation to later once the subnodes have been done is not exactly a challenge. -Brett