Postfix/Prefix Operators (++,--)

Peter Hansen peter at engcorp.com
Sat Jun 7 04:11:59 CEST 2003


John Roth wrote:
> 
> "Peter Hansen" <peter at engcorp.com> wrote in message
> news:3EE0D19C.7D7FFCA0 at engcorp.com...
> > Joshua Marshall wrote:
> > >   >>> c = 1
> > >   >>> a = c++
> > >   >>> a
> > >   1
> > >   >>> c
> > >   2
> >
> > Except that that violates a fundamental aspect of Python, which while
> > I can't describe it in the best technical terms as I don't ever work
> > at the compiler level, could be said as "you are rebinding a name (c)
> > without using an assignment statement".  
> 
> Well, let's see. The "def", "class" and "import" statements all (re)bind
> names. So do several of the builtin functions (setattr() comes to mind
> immediately.)

I figured my inability to use the proper technical terms would cause
trouble.  I think Joshua has the best perspective: the fundamental
aspect of Python which is being violated here is that of not rebinding
things in an expression.  The examples you give are not expressions so
I think they still fit in the Python mould.  I'll comment on Joshua's
exception in a response to his message...

-Peter




More information about the Python-list mailing list