None assigment

Gregoire Welraeds greg at
Thu Feb 8 12:12:27 EST 2001

> There's nothing special about the name "None"; it's just a variable,
> like any other. 
> After doing "None = 2", you can "del None" to get the default value 
> back.

If we follow that logic, I could use any non assigned variable to have the
following working:

>>> a= [1,'',3]
>>> filter(b,a)

but this won't work as the interpreter complains that there is no variable
named b.

Always according to this logic, I have tried to run the following:

>>> a= [1,'',3]
>>> b= 0 # b could be anything
>>> del b
>>> filter(b,a)

but this won't work either as stated in the documentation. Referencing a
"deleted" variable is an error at least until another value is assigned to
it (see del statement section in the tutorial).

It seems that (the so called variable) None is neither a variable like any
other, nor is it a label as stated by Simon Brunning in another post.

Furthermore, I found that the documentation is rather confusing about this
question. Here's what I found while browsing:

>From Python Reference Manual:

-	6.1 Expression statements 	
	in Python, procedures return the value None

-	3.2 The standard type hierarchy 
	This type has a single value. There is a single object with this
	value. This object is accessed through the built-in name None. It 
	is used to signify the absence of a value in many situations,
	e.g., it is returned from functions that don't explicitly return
	anything. Its truth value is false. 	

>From Python Library Reference:

-	3.4 types -- Names for all built-in types
       		The type of None.

- 	2.1.1 Truth Value Testing 
	Any object can be tested for truth value, for use in an if or while
	condition or as operand of the Boolean operations below. The following
	values are considered false: 

>From Python/C API Reference Manual

-	7.1.2 The None Object
And finally, to add to the confusion, I have try the following:

>>> a= [1,'',3]
>>> filter(0,a)

for what the system complains that 0 is a non function type ! 

Now If we resume:
None is a value
None is a built in type
None is an object
None is an alias (as I understand it) for lambda x: x in the case of
filter(None, some_list)

Now that I look at this problem, I'm totally confused about None. Any
explanaition is welcome. Anyway, I don't understand that one can override
None. Could you give me at least one single good reason to do that.

Gregoire & Xavier
>From Perceval Development team, (python division :)

On 9 Feb 2001, Paul Foley wrote:

~# Date: 09 Feb 2001 02:30:45 +1300
~# From: Paul Foley <mycroft at>
~# To: Gregoire Welraeds <greg at>
~# Subject: Re: None assigment
~# On Thu, 8 Feb 2001 12:54:00 +0100 (CET), Gregoire Welraeds wrote:
~# > While playing a bit with python 2.0, I found that I can assign some value
~# > to None
~# > EG: None= 2
~# > which I found to be very pernicious because then the following, for
~# > example, won't work any more:
~# >>>> b= filter(None, [1,2,'',3])
~# > Bug or feature ?
~# Neither, really.
~# > If it is a feature (I suppose it is not a bug :), what is the interest of
~# > this ?
~# There's nothing special about the name "None"; it's just a variable,
~# like any other.  Any other behaviour would be inconsistent.  None is
~# usually bound to the special "None" value (note: values have nothing
~# to do with names; the None value is not really related to the name
~# "None"), that's all.
~# After doing "None = 2", you can "del None" to get the default value
~# back.
~# -- 
~# Qui beneficium dedit, taceat; narret qui accepit                 -- Seneca
~# (setq reply-to
~#   (concatenate 'string "Paul Foley " "<mycroft" '(#\@) ">"))

More information about the Python-list mailing list