Chris said :
"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! "
There is some truth in what you say ... but in
On Sun, Nov 10, 2013 at 7:57 PM, Peter Cacioppi
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 ev
Sorry, typo, meant to say
To be clear, I was never really intending to keep the
_ = lambda c : lambda x : c(*x)
map(_(P), zip([1,2,3], [6, 5, 4]))
code snippets in my final work product. The purpose of this thread was too fish
around for ideas on what to replace it with...
--
https://m
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"
OK, thi
Stefan Behnel wrote:
> Peter Otten, 09.11.2013 12:49:
>> There is no obvious meaning attached to _ -- so don't use it.
>
> Not quite true. Depending on the context, the obvious meanings of "_" in
> Python are either
>
> 1) "ignore me", e.g. in
>
> _, b = some_tuple
>
> or
>
> 2) "this is
On Sat, Nov 9, 2013 at 11:41 PM, Stefan Behnel wrote:
> 2) "this is a non-public thing", as in
>
> class Xyz:
> _private = 1
Your three meanings all have the etymology of "ignore me", but I would
distinguish this one from the others. An underscore used on its own
has meaning; an under
Peter Otten, 09.11.2013 12:49:
> There is no obvious meaning attached to _ -- so don't use it.
Not quite true. Depending on the context, the obvious meanings of "_" in
Python are either
1) "ignore me", e.g. in
_, b = some_tuple
or
2) "this is a non-public thing", as in
class Xyz:
Peter Cacioppi wrote:
> Peter Otten said:
>
>
> ">>> _ = lambda c: lambda x: c(*x)
list(map(_(P), zip([1,2,3], [6, 5, 4])))
> [Point(x=1, y=6), Point(x=2, y=5), Point(x=3, y=4)]
>
> ? While the obvious approach would be
>
[P(*args) for args in zip([1,2,3], [6, 5, 4])]
> [Point(x=1, y
Peter Cacioppi writes:
[P(*args) for args in zip([1,2,3], [6, 5, 4])]
[P(x,y) for x,y in zip(...)]
> Are you saying it's always preferable to avoid map?
Not always. Depends on context, partly subjective.
> I sometimes use map, sometimes comprehensions. I suspect other people
> do the sam
On Sat, Nov 9, 2013 at 8:23 PM, Peter Cacioppi wrote:
> I sometimes use map, sometimes comprehensions. I suspect other people do the
> same, that's why the language supports map and comprehensions.
I think map is fine if you can use a named function, but if you can't
come up with a descriptive n
Peter Otten said:
">>> _ = lambda c: lambda x: c(*x)
>>> list(map(_(P), zip([1,2,3], [6, 5, 4])))
[Point(x=1, y=6), Point(x=2, y=5), Point(x=3, y=4)]
? While the obvious approach would be
>>> [P(*args) for args in zip([1,2,3], [6, 5, 4])]
[Point(x=1, y=6), Point(x=2, y=5), Point(x=3, y=4)]
Peter Cacioppi wrote:
> my fav so far is this
>
> _ = lambda c : lambda x : c(*x)
>
> c can be any calleable and x any iterable, but I tend to use it with a
> class, and then map _(class) over the result of a zip.
>
> It must be in the library somewhere, but I haven't found it. I'm never
> sure
Chris said:
"So... for any given class, it returns a tweaked version that unpacks
an iterable of its arguments instead of taking separate args. "
It works with any calleable (not just any class), but otherwise your summary is
spot on.
"Interesting, perhaps, but not something that'll be needed
On Sat, Nov 9, 2013 at 9:22 AM, Peter Cacioppi wrote:
> my fav so far is this
>
> _ = lambda c : lambda x : c(*x)
>
> c can be any calleable and x any iterable, but I tend to use it with a class,
> and then map _(class) over the result of a zip.
>
> It must be in the library somewhere, but I have
my fav so far is this
_ = lambda c : lambda x : c(*x)
c can be any calleable and x any iterable, but I tend to use it with a class,
and then map _(class) over the result of a zip.
It must be in the library somewhere, but I haven't found it. I'm never sure
what to call it, so I just reroll it i
15 matches
Mail list logo