Reputation: 16860
Imagine the following ternary condition:
foreground = self.foreground if self.foreground else c4d.COLOR_TRANS
In this case, I need to call self.foreground
twice just to check if it is True
or not.
Is there a way where I only need to call it once ?
Upvotes: 3
Views: 109
Reputation: 7780
You can use the boolean operators:
foreground = self.foreground or c4d.COLOR_TRANS
Upvotes: 3
Reputation: 601461
An equivalent expression is
foreground = self.foreground or c4d.COLOR_TRANS
Upvotes: 7