Dan wrote:
> BJo:rn Lindqvist wrote:
> > On 8/30/06, Dan <[EMAIL PROTECTED]> wrote:
> >> Is my data safer if I explicitly close, like this?:
> >> fileptr = open("the.file", "w")
> >> foo_obj.write(fileptr)
> >> fileptr.close()
> > Have you ever experienced a problem caused by not exp
BJörn Lindqvist wrote:
> On 8/30/06, Dan <[EMAIL PROTECTED]> wrote:
>> Is my data safer if I explicitly close, like this?:
>> fileptr = open("the.file", "w")
>> foo_obj.write(fileptr)
>> fileptr.close()
>
> Have you ever experienced a problem caused by not explicitly closing
> your
On 8/30/06, Dan <[EMAIL PROTECTED]> wrote:
> Is this discouraged?:
>
> for line in open(filename):
>
In theory, it is. In practice, that is the way Python code is written
because it more natural and to the point. Not just for hacked together
scripts, lots of third party modules incl
Paul Rubin wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > I disagree strongly with this assertion. It's not as efficient overall
> > as other GC implementations, but it's not a case of "less efficient to
> > do the same task". Reference counting buys you deterministic GC in the
> >
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> I disagree strongly with this assertion. It's not as efficient overall
> as other GC implementations, but it's not a case of "less efficient to
> do the same task". Reference counting buys you deterministic GC in the
> pretty common case where you
Dan <[EMAIL PROTECTED]> wrote:
> Is this discouraged?:
>
> for line in open(filename):
>
>
> That is, should I do this instead?:
>
> fileptr = open(filename)
> for line in fileptr:
>
> fileptr.close()
One reason to use close() explicitly is to make sure tha
Paul Rubin wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > > > (And personally I think the benefits to programmers of guaranteeing
> > > > ref-counting semantics would outweigh the additional headaches for
> > > > Jython and other alternative implementations).
>
> Ref counting is a rat
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> Sure. But most Java GCs are pretty reasonable and for typical code
> will run periodically (what I call the not-horribly-distant future).
If your system allows max 100 files open and you're using 98 of them,
then "horribly distant future" can be a
Paul Rubin wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> > I disagree, somewhat. No, you shouldn't count on the "ref count" per
> > se going to 0. And you shouldn't count on the file object being GC'd
> > _immediately_ after the last reference is destroyed. You should be able
> > to
Dan wrote:
> Is this discouraged?:
>
> for line in open(filename):
>
>
> That is, should I do this instead?:
>
> fileptr = open(filename)
> for line in fileptr:
>
> fileptr.close()
depends on the use case; in a small program that you know will only read
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> I disagree, somewhat. No, you shouldn't count on the "ref count" per
> se going to 0. And you shouldn't count on the file object being GC'd
> _immediately_ after the last reference is destroyed. You should be able
> to rely on it being GC'd at som
Paul Rubin wrote:
> Dan <[EMAIL PROTECTED]> writes:
> > Is this discouraged?:
> >
> > for line in open(filename):
> >
>
> Yes.
>
> > Can I count on the ref count going to zero to close the file?
>
> You really shouldn't. It's a CPython artifact.
I disagree, somewhat. No, you shoul
Paul Rubin wrote:
> Dan <[EMAIL PROTECTED]> writes:
>> Is this discouraged?:
>>
>> for line in open(filename):
>>
>
> Yes.
Well, not what I wanted to hear, but what I expected.
Thanks,
Dan
--
dedded att verizon dott net
--
http://mail.python.org/mailman/listinfo/python-list
Dan <[EMAIL PROTECTED]> writes:
> Is this discouraged?:
>
> for line in open(filename):
>
Yes.
> Can I count on the ref count going to zero to close the file?
You really shouldn't. It's a CPython artifact.
> I understand that the upcoming 'with' statement will obviate this
> qu
Is this discouraged?:
for line in open(filename):
That is, should I do this instead?:
fileptr = open(filename)
for line in fileptr:
fileptr.close()
Can I count on the ref count going to zero to close the file?
How about a write case? For example:
15 matches
Mail list logo