Fri, 10 Dec 1993 17:25:32 +0100
> I picked up the idiom:
> None = f( x )
> from some random piece of Python code ( in the library ? in the demo's ? )
> as a notation that I was throwing away the value of f(x) and didn't
> want it printed either. I think the code where I saw it originally
> did something like:
> a, None, None, b, c, None = tuple_returning_function( )
> to only grab the needed unpacked values.
> I *THINK*, long ago, I actually checked that None *DIDN'T* actually
> get a value assigned to it. In any event, it never got me into
> trouble before, so I had come to assume that 'None' was sort of
> like the risc zero-register.
> Now, I HAVE gotten into trouble using it. And now I discover that:
> >>>None = 1
> Has this behaviour changed ?
> Or is my memory totally false about what it USED to do ?
> Help!!! I'm about to dump core over this !!!
I'm sorry, but this never worked. I sincerely hope you didn't pick
it up from any code in the distribution (I challenge you to show where
The key to understanding what happened in your example is that the
*name* None gets no special treatment from the compiler -- it is just
a name initialized in module builtin to the *value* None. BTW this
won't happen easily in functions, since there the assignment to None
creates a local variable named None which probably won't be used
elsewhere in the function.
What *does* work is "void = f(x)" where void can be any name not
otherwise used. (I often use dummy().)
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>