file io (lagged values) newbie question
Paul Rubin
http
Tue Feb 20 11:41:22 EST 2007
Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> Would it be less crufty if I wrote it as a cryptic one liner without
> comments?
>
> f.write(str(data)[1:-1].replace(',', '') + '\n')
That doesn't look terribly cryptic to me, but maybe I'm used to it.
> > Try this: f.write(' '.join(str(x) for x in data) + '\n')
> That will only work in Python 2.5 or better.
It should work in 2.4, I think. Though, I haven't tried 2.5 yet so I
can't say from experience whether 2.4 is better than 2.5. Anyway,
f.write(' '.join(map(str, data)) + '\n')
should work in the whole 2.x series, if I'm not mistaken.
More information about the Python-list
mailing list