Newbie: opening files.

Doug Stanfield DOUGS at oceanic.com
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
(egcs-1.1.1
  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from os import *
>>> dir()
['F_OK', 'O_APPEND', 'O_CREAT', 'O_EXCL', 'O_NDELAY', 'O_NOCTTY',
'O_NONBLOCK',
'O_RDONLY', 'O_RDWR', 'O_SYNC', 'O_TRUNC', 'O_WRONLY', 'R_OK', 'UserDict',
'WEXI
TSTATUS', 'WIFEXITED', 'WIFSIGNALED', 'WIFSTOPPED', 'WNOHANG', 'WSTOPSIG',
'WTER
MSIG', 'W_OK', 'X_OK', '__builtins__', '__doc__', '__name__', 'access',
'altsep'
, 'chdir', 'chmod', 'chown', 'close', 'curdir', 'defpath', 'dup', 'dup2',
'envir
on', 'error', 'execl', 'execle', 'execlp', 'execlpe', 'execv', 'execve',
'execvp
', 'execvpe', 'fdatasync', 'fdopen', 'fork', 'fstat', 'fsync', 'ftruncate',
'get
cwd', 'getegid', 'geteuid', 'getgid', 'getpgrp', 'getpid', 'getppid',
'getuid',
'kill', 'linesep', 'link', 'listdir', 'lseek', 'lstat', 'makedirs', 'mkdir',
'mk
fifo', 'name', 'nice', 'open', 'pardir', 'path', 'pathsep', 'pipe', 'popen',
'pu
tenv', 'read', 'readlink', 'remove', 'removedirs', 'rename', 'renames',
'rmdir',
 'sep', 'setgid', 'setpgid', 'setpgrp', 'setsid', 'setuid', 'stat',
'strerror',
'symlink', 'sys', 'system', 'tcgetpgrp', 'tcsetpgrp', 'times', 'ttyname',
'umask
', 'uname', 'unlink', 'utime', 'wait', 'waitpid', 'write']
>>>

-Doug-




More information about the Python-list mailing list