any trick to allow anonymous code blocks in python?
Doug Holton
insert at spam.here
Sat Jun 26 01:58:49 EDT 2004
Mark Hahn wrote:
> Prothon by the way doesn't have anonymous code blocks, but it can do:
>
> b = button()
> def b.onClick():
> print "You clicked me"
That's the alternative David Eppstein mentioned, and I like it even
better than my =: suggestion ( b.onclick =: <code block> ).
Perhaps that should be a proposal for Python. It's like the decorators
proposal (318). It just saves an extra step and is helpful for
framework designers (people who use metaclasses, etc.). Instead of
having to do this (or the other ways I mentioned):
def onclick(..):
...code here
b.onclick = onclick
You can save a step and just do like you said:
def b.onclick(...):
...code here
Similarly, decorators will save a step: (exact syntax TBD)
def myfunc (params) [synchronized]:
...
instead of:
def myfunc (params):
...
myfunc = synchronized(myfunc)
> I'm not trolling for Prothon users, since Prothon isn't ready for use
> anyway, but I'm curious why you have to use the Python intepreter.
Can you
> fill me in?
You know better than me, but last I checked, in prothon you can't use
any of the wealth of python bindings to 3rd-party code libraries.
Perhaps eventually either prothon could be made compatible with python,
or SWIG/Boost/Pyrex etc. could be made compatible with prothon so that
it would be easy for example to compile wxpython for prothon. wxprothon.
More information about the Python-list
mailing list