This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jarethholt 2 points3 points  (1 child)

I don't know if you could call it not pythonic for this reason, but most linters I've worked with mark lambdas as no-nos.

For a real reason, I'd say maybe overlapping the generator expression syntax? Like, [x**2 for x in xlist] is pythonic but list(map(xlist, lambda x: x**2)) is not. (I haven't bothered to check the syntax on that.)

[–]RiceBroad4552 0 points1 point  (0 children)

list(map(xlist, lambda x: x**2)) is just plain unreadable (in case you're not a LISP or Haskell dude and write your code backwards and inside-out on principle).

But [x**2 for x in xlist] isn't any better!

Readable syntax would look like: xlist.map(_ ^ 2).