None

Werner Schiendl ws-news at gmx.at
Thu Oct 25 07:38:30 EDT 2001


Hi,

thanks for the thorough explanation. It is pretty obvious once thought about
it a second time.
It is only a bit confusing, because one rather expects None to be a literal
or constant value like NULL in C or true and false in C++.
At least if you normally use a C or C++ compiler ;-)

thanks
Werner

"Ken Seehof" <kseehof at neuralintegrator.com> wrote in message
news:mailman.1003881804.28186.python-list at python.org...
> > Hi,
> >
> > just had to try that out...
> >
> > >>> print None
> > None
> > >>> None = 17
> > >>> print None
> > 17
> > >>>
> >
> > Strange... is it intended that you can assign to None?
> >
> > In short, is this a bug or a feature?
> >
> > thanks
> > Werner
>
> When you understand why this is exactly what you would expect, your
> understand of python will jump to the next level :-).
>
> 'None' is a name, not a keyword.  Assigning to None simply attaches a new
> object to the name 'None'.  So it's not as scary as it looks.  You are not
> changing the value of an internal variable as you might expect.  In other
> languages such as C/C++ (which have early binding), assignment causes data
> stored in a variable to change.  In python (and other languages with late
> binding), assignment binds a name to some data without changing the data
> that the name used to refer to.  This is probably the most important
concept
> for python programmers to understand if they come from a C/C++ background.
>
> >>> x = None
> >>> print x
> None
> >>> None = 'spam!'
> >>> print None
> spam!
> >>> print x
> None
>
> Get it?
>
> - Ken
>
>
>





More information about the Python-list mailing list