Peter Otten added the comment:

I believe you are misinterpreting what you are seeing. Empty lines read from a 
file do not produce an empty string, you get "\n" instead which is true in a 
boolean context.

Try

[line.split()[0] for line in lines if line.strip() and not line.startswith("#")]

or add an extra check for all-whitespace line

[... if line and not line.isspace() and not line.startswith("#")]

----------
nosy: +peter.otten

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19657>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to