while c = f.read(1)

Greg McIntyre greg at puyo.cjb.net
Mon Aug 22 05:23:33 EDT 2005


Okay, the 1st option seems more complicated and the 2nd option, while
simpler to my eye makes me worry about file descriptors, resource
management and memory running out.

My files are large, hence 1 character at a time, not f.read().

This is code from another employee and I'm just in the stages of going
through it and doing a basic clean-up before I get on to a proper
efficiency assessment, hence I don't want to change the way it works,
just make it as short and lucid as I can.

Your suggestion using the generator expression again seems more complex
than the original.

They're good suggestions though. Thank you! I'm just now catching up
with everybody's comments. Some of them seem quite entriguing.




More information about the Python-list mailing list