[Python-Dev] None as a keyword / class methods

Peter Funk pf@artcom-gmbh.de
Thu, 23 Mar 2000 19:25:57 +0100 (MET)


Hi!

gvwilson@nevex.com:
> I'd also like to ask (separately) that assignment to None be defined as a
> no-op, so that programmers can write:
> 
>     year, month, None, None, None, None, weekday, None, None = gmtime(time())

You can already do this today with 1.5.2, if you use a 'del None' statement:

Python 1.5.2 (#1, Jul 23 1999, 06:38:16)  [GCC egcs-2.91.66 19990314/Linux (egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from time import time, gmtime
>>> year, month, None, None, None, None, weekday, None, None = gmtime(time())
>>> print year, month, None, weekday
2000 3 0 3
>>> del None
>>> print year, month, None, weekday
2000 3 None 3
>>> 

if None will become a keyword in Py3K this pyidiom should better be written as 
    year, month, None, None, None, None, ... = ...	
    if sys.version[0] == '1': del None

or
    try:
        del None
    except SyntaxError:
        pass # Wow running Py3K here!

I wonder, how much existinng code the None --> keyword change would brake.

Regards, Peter