Martin v. Löwis wrote:
The question is, what is the specification for Python.

Now, that's a more interesting question than the question originally
asked (which I interpreted as "why does it work the way it works").

The only indication in the specification of that feature I could find
was:

http://docs.python.org/dev/library/constants.html

"Changed in version 2.4: Assignments to None are illegal and raise a
SyntaxError."

Now, given that this talks about the built-in namespace, this *doesn't*
specify that foo.None=1 should also raise a syntax error.

So the implementation apparently deviates from the specification.

In Python 3, None, True, and False are keywords, so clearly, the
intended semantics is also the implemented one (and the language
description for 2.x needs to be updated/clarified).

Interestingly enough, the semantics of True, False and None are different from one another in 2.6:

True = "blah" and False = 6 are perfectly legal in Python <=2.6.

Funny, I just ran into this. I was trying to figure out why the AST optimization code was breaking test_xmlrpc ... turns out xmlrpclib defines xmlrpclib.True and xmlrpclib.False and the optimizer was trying to resolve them as constants while compiling the module. Ouch.

What happened in 3k? Were the constants in xmlrpclib renamed/removed?

Cheers,
T

_______________________________________________
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