On Feb 1, 2008 4:43 PM, Ian Kelly <[EMAIL PROTECTED]> wrote: > Prettier: > > #!/usr/bin/env python > import sys > from random import * > > rulefile = open(sys.argv[1], "r") > print SystemRandom().choice(rule for rule in rulefile if rule)
Oops, choice() calls len(), which raises an exception on the generator comprehension. But this works: print SystemRandom().choice([rule for rule in rulefile if rule]) -root

