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

Jeremy Hylton hylton@jagunet.com
Thu, 23 Mar 2000 16:01:01 -0500 (EST)


>>>>> "GVW" == gvwilson  <gvwilson@nevex.com> writes:

  GVW> I'd also like to ask (separately) that assignment to None be
  GVW> defined as a no-op, so that programmers can write:

  GVW>     year, month, None, None, None, None, weekday, None, None =
  GVW> gmtime(time())

  GVW> instead of having to create throw-away variables to fill in
  GVW> slots in tuples that they don't care about.  I think both
  GVW> behaviors are readable; the first provides genuinely new
  GVW> functionality, while I often found the second handy when I was
  GVW> doing logic programming.

-1 on this proposal

Pythonic design rule #8:
    Special cases aren't special enough to break the rules.

I think it's confusing to have assignment mean pop the top of the
stack for the special case that the name is None.  If Py3K makes None
a keyword, then it would also be the only keyword that can be used in
an assignment.  Finally, we'd need to explain to the rare newbie 
who used None as variable name why they assigned 12 to None but that
it's value was its name when it was later referenced.  (Think 
'print None'.)

When I need to ignore some of the return values, I use the name nil.

year, month, nil, nil, nil, nil, weekday, nil, nil = gmtime(time())

I think that's just as clear, only a whisker less efficient, and
requires no special cases.  Heck, it's even less typing <0.5 wink>.

Jeremy