Am 08.12.2011 08:18 schrieb 88888 Dihedral:
I use the @ decorator to behave exactly like a c macro that
does have fewer side effects.
I am wondering is there other interesting methods to do the
jobs in Python?
In combination with a generator, you can do many funny things.
For example, you can build up a string:
def mkstring(f):
"""Turns a string generator into a string,
joining with ", ".
"""
return ", ".join(f())
def create_answer():
@mkstring
def people():
yield "Anna"
yield "John"
yield "Theo"
return "The following people were here: " + people
Many other things are thinkable...
Thomas
--
http://mail.python.org/mailman/listinfo/python-list