Newbie: opening files.

Doug Stanfield DOUGS at
Fri May 19 16:44:54 EDT 2000

[First Bart Holthuijsen wrote:]
> > from sys import *
> > from os import *

[Then Moshe Zadka replied:]
>                  ^^^^
> Here's the culprit. The "os" module defines an "open" function. Don't
> import "*". Ever.

Unless you are at an interactive prompt, still the best way to explore
module capabilities.  Can that be enforced somehow by the interpreter?:

[dougs at lawehana dougs]$ python
Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201
  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from os import *
>>> dir()
'O_RDONLY', 'O_RDWR', 'O_SYNC', 'O_TRUNC', 'O_WRONLY', 'R_OK', 'UserDict',
MSIG', 'W_OK', 'X_OK', '__builtins__', '__doc__', '__name__', 'access',
, 'chdir', 'chmod', 'chown', 'close', 'curdir', 'defpath', 'dup', 'dup2',
on', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve',
', 'execvpe', 'fdatasync', 'fdopen', 'fork', 'fstat', 'fsync', 'ftruncate',
cwd', 'getegid', 'geteuid', 'getgid', 'getpgrp', 'getpid', 'getppid',
'kill', 'linesep', 'link', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir',
fifo', 'name', 'nice', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen',
tenv', 'read', 'readlink', 'remove', 'removedirs', 'rename', 'renames',
 'sep', 'setgid', 'setpgid', 'setpgrp', 'setsid', 'setuid', 'stat',
'symlink', 'sys', 'system', 'tcgetpgrp', 'tcsetpgrp', 'times', 'ttyname',
', 'uname', 'unlink', 'utime', 'wait', 'waitpid', 'write']


More information about the Python-list mailing list