git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]# base = 1024 if (gnu or binary) else 1000

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On 2019-08-05 16:01, Hongyi Zhao wrote: > Hi, > > I read the source code of of `humanize/filesize.py' and find the 24 line > writing as follows: > > base = 1024 if (gnu or binary) else 1000 > > It seems this is not the standard usage of if ... else .... > > Is this a variant of lambda or some others? Could you please give me > some more hints? > It's a "conditional expression" (also called a "ternary if") and it's mentioned in Python's documentation. In this case it does the same as: if gnu or binary: base = 1024 else: base = 1000

- Prev by Date:
**base = 1024 if (gnu or binary) else 1000** - Next by Date:
**Please help me** - Previous by thread:
**base = 1024 if (gnu or binary) else 1000** - Next by thread:
**Please help me** - Index(es):