confusion about opening files
Mark McEahern
marklists at mceahern.com
Mon Sep 23 23:02:38 EDT 2002
> 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?
You are assuming open == os.open. Not so. Watch...
***
$ python
Python 2.2.1 (#1, Jun 25 2002, 10:55:46)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 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().
>>> import os
>>> print os.open.__doc__
open(filename, flag [, mode=0777]) -> fd
Open a file (for low level IO).
>>> open == os.open
0
***
Cheers,
// m
-
More information about the Python-list
mailing list