[Python-ideas] setting function properties with a decorator syntax

Andrey Fedorov anfedorov at gmail.com
Thu Mar 18 22:01:55 CET 2010

spir wrote:

> A "parameterisable" generator factory: [...]

Good lord, no! Nooo!

"power" is one thing with one semantic meaning
"range" is another thing with another semantic meaning

There is absolutely no excuse for mixing the two implementation into a
"power-range" monstrosity. Implement the two separately and make some custom
function composition like:

def pow(x, n):
    return x**n

def pow_o_range(n, a, b):
    return [(x, pow(x, n)) for x in range(a,b)]

for i, x in pow_o_range(3, 1, 10):
   print "%s:%s" % (i,x),

# prints "1:1 2:8 3:27 4:64 5:125 6:216 7:343 8:512 9:729"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100318/07984cb5/attachment.html>

More information about the Python-ideas mailing list