[Python-Dev] Recent experience with the _ast module (original) (raw)
Collin Winter collinw at gmail.com
Thu Feb 15 05:40:19 CET 2007
- Previous message: [Python-Dev] Recent experience with the _ast module
- Next message: [Python-Dev] Recent experience with the _ast module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2/14/07, "Martin v. Löwis" <martin at v.loewis.de> wrote:
Collin Winter schrieb: > 2) It turned out that {BinOp, BoolOp,AugAssign,etc}.op were already > singleton instances of their respective classes. I've changed > asdlc.py to no longer emit the *singleton names and to use the > corresponding *type types in their place, which will enable me to > write "node.op is ast.Add", etc.
I don't really like this - it's inconsistent. I'd rather prefer if the singletons where exposed under a name, e.g. ast.Add.singleton, or ast.add (if that doesn't cause conflicts).
What's inconsistent about it? That classes are being used for the _ast.{Add,Sub,Mult,etc} names?
I don't see the need for both _ast.Add and _ast.Add.singleton or _ast.add or however else it might be spelled. I'd be perfectly happy doing something like "_ast.Add = object()" (when initializing the _ast module), so long as I can write "node.op is _ast.Add", "node.op == _ast.Add", or something equally brief and to-the-point.
Collin Winter
- Previous message: [Python-Dev] Recent experience with the _ast module
- Next message: [Python-Dev] Recent experience with the _ast module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]