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
--
https://mail.python.org/mailman/listinfo/python-list