PEP 8 and list comprehension

后端 未结 4 1888
小鲜肉
小鲜肉 2021-01-17 18:27

I seem to have hit a bit of a problem with PEP 8.

I am using list comprehension which is longer than 79 characters long. So my text editor is screaming at me to do s

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-17 18:47

    if you want to stick strictly to pep8 then the hanging indent is your friend.

    return [
        (i['user_id'], i['id'])
        for i in j['collection']
        if i and i['user_id']]
    

提交回复
热议问题