[Python-Dev] Is it intentional that "sys.__debug__ = 1" is illegal in Python 2.7?

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Aug 1 02:41:02 CEST 2010


Barry Warsaw wrote:
> I've always understood the rules on
> double-underscore names to mean that Python reserves the use of those names
> for its own purposes, and is free to break your code if you define your own.
> That's very different than saying it's forbidden to use double-underscore
> names for your own purposes or assign to them, which is I think what's going
> on with the sys.__debug__ example.

I don't see that there's any difference. Once upon a time,
__debug__ wasn't special, and someone decided to use it for
their own purposes. Then Guido decided to make it special,
and broke their code, which is within the rules as you
just stated them. The rule doesn't say anything about what
*kinds* of breakage are allowed, so anything goes, including
making it impossible to assign to the name any more.

-- 
Greg


More information about the Python-Dev mailing list