Collin Winter schrieb:
> But Pass, Break, Continue and Ellipsis aren't in the same category as
> Add, Mult, Div, etc.. The former stand alone


That's not true. Pass, Break, Continue don't stand alone; they are
members of the body sequence of some other statement (in particular
for Break and Continue), you need some kind of loop around it.

In any case, they are in the same category as they have no child
nodes, which is a prerequisite for not creating objects. I can't
see why the property "stand alone" should impact whether objects
are created or not.

> So: what if _ast.Add and co. were singleton instances of _ast.AST or
> even of a subclass of AST, like _ast.Op? That way, we keep the
> consistency that all AST nodes are instances of _ast.AST and I get the
> nice property I'm looking for, ie, "node.op is _ast.Mult".

I like this better. The base class you are looking for is _ast.operator;
it should be already there (please do take a look at Python.asdl to
see how I came to this conclusion, without studying the _ast module
again).

Regards,
Martin
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to