how to count lines in a file ?
Alex Martelli
aleax at aleax.it
Thu Jul 25 10:09:44 EDT 2002
Bo M. Maryniuck wrote:
...
> Therefore code:
> ----------8<------------
>>>> a = open('file')
>>>> a.close()
>>>> del a
> ----------8<------------
>
> ...and just...
> ----------8<------------
>>>> open('file')
> <open file 'file', mode 'r' at 0x81926f8>
> ----------8<------------
>
> ..."make" different garbage in the memory and second one provides more
> "crap"?
I would DEFINITELY hope so -- else how could this work...?
>>> open('/etc/motd')
<open file '/etc/motd', mode 'r' at 0x8166448>
>>> print _.read(),
Welcome to FOOBAR INC!
>>> _.close()
Don't forget that the interactive interpreter keeps your
latest non-None expression statement's result as an attribute
of the builtins module with a name of '_'. If you do forget
it, understanding what's garbage, what not, gets tricky:-).
Alex
More information about the Python-list
mailing list