Python in is also an operator

In Python, ʻin is part of the forand can also be used as an operator to find out if a value is included as an element of a container such aslist or tuple`. If you use it well, you can make Pythonic expressions.

In the following example, if the list sys.argv containing the command line arguments contains the string --debug, then DEBUG is set to True, otherwise False is set. Will be done.

DEBUG = '--debug' in sys.argv

You can also use not in as the opposite:

SHORT = '--verbose' not in sys.argv

Recommended Posts

Python in is also an operator
Quicksort an array in Python 3
Python is an adult language
Difference between == and is in python
Use fabric as is in python (fabric3)
Write an HTTP / 2 server in Python
Develop an investment algorithm in Python 2
There is no switch in python
Create a Kubernetes Operator in Python
Python> What is an extended slice?
An alternative to `pause` in Python
What is "mahjong" in the Python library? ??
Hash in Perl is a dictionary in Python
Is Python's in operator slow? (From ABC167D)
How to use is and == in Python
Quadtree in Python --2
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
SendKeys in Python
Python is easy
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Python 3 operator memo
What is python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
When issuing an INSERT statement in Python, no such column is displayed
LINE-Bot [0] in Python
Python is instance
Csv in python
Disassemble in Python
Reflection in Python
Ternary operator (Python)
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
What is Python