reading files

Jorge Godoy godoy at ieee.org
Mon Dec 19 05:35:20 EST 2005


"Johhny" <exter_c at hotmail.com> writes:

> ===SNIP===
> import string

Why's that here?  You don't need that import...

> vsftpd=open('vsftpd.conf', 'r')

Open the file and associate its resulting *object* to the 'vsftpd' variable. 

> print vsftpd

Print the object's __str__.

> vsftpd.read()

Read the full file into the string at the LHS (left side of the '=').  In your
case, it reads the full file and discard its contents.

> vsftpd.readlines()

Read all other lines (none) into an array on the LHS.

> vsftpd.close()

Close the file.

> When I run the script I get the following:
> 
> python reading_file.py
> <open file 'vsftpd.conf', mode 'r' at 0xb7d742a8>
> 
> Does anyone have any advice on this issue at all. 

What issue?  You did nothing with what you read, just with the object itself. 


-- 
Jorge Godoy      <godoy at ieee.org>



More information about the Python-list mailing list