LoginSignup
5
5

More than 5 years have passed since last update.

python のor の論理演算子でない使い方

Posted at

spotify/luigi のs3 targetのコードで、またまた自分が知らない記述方法があった。

        self.fs = client or S3Client()

このorは一般的に条件式で使われる論理演算子ではないらしい。左辺が優先され、左辺がNoneの時には右辺が入る。

Python の or は条件分岐以外にも使える

5
5
2

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
5
5