3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

lambdaで使う時にそのまま使いたい時memo

Last updated at Posted at 2015-06-21

pythonは扉を態々閉扉する必要がないので書きやすい

##lambdaで使う時にそのまま使いたい時

普通に書く

.py
>>> text = "Which is Kinoko SaMpLE ?"
>>> text.lower().replace("sample", "takenoko")
'which-kinoko-takenoko-?'

lambdaを使い書く

.py
>>> text = "Which is Kinoko SaMpLE ?"
>>> (lambda x: x.lower().replace("sample", "takenoko"))(text)
'which-kinoko-takenoko-?'

実際にそのまま使いたい場面があるのかはわからない

3項演算子のif〜elseはpython上使えるようになったが、その場合処理を入れ込めない
[x if x < 100 else 'kinoko' for x in A]
値を持ってくることはできる

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?