3 ms·
This is not 'akin to a decorator', it's is partial function! Do you name your functions: def THIS_IS_IN_GLOBAL_SCOPE(): ... Of course you don't! Then why
by emidln 10y ago
This is not 'akin to a decorator', it's is partial function! Do you name your functions:
def THIS_IS_IN_GLOBAL_SCOPE(): ...
Of course you don't! Then why would you consider forcing someone to write this:
def bar(spam, eggs):
print spam, eggs
def foo(eggs):
return bar('baz', eggs)
Which even manages to lose information, hence why functools.partial exists in the first place.
This is bad because readers now see FOO and think it's a constant:
FOO = functools.partial(bar, 'baz')