P
Peter Cacioppi
I really like the logic that Pythons "or" is not only short-circuit but non-typed.
So I can say
y = override or default
and y won't necc be True or False. If override boolean evaluates to True (which, for most classes, means not None) than y will be equal to override. Otherwise it will be equal to default.
I have two questions
--> Is there a handy name for this type of conditional (something as catchy as "short circuit or")
and
--> Is there a common idiom for taking advantage of the similar behavior of "and". The "override or default" just makes me grin every time I use it.
Thanks
So I can say
y = override or default
and y won't necc be True or False. If override boolean evaluates to True (which, for most classes, means not None) than y will be equal to override. Otherwise it will be equal to default.
I have two questions
--> Is there a handy name for this type of conditional (something as catchy as "short circuit or")
and
--> Is there a common idiom for taking advantage of the similar behavior of "and". The "override or default" just makes me grin every time I use it.
Thanks