Code block function syntax, anonymous functions decorator

castironpi at castironpi at
Fri Feb 8 07:50:44 CET 2008

On Feb 7, 7:13 pm, castiro... at wrote:
> On Feb 7, 2:48 am, "Diez B. Roggisch" <de... at> wrote:
> > Jean-Paul Calderone schrieb:
> > > On Wed, 06 Feb 2008 23:59:27 +0100, "Diez B. Roggisch"
> > > <de... at> wrote:
> > >> castiro... at schrieb:
> > >>> def run3( block ):
> > >>>    for _ in range( 3 ):
> > >>>       block()
> > >>> run3():
> > >>>    normal_suite()
> > >>> Introduces new syntax; arbitrary functions can follow 'colon'.
> > >>> Maintains readability, meaning is consistent.
> > >>> Equivalent to:
> > >>> def run3( block ):
> > >>>    for _ in range( 3 ):
> > >>>       block()
> > >>> @run3
> > >>> def anonfunc():
> > >>>    normal_suite()
> > >>> Simplification in cases in which decorators are use often.
> > >> This is non-sensical - how do you invoke anonfunc? They would all bind
> > >> to the same name, run3. Or to no name as all, as your "spec" lacks that.
> > > As he said, the decorator version is the _equivalent_ to the syntax he
> > > was proposing.  The point isn't to decorate the function, so perhaps he
> > > shouldn't have used decorator syntax, but instead:
> > >    def anonfunc():
> > >        normal_suite()
> > >    run3(anonfunc)
> > >    del anonfunc
> > > So it's not non-sensical.  It's a request for a piece of syntax.
> > >> Besides, it's butt-ugly IMHO. But taste comes after proper definition...
> > > It's properly defined.  Not that I'm endorsing this or anything.  I'd
> > > rather not see half-assed syntax proposals at all, even if they're super
> > > great (and some of the syntax that's made it into Python is much worse
> > > than this).
> > Yeah, I missed somehow that the decorator doesn't actually return anything.
> > Diez- Hide quoted text -
> > - Show quoted text -
> Even to myself, the idea is not sounding too bad.  You could require
> that the function have a 'codeblock' argument, (but that goes against
> pythonic "self" style customs), or pass it as an implicit first
> parameter.  Hybrid context manager and function.- Hide quoted text -
> - Show quoted text -

Sometimes, it's more appropriate to write

def f():


def f():

It's clearer to the eye and reader, and truer to the meaning of the
code.  From reading the docs, it's pretty clear that it's not what the
author meant for decorators.  So, even though it's good and practical,
as well as Pythonic, it doesn't get in.  However, from the writing, he
or she is most reasonable himself and practical.  Or herself.  How
does one reconcile these observations?  Not just anyone can invent a
computer language, but we all know what happens later to emperors and
the like.  Will they listen to reason?  Depends.  Is Python someone's
baby to raise, as court says, "any way he or she wants?"  Does he or
she want people to like it?  Does he or she only want to please
himself?  Or herself?  Anyone for a controlling share, hostile
takeover, or court injunction or protection order?  Gollum was a
Hobbit too once....

Maybe someone is getting back at "us", "the rest", "the world", for
ideas he or she had early on that weren't accepted.  Does he or she
even read these things down here?  What factors in to his or her
decision?  If someone "on top" doesn't like an idea, is it a strong
indicator that it's bad?  That it's good?  If myself, I don't
understand, it's one thing.  If "they" are wrong, it's another.  If he
or she is just shy, and won't get behind something clean and cool,
only without first making a friend, then maybe, after all, I can

If it's bad, they should be able to tell me why.  Is it?  Can they?
Will they?

Though don't forget: there's only so much that can fit in a language.
There are only so many letters, so many punctuation marks (many of
which are in use), and syntax is pricey-pricey.  Clearly, extensions
should be general.

$ to execute, .. to download, ## to get the size of a list, etc., cf.
Perl, are one side of this coin.  Math and logic are the other: it is
so general, in fact, that it's outside cause altogether.

How well you speak English is well-defined.  How well you speak Python
is too.  Your choice of custom-syntax languages, though, may not be.
Once a syntax is defined in a language, is the rest of the program in
it?  Say it like this: There's only so many specifics that -ought- to
go into any given line of code.

If it's not clear by now, I agree with many of the constraints that
"our someone" has imposed on Python-- or, more accurately, demanded of
us, its speakers, requests they have made for the future of it.  I've
had some proposals rejected.  They didn't fit in with-- what?  The
powers that be are not impartial; they are human, prejudiced emotions,
battered childhoods, and all.

I like to think that a good idea would get in to a language I create.
Does it?  No holds barred, no strings attached, no further
prerequisites, only that its good?  Perhaps "up there", priorities are
different; and it turns out that whatever it is  constitutes "good" is
not, after all, objective.  In other words, that there's no such
thing, only favorites.  I can't say that pride has always been
entirely dissociated from my own evaluations of ideas I've even had

Anyway, what are the constraints on a language?  If something is too
big to fit in a person's mind, too broad, or too general; too small,
too specific, or too distracting, it doesn't get in.  Even if it
should.  Computer languages are spoken by people too.  There is a
scarcity of resources, "time" in the sense of perception and the human
condition: memory and attention, available to any person, hence to any
aim, and if they're already allocated, then the long answer is, "the
people on top can't afford to think about it.  Bring some, not give
some, that is, time, to think about it."  Time is -a- money, of course
not money itself; it's a scarcity, and time on Earth is too.  Short
answer: "Sure.  Buy it."  And yes, this applies to politics and
religion.  But I digress.

How did Python's creator get the idea for it?  How long did it take to
push it?  And what through?  What are the hurdles?  What sponsors it,
what are its interests, and can I donation-style-buy, the equivalent
of a university building to it?  How much does my idea cost? ... in
time -or- money.  As an aside, one can always trust Gollum to hold a
Ring.  It's only a riddle to get it back.

Are the criteria for what is Pythonic, and what isn't, -com-plete-ly-
objective?  Are they written anywhere, or even spoken?  Alternatively,
do they go without saying?  If they're not, that's a shame.  If they
are, does it take judgment to see how closely an idea fulfills them?

Some of the criteria I've heard so far are, "it is in widespread use,"
and, "Guy X likes it."  I don't know Guy X, but Guy Y plays favorites
and takes bribes.  What about X?  There's an objective time frame on
the former: is it, how long has it been so, and will it ever be; is it
ahead of its time, after its time, right on time, and does it have
one?  What's involved in the latter is, for the lack of a better word,
personal.  But then again, are those on top equipped to evaluate the
former?  I'm not, and where am I going with this.  Time of course will
tell; stick around.

For my part, and for the idea of topic, the strongest argument I have
follows.  If we ever end up with poly-core PCs, multiple pipelines,
decoupled perpipherals, or parallel, "many small" types of hardware,
the ability to "hand around" ounce-sized blocks of code might be one
way to avail of them, and here's at least one way to do it.

If no one designs for a poly-core PC, and no one builds one, what?  Do
hardware manufacturers know where software manufacturers are taking
this?  Vice versa?  Who has crosshairs on the future?  Is leadership a
responsibility?  Who takes it?  Who leads?  Take me to him ...or her!

More information about the Python-list mailing list