Python 2.4 removes None data type?

John Machin sjmachin at lexicon.net
Fri Mar 4 20:44:44 EST 2005


gaudetteje at gmail.com wrote:
> I just read in the 'What's New in Python 2.4' document that the None
> data type was converted to a constant:
> http://python.org/doc/2.4/whatsnew/node15.html
>
> """
> # None is now a constant; code that binds a new value to the name
> "None" is now a syntax error.
> """
>
> So, what's the implications of this?

Relax. The sky is not falling.

>  I find the lack of explanation a
> little puzzling, since I've written code that compares a variable's
> type with the 'None' type.

It is saying that if you had been silly enough to do

None = "fubar"

you will now get a syntax error.

It said absolutely nothing about "removes None data type".

There are (at least) two possible reasons for a lack of explanation:

(1) Python is one of those expensive software products that hit you
with "upgrades" where you have difficulty finding about the changes in
advance (let alone participarting in the design process) and require
you to recode large chunks of your application but you can't find out
with any sort of precision the necessary changes might be from the
vague descriptions on a complex and ever-changing website.

(2) Unless you have done something completely idiotic [which the change
is designed to prevent], no change is required to your code. OR, like
for the changes to integer division, the change is announced for a
future version, you can do "from __future__ inport whatever". Any
furore (and there have been some doozies) noticeable in the newsgroup
is part of the design process, and has died down well before the
changes are released.

Which do you think is more likely?

>  For example, a variable would be
> initialized to 'None' and if it went through a loop unchanged, I
could
> determine this at the end by using a conditional type(var) ==
> type(None).

or by var == None or var is None

> What will type(None) return now?

Constants have types. What made you think that its type would change?




More information about the Python-list mailing list