ot : boolean operators
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/03/2012 at 11:58, xxxxxxxx wrote:
this is slightly ot, but i'll be asking nevertheless :D. is there a shorter way to write the
following boolean expression in python ?if x == a or x == b or x == c :
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/03/2012 at 12:52, xxxxxxxx wrote:
if x in [a, b, c]:
There may be a time where you want to apply another operator or a complex comparison to a number of variables.
if any(map(lambda v: x <= v, [a, b, c])) :
Or use all() if you want the if-clause being True only when the comparison matches to every element, not any.
if all(map(lambda v: x <= v, [a, b, c])) :
You can find a listing of all built-in functions here. Note that this is the CPython 2.7 documentation. Cinema 4D embedds the 2.6 distribution and therefore there may be functions documented not availablenin C4D. (The 2.6 version of the page is here but doesn't habe such a nice table of all functions.)
Cheers,
-Niklas -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/03/2012 at 17:02, xxxxxxxx wrote:
thanks !