[Tutor] quick question to open(filename, 'r') vs. file(filename, 'r')

Bill Campbell bill at celestial.net
Mon May 4 23:49:27 CEST 2009


On Tue, May 05, 2009, David wrote:
>Dear list,
>
>in different books I come across different syntax for dealing with
>files. It seems that open(filename, 'r') and file(filename, 'r') are
>used interchangeably, and I wonder what this is all about. Is there a
>reason why Python allows such ambiguity here?
>
>Cheers for a quick shot of enlightenment ;-)

``pydoc file'' is your friend.  It says open is an alias for file.

Bill
-- 
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
Fax:            (206) 232-9186  Skype: jwccsllc (206) 855-5792

A petty thief is put in jail. A great brigand becomes ruler of a
State. -- Chuang Tzu


More information about the Tutor mailing list