0

I know this may sound a silly question, but coming from Scala, I really appreciate the short notation used with functional expressions involving the placeholder _.

For example in Scala, to do a mapping

val x = Seq(1,2,3)
val y = x.map(_+1)

The equivalent in Python requires the usage of lambda which makes the expression much longer:

x = list(1,2,3)
y = list(map(lambda v: v+1, x))

Is it programmed in Python to somewhat introduce the placeholder symbol _ in future versions for notational brevity, when clear from the context?

linello
  • 8,451
  • 18
  • 63
  • 109
  • No, but generally you should avoid lambda anyway. Most use cases would be better served with some comprehension construct rather than an anonymous function and `map`/`filter` – juanpa.arrivillaga May 13 '20 at 08:37
  • Many of the circumstances in which comprehensions are better in python are *because* lambdas are so verbose. – Karl Bielefeldt May 14 '20 at 02:38

0 Answers0