Python 2.4: Why only assignments to None are forbiden?
danb_83 at yahoo.com
Sat Nov 13 11:49:15 CET 2004
Ian Bicking <ianb at colorstudy.com> wrote in message news:<mailman.6320.1100296338.5135.python-list at python.org>...
> 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. It's a common mistake to do things
> > like this:
> > >>> def getFileName(file):
> > ... parts=file.split('/')
> > ... return parts('/')[-1]
> > Specially if you come from python 2.1.x where "file" didn't exist.
> > Instead, there was "open"
> Well, it's not really a mistake, because it works just fine and causes
> no problems. I use builtin names often, as they are annoyingly very
> convenient local variables. I try not to, but it still happens
> (especially file, though I make sure to distinguish between files and
I have the same problem.
Perhaps it would have better if "file" were named "File" instead.
More information about the Python-list