scope of function parameters

Jussi Piitulainen jpiitula at ling.helsinki.fi
Mon May 30 06:40:19 EDT 2011


Laurent Claessens writes:
> Le 30/05/2011 11:02, Terry Reedy a écrit :
> > On 5/30/2011 3:38 AM, Laurent wrote:
> >
> >>  Cool. I was thinking that "5" was the name, but
> >>   >>>  5.__add__(6)
> >>  File "<stdin>", line 1
> >>  5.__add__(6)
> >
> >
> > Try 5 .__add__(6)
> 
> What is the rationale behind the fact to add a space between "5" and
> ".__add__" ?
> Why does it work ?

Oh joy.

  >>> [5][0].__add__([6][-1])
  11

The parser just needs the help to detect the intended token boundary
instead of another, unintened one. As the others already say.



More information about the Python-list mailing list