In Perl, you often have to do things like function() || alternative()
function() || alternative()
. If the first returns false, it will run the second.
How is this easy to implement in Python?
Update
Examples (pseudo-code):
x = func() or raise exeption x = func() or print(x) func() or print something
If possible solutions should work with Python 2.5+
Note. There is an assumption that you cannot modify func () to throw exceptions or to write wrappers.
source share