LoginSignup
1
0

More than 3 years have passed since last update.

Python lambda Djangoでドヤ りたいけどやめます

Posted at

Pythonのlambdaでドヤりたいけどやめる

sum(list(map(lambda item3: len(item3), list(filter(lambda item2: item2[0].hoge == 3, list(
    map(lambda item: list(item.huga.all()), list(piyo.all())))))
             )))

Djangoのクエリと組み合わせたどやどやラムダ式。

1ヶ月後見ると死ぬのでやめる

# データの取得
piyo_list = list(piyo.all())

# 詳細データを取得
huga_list = list(map(lambda item:list(item.huga.all()), piyo_list))

# レベル1,2を取得
hoge_list = list(filter(lambda item: item[0].level == 1 or item[0].level == 2,huga_list))

# レベル1,2の件数を取得
level_list = list(map(lambda item: len(item), hoge_list))

# レベルの合計件数を取得
sum_level = sum(level_list)

ドヤりたいのはわかるけどやめときます。

1
0
1

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
1
0