my favorite line of py code so far
rosuav at gmail.com
Sun Nov 10 11:23:46 CET 2013
On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi
<peter.cacioppi at gmail.com> wrote:
> Chris said :
> "I think map is fine if you can use a named function, but if you can't
> come up with a descriptive name for what you're doing, a comprehension
> is probably better (as it'll have the code right there). Mapping _
> across everything tells you nothing about what it's actually doing"
> How about this? I put the following in my catchall_utility.py module
> # the oneArg combinator takes a multi-argument calleable
> # and returns the equivalent single argument calleable
> oneArg = lambda c: lambda x : c(*x)
Now it has a name, so I could imagine you importing it into modules
and using it usefully. I'd be inclined to call it something along the
lines of "unpacked" but that's just bikeshedding.
> ... I find that I write fewer bugs when I use idioms that resonate.
Absolutely! The unfortunate truth, though, is that idioms that
resonate with you _and nobody else_ are just as big a problem as bugs,
because they're unmaintainable. So hopefully what you're doing will
make sense to other people too!
More information about the Python-list