Named code blockes
Stephen Hansen
news at myNOSPAM.org
Tue Apr 24 01:02:41 EDT 2001
Oh, probably nothing unless you want the DoThisAndDoThatToItem thing to
take args from __init__, then you have that blah=blah thing. I had a
momentary brainfart; nested-scopes is irrelevent. The reason I mentioned
that bit was because I basically ignored the existance of def-within-a-def
until I saw examples of it in the talking-about-nested-scopes conversations.
My point was that it seems to me you can get a 'named code block' just
fine, or at least, you can do just what the James wanted to with a named
code block, without adding any more complexity to the language.
really-needs-to-add-the-below-into-a-sig-ly'y'rs - Stephen
(replace 'NOSPAM' with 'seraph' to respond in email)
Hey. I've never done that before. I wonder if Tim'll sue me now. Hmmm. :)
"Alex Martelli" <aleaxit at yahoo.com> wrote in message
news:9c24dr21aeo at news2.newsguy.com...
> "Stephen Hansen" <news at myNOSPAM.org> wrote in message
> news:ic%E6.195119$LO3.31059618 at typhoon.we.rr.com...
> [snip]
> > With the advent of nested_scopes, I believe you can accomplish this
by
> > just embedding a 'def' in either the __init__ or the collection.do
> function,
> > making your code as readable as that smalltalk code was. :)
> >
> > For instance:
> >
> > class Dummy:
> > def __init__(self, collection):
> > def DoThisAndDoThatToItem(item):
> > item.DoThis()
> > item.DoThat()
> >
> > collection.do(DoThisAndDoThatToItem)
>
> I don't get it -- what difference do nested scopes do to THIS code? It
> will run identically with or without nested scopes. What am I missing?
>
>
> Alex
>
>
>
More information about the Python-list
mailing list