In the following case:

>>> class Foo:
...     _Foo__a = 100
...     __a = 33
...
>>> Foo._Foo__a
33

I think this behavior, for a user who does not know the convention, could be a surprise. Should be raising an exception (in order to inform the user the transformation of the name __a have been replaced an existing name) a possible --explicit-- alternative?

Another question is: where is the place in which this transformation occurs? Is it at the parser level, before the dictionary attribute is gave as argument to the metaclass?

I looked at the documentation:

http://docs.python.org/3/reference/lexical_analysis.html
http://docs.python.org/3/reference/expressions.html#atom-identifiers

but it is not clear when this transformation happens.

--
Marco Buttu
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to