In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 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? I find the lack of explanation a >little puzzling, since I've written code that compares a variable's >type with the 'None' type. 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). What will type(None) return now?
Empirically, NoneType, same as before. The change you refer to is to prevent the user from doing silly things like: ========================================================================== Python 2.3.4 (#1, Feb 8 2005, 13:07:40) [GCC 3.3.3 (NetBSD nb3 20040520)] on netbsd2 Type "help", "copyright", "credits" or "license" for more information. >>> type(None) <type 'NoneType'> >>> None="fred" <stdin>:1: SyntaxWarning: assignment to None >>> None 'fred' >>> type(None) <type 'str'> >>> ========================================================================== Python 2.4 (#1, Mar 4 2005, 16:55:16) [GCC 3.3.3 (NetBSD nb3 20040520)] on netbsd2 Type "help", "copyright", "credits" or "license" for more information. >>> type(None) <type 'NoneType'> >>> None="Fred" SyntaxError: assignment to None >>> type(None) <type 'NoneType'> >>> ========================================================================== So your idiom should still work. Note that since there is only one NoneType instance (i.e. None), you can just test for "var is None" and save yourself some work. Gary Duzan BBN Technologies -- http://mail.python.org/mailman/listinfo/python-list