O'Reilly logo
  • Sri Harsha V thinks this is interesting:

>>> [('sys' in line, line[:5]) for line in open('script2.py')] [(True, 'impor'), (True, 'print'), (False, 'x = 2'), (False, 'print')]

From

Cover of Learning Python, 5th Edition

Note

Multiple results in list comprehension. Nice way of running multiple statements returning results.