quite simply...what???
In [108]: bool([ x for x in range(10) if False ])
Out[108]: False
In [109]: bool( x for x in range(10) if False )
Out[109]: True
Why do these two evaluate differently? I was expecting that they would
evaluate the same but the generator would return true *as soon as the
first value is detected*. I'd really expect it to act more like...
def has_values(g):
for i in g:
return True
return False
So what's going on here? Am I using the wrong function or is this
actually just a bug?
--
Josh Dukes
MicroVu IT Department
--
http://mail.python.org/mailman/listinfo/python-list