Named code blockes

Alex Martelli aleaxit at yahoo.com
Tue Apr 24 18:32:00 EDT 2001


"Steve Holden" <sholden at holdenweb.com> wrote in message
news:VQjF6.5612$qc2.2264336 at typhoon.southeast.rr.com...
> "Rainer Deyke" <root at rainerdeyke.com> wrote in ...
    [snip]
> > > > consistent way of naming them.  Consider:
> > > >
> > > > a = 5
> > > > b = lambda: None
> > > > def c():
> > > >   pass
> > > >
> > > > These are three assignments, but only two look like assingments.
The
> > >
> > > They are three ways to bind (or re-bind) names, but only two of them

_They_ (the three things of which you said 'these are three assignments'),
not _there_ are.  I.e., I was very specifically speaking about these three
statements, not about all Python ways to bind (or re-bind) names.

> > > ARE "assignments" -- Python's syntax defines assignments, plain and
> > > augmented, rather precisely, and there is no 'def' keyword there:-).
> >
> > I count four ways ('import', 'def', '=', and augmented assignment), not

There were no import nor augmented assignments in the three things of
which you stated "these are three assignments".  There were two assignment
statements (both of the plain kind) and one def statement.

Whether augmented assignments can "bind (or re-bind) names" -- hmmm,
they can only re-bind them sometimes, never bind them if they weren't
previously bound, of course.

> > counting 'globals().set' and similar tricks.

You count built-in function setattr as "a trick"?  In what sense?  I _could_
understand the 'exec' statement & friends being considered "tricks", but
setattr is so nice and clean.


> Then there's class. I count five ways ...

If we're taking a survey, as an old setattr fan I insist it be counted
too!-)


Alex






More information about the Python-list mailing list