When you want to print a bunch of variables in Python, you have quite a few options, such as:
for i in range(len(iterable)):
print iterable[i].name
OR
map(lambda i: sys.stdout.write(i.name), iterable)
The reason I use sys.stdout.write instead of print in the second example is that lambdas won't accept print, but sys.stdout.write serves the same purpose.
You can also print conditionally with the ternary operator:
map(lambda n: None if n % 2 else sys.stdout.write(str(n)), range(1, 100))
So it would be really handy if I could check an entire sequence for a condition that would warrant an exception in such a way:
map(lambda o: raise InvalidObjectError, o.name if not o.isValid else o(), iterable)
But that doesn't work. Is there such an object for raise in Python, and if so, where is it?