confusion about opening files
robie at 1373.net
Tue Sep 24 05:17:21 CEST 2002
Cool! Thanks so much! I think I'm actually starting to get it!
"Erik Max Francis" <max at alcyone.com> wrote in message
news:3D8FD2F3.81F3831C at alcyone.com...
> robie1373 wrote:
> > O. K. Now I am confused. I thought that when I imported the os
> > module, i
> > would have to call its functions like this: os.open() Why am I just
> > using
> > the function name?
> Because there are two different open functions here. One is in the
> builtins, one is in the os module. They are not the same:
> >>> import os
> >>> print open.__doc__
> file(name[, mode[, buffering]]) -> file object
> Open a file. The mode can be 'r', 'w' or 'a' for reading (default),
> writing or appending. The file will be created if it doesn't exist
> when opened for writing or appending; it will be truncated when
> opened for writing. Add a 'b' to the mode for binary files.
> Add a '+' to the mode to allow simultaneous reading and writing.
> If the buffering argument is given, 0 means unbuffered, 1 means line
> buffered, and larger numbers specify the buffer size.
> Note: open() is an alias for file().
> >>> print os.open.__doc__
> open(filename, flag [, mode=0777]) -> fd
> Open a file (for low level IO).
> The os.open is a low-level API and is rarely going to be the one you
> Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
> __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> / \ Insight -- the titillating knack for hurting!
> \__/ Colette
> Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/
> A highly categorized list of Web links.
More information about the Python-list