Python 2.4: Why only assignments to None are forbiden?

James Stroud jstroud at mbi.ucla.edu
Fri Nov 12 16:08:30 EST 2004


Forbidding assignment to arbitrary things seems like a bad idea.

I remember some learning manual recommended this (or the equivalent):

def do_stuff_to_bob(bob=None):
  if not bob:
    bob = ["carol","ted","alice"]
  #do stuff to bob
  return bob

otherwise bob would already be defined from the last call (because it is a 
mutable type? I can't remember.). How else to handle this in 2.4?

On Friday 12 November 2004 01:11 pm, Josef Meile wrote:

> Hi,
>
> Textually from the highlights of python 2.4:
>
> "Assigning to None - the compiler now treats assigning to None as a
> SyntaxError."
>
> I think in general assignments to built-in types, functions, and
> variables should be also forbiden.


James



More information about the Python-list mailing list