Paul McGuire wrote:
> "Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in
> message news:[EMAIL PROTECTED]
>
>>bruno at modulix a écrit :
>>(snip)
>>
>>(responding to myself)
>>(but under another identity - now that's a bit schizophrenic, isn't it ?-)
>>
>
>
> Do you ever flame yourself?
class M
bruno at modulix wrote:
> fin = open(path, 'r')
> fout = open(temp, 'w')
> for line in fin:
> if line.strip():
> fout.write(line)
> fin.close()
> fout.close()
>
> then delete path and rename temp, and you're done. And yes, this is
> actually the canonical way to do this !-)
What if there's a
[Tim Peters]
>> In 2.5 `file` is unchanged but `open` becomes a function:
>>
>> >>> file
>>
>> >>> open
>>
[Paul Rubin]
> So which one are we supposed to use?
Use for what? If you're trying to check an object's type, use the
type; if you're trying to open a file, use the function.
>>> type(op
"Tim Peters" <[EMAIL PROTECTED]> writes:
> In 2.5 `file` is unchanged but `open` becomes a function:
>
> >>> file
>
> >>> open
>
So which one are we supposed to use?
--
http://mail.python.org/mailman/listinfo/python-list
Tim Peters wrote:
> [John Salerno, on the difference between `open` and `file`]
>> Interesting. What is the difference between them now?
>
> In 2.5 `file` is unchanged but `open` becomes a function:
>
file
>
open
>
So they are still used in the same way though?
--
http://mail.python
[John Salerno, on the difference between `open` and `file`]
> Interesting. What is the difference between them now?
In 2.5 `file` is unchanged but `open` becomes a function:
>>> file
>>> open
--
http://mail.python.org/mailman/listinfo/python-list
"Bruno Desthuilliers" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> bruno at modulix a écrit :
> (snip)
>
> (responding to myself)
> (but under another identity - now that's a bit schizophrenic, isn't it ?-)
>
Do you ever flame yourself?
-- Paul
--
http://mail.python.org/mailma
Aahz wrote:
> Python 2.5a2 (trunk:46052, May 19 2006, 19:54:46)
> [GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
open is file
> False
>
> Per the other comments in this thread, Guido agreed that mak
In article <[EMAIL PROTECTED]>,
James Stroud <[EMAIL PROTECTED]> wrote:
>Paul McGuire wrote:
>>
>> 1. open("xxx") still works - not sure if it's even deprecated or not - but
>> the new style is to use the file class
>
>Python 2.3.4 (#4, Oct 25 2004, 21:40:10)
>[GCC 3.3.2 (Mandrake Linux 10.0 3.3.
John Salerno <[EMAIL PROTECTED]> writes:
> Paul McGuire wrote:
>
> > I think it is just part of the objectification trend - "f =
> > open('xyzzy.dat')" is sort of a functional/verb concept, so it has
> > to return something, and its something non-objecty like a file
> > handle - urk! Instead, us
Bruno Desthuilliers wrote
>
> It has been, at a time, recommended to use file() instead of
> open(). Don't worry, open() is ok - and I guess almost anyone
> uses it.
http://mail.python.org/pipermail/python-dev/2005-December/059073.html
--
http://mail.python.org/mailman/listinfo/python-list
bruno at modulix a écrit :
(snip)
(responding to myself)
(but under another identity - now that's a bit schizophrenic, isn't it ?-)
> For the general case, the best way to go would probably be an iterator:
>
> def iterfilter(fileObj):
> for line in fileObj:
> if line.strip():
> yield
John Salerno a écrit :
> Paul McGuire wrote:
>
>> Your coding style is a little dated - are you using an old version of
>> Python? This style is the old-fashioned way:
>
>
> I'm sure it has more to do with the fact that I'm new to Python, but
> what is old-fashioned about open()?
It has been
John Salerno a écrit :
> John Salerno wrote:
>
>> What is the best way of altering something (in my case, a file) while
>> you are iterating over it? I've tried this before by accident and got
>> an error, naturally.
>>
>> I'm trying to read the lines of a file and remove all the blank ones.
>>
On Fri, 19 May 2006 13:36:35 -0700, James Stroud wrote:
> Paul McGuire wrote:
>> Your coding style is a little dated - are you using an old version of
>> Python? This style is the old-fashioned way:
> [clip]
>> 1. open("xxx") still works - not sure if it's even deprecated or not - but
>> the new
In <[EMAIL PROTECTED]>, Paul McGuire wrote:
> 1. open("xxx") still works - not sure if it's even deprecated or not - but
> the new style is to use the file class
It's not deprecated and may be still used for opening files. I guess the
main reason for introducing `file` as a synonym was the possi
Paul McGuire wrote:
> I think it is just part of the objectification trend - "f =
> open('xyzzy.dat')" is sort of a functional/verb concept, so it has to return
> something, and its something non-objecty like a file handle - urk! Instead,
> using "f = file('xyzzy.dat')" is more of an object const
Paul McGuire wrote:
>>> answer is - you are STILL UPDATING THE LIST YOUR ARE ITERATING OVER!!!
>> Doh! I see that now! :)
>>
>
> Sorry about the ALL CAPS... I think I got a little rant-ish in that last
> post, didn't mean to shout. :)
>
> Thanks for being a good sport,
Heh heh, actually it was
"John Salerno" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Paul McGuire wrote:
>
> > Your coding style is a little dated - are you using an old version of
> > Python? This style is the old-fashioned way:
>
> I'm sure it has more to do with the fact that I'm new to Python, but
> w
Paul McGuire wrote:
> Your coding style is a little dated - are you using an old version of
> Python? This style is the old-fashioned way:
[clip]
> 1. open("xxx") still works - not sure if it's even deprecated or not - but
> the new style is to use the file class
Python 2.3.4 (#4, Oct 25 2004, 2
Paul McGuire wrote:
> Your coding style is a little dated - are you using an old version of
> Python? This style is the old-fashioned way:
I'm sure it has more to do with the fact that I'm new to Python, but
what is old-fashioned about open()? Does file() do anything different? I
know they are
"John Salerno" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> John Salerno wrote:
> > What is the best way of altering something (in my case, a file) while
> > you are iterating over it? I've tried this before by accident and got an
> > error, naturally.
> >
> > I'm trying to read th
bruno at modulix wrote:
> Now if what you want to do is just to rewrite the file without the blank
> files, you need to use a second file:
>
> fin = open(path, 'r')
> fout = open(temp, 'w')
> for line in fin:
> if line.strip():
> fout.write(line)
> fin.close()
> fout.close()
>
> then delet
John Salerno wrote:
> What is the best way of altering something (in my case, a file) while
> you are iterating over it? I've tried this before by accident and got an
> error, naturally.
>
> I'm trying to read the lines of a file and remove all the blank ones.
> One solution I tried is to open the
John Salerno wrote:
> What is the best way of altering something (in my case, a file) while
> you are iterating over it? I've tried this before by accident and got an
> error, naturally.
>
> I'm trying to read the lines of a file and remove all the blank ones.
> One solution I tried is to open
What is the best way of altering something (in my case, a file) while
you are iterating over it? I've tried this before by accident and got an
error, naturally.
I'm trying to read the lines of a file and remove all the blank ones.
One solution I tried is to open the file and use readlines(), th
26 matches
Mail list logo