Re: file io (lagged values) newbie question

2007-02-20 Thread Steven D'Aprano
On Tue, 20 Feb 2007 22:03:43 +0100, Bruno Desthuilliers wrote: [snip] >>>And that's not cruft? >> >> >> No. Why do you think it is crufty? > > Because it is ? *shrug* "Is not." "Is too." "Is not." Why is converting a list of integers to a string all at once more crufty than converting them

Re: file io (lagged values) newbie question

2007-02-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : > On Tue, 20 Feb 2007 07:08:02 -0800, John Machin wrote: > > >>>def write_series(data, f): >>>"""Write a time series data to file f. >>> >>>data should be a list of integers. >>>f should be an already opened file-like object. >>>""" >>># Convert data

Re: file io (lagged values) newbie question

2007-02-20 Thread Paul Rubin
Steven D'Aprano <[EMAIL PROTECTED]> 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 d

Re: file io (lagged values) newbie question

2007-02-20 Thread Steven D'Aprano
On Tue, 20 Feb 2007 07:08:02 -0800, John Machin wrote: >> def write_series(data, f): >> """Write a time series data to file f. >> >> data should be a list of integers. >> f should be an already opened file-like object. >> """ >> # Convert data into a string for writing. >>

Re: file io (lagged values) newbie question

2007-02-20 Thread John Machin
On Feb 21, 12:22 am, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 19 Feb 2007 22:17:42 -0800, hiro wrote: > > Hey there, I'm currently doing data preprocessing (generating lagged > > values for a time series) and I'm having some difficulties trying to > > write a file to disk. A friend of

Re: file io (lagged values) newbie question

2007-02-20 Thread Jussi Salmela
hiro kirjoitti: > Hey there, I'm currently doing data preprocessing (generating lagged > values for a time series) and I'm having some difficulties trying to > write a file to disk. A friend of mine, wrote this quick example for > me: > > > tweaked code: > ---

Re: file io (lagged values) newbie question

2007-02-20 Thread Steven D'Aprano
On Mon, 19 Feb 2007 22:17:42 -0800, hiro wrote: > Hey there, I'm currently doing data preprocessing (generating lagged > values for a time series) and I'm having some difficulties trying to > write a file to disk. A friend of mine, wrote this quick example for > me: If that's a quick example (we

file io (lagged values) newbie question

2007-02-19 Thread hiro
Hey there, I'm currently doing data preprocessing (generating lagged values for a time series) and I'm having some difficulties trying to write a file to disk. A friend of mine, wrote this quick example for me: ---