Python version of perl's "if (-T ..)" and "if (-B ...)"?
Hrvoje Niksic
hniksic at xemacs.org
Wed Feb 17 14:18:39 EST 2010
Tim Chase <python.list at tim.thechases.com> writes:
> if portion is None:
> content = iter(f)
iter(f) will iterate over lines in the file, which doesn't fit with the
rest of the algorithm. Creating an iterator that iterates over
fixed-size file chunks (in this case of length 1) is where the
two-argument form of iter comes in handy:
content = iter(lambda: f.read(1), '')
More information about the Python-list
mailing list