[Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.155,1.156

Fred L. Drake fdrake@users.sourceforge.net
Tue, 04 Dec 2001 11:47:48 -0800


Update of /cvsroot/python/python/dist/src/Doc/tut
In directory usw-pr-cvs1:/tmp/cvs-serv10960/tut

Modified Files:
	tut.tex 
Log Message:
Include a warning that scripts should not have the same name as standard
modules, or the module cannot be properly imported.  (Based on a suggestion
sent to python-docs.)

Update the displayed dir() of the sys and __builtin__ module with Python 2.2.


Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.155
retrieving revision 1.156
diff -C2 -d -r1.155 -r1.156
*** tut.tex	2001/12/04 19:20:43	1.155
--- tut.tex	2001/12/04 19:47:46	1.156
***************
*** 2238,2243 ****
  \envvar{PYTHONPATH} and the installation-dependent default.  This allows
  Python programs that know what they're doing to modify or replace the 
! module search path.  See the section on Standard Modules later.
  
  \subsection{``Compiled'' Python files}
  
--- 2238,2249 ----
  \envvar{PYTHONPATH} and the installation-dependent default.  This allows
  Python programs that know what they're doing to modify or replace the 
! module search path.  Note that because the directory containing the
! script being run is on the search path, it is important that the
! script not have the same name as a standard module, or Python will
! attempt to load the script as a module when that module is imported.
! This will generally be an error.  See section~\ref{standardModules},
! ``Standard Modules.'' for more information.
  
+ 
  \subsection{``Compiled'' Python files}
  
***************
*** 2364,2370 ****
  ['__name__', 'fib', 'fib2']
  >>> dir(sys)
! ['__name__', 'argv', 'builtin_module_names', 'copyright', 'exit',
! 'maxint', 'modules', 'path', 'ps1', 'ps2', 'setprofile', 'settrace',
! 'stderr', 'stdin', 'stdout', 'version']
  \end{verbatim}
  
--- 2370,2382 ----
  ['__name__', 'fib', 'fib2']
  >>> dir(sys)
! ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__',
!  '__stdin__', '__stdout__', '_getframe', 'argv', 'builtin_module_names',
!  'byteorder', 'copyright', 'displayhook', 'exc_info', 'exc_type',
!  'excepthook', 'exec_prefix', 'executable', 'exit', 'getdefaultencoding',
!  'getdlopenflags', 'getrecursionlimit', 'getrefcount', 'hexversion',
!  'maxint', 'maxunicode', 'modules', 'path', 'platform', 'prefix', 'ps1',
!  'ps2', 'setcheckinterval', 'setdlopenflags', 'setprofile',
!  'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'version',
!  'version_info', 'warnoptions']
  \end{verbatim}
  
***************
*** 2389,2401 ****
  >>> import __builtin__
  >>> dir(__builtin__)
! ['AccessError', 'AttributeError', 'ConflictError', 'EOFError', 'IOError',
! 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
! 'MemoryError', 'NameError', 'None', 'OverflowError', 'RuntimeError',
! 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError', 'ValueError',
! 'ZeroDivisionError', '__name__', 'abs', 'apply', 'chr', 'cmp', 'coerce',
! 'compile', 'dir', 'divmod', 'eval', 'execfile', 'filter', 'float',
! 'getattr', 'hasattr', 'hash', 'hex', 'id', 'input', 'int', 'len', 'long',
! 'map', 'max', 'min', 'oct', 'open', 'ord', 'pow', 'range', 'raw_input',
! 'reduce', 'reload', 'repr', 'round', 'setattr', 'str', 'type', 'xrange']
  \end{verbatim}
  
--- 2401,2425 ----
  >>> import __builtin__
  >>> dir(__builtin__)
! ['ArithmeticError', 'AssertionError', 'AttributeError',
!  'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError',
!  'Exception', 'FloatingPointError', 'IOError', 'ImportError',
!  'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt',
!  'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented',
!  'NotImplementedError', 'OSError', 'OverflowError', 'OverflowWarning',
!  'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError',
!  'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
!  'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError',
!  'UnicodeError', 'UserWarning', 'ValueError', 'Warning',
!  'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
!  '__name__', 'abs', 'apply', 'buffer', 'callable', 'chr', 'classmethod',
!  'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr',
!  'dict', 'dir', 'divmod', 'eval', 'execfile', 'exit', 'file', 'filter',
!  'float', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id',
!  'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len',
!  'license', 'list', 'locals', 'long', 'map', 'max', 'min', 'object',
!  'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range', 'raw_input',
!  'reduce', 'reload', 'repr', 'round', 'setattr', 'slice', 'staticmethod',
!  'str', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange',
!  'zip']
  \end{verbatim}