Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
52e85508
Commit
52e85508
authored
Nov 17, 2012
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update section about dir() in the tutorial.
parent
89b03b0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
33 deletions
+41
-33
Doc/tutorial/modules.rst
Doc/tutorial/modules.rst
+41
-33
No files found.
Doc/tutorial/modules.rst
View file @
52e85508
...
...
@@ -288,16 +288,21 @@ defines. It returns a sorted list of strings::
>>> import fibo, sys
>>> dir(fibo)
['
__name__
', '
fib
', '
fib2
']
>>> dir(sys)
['
__displayhook__
', '
__doc__
', '
__excepthook__
', '
__name__
', '
__stderr__
',
'
__stdin__
', '
__stdout__
', '
_getframe
', '
api_version
', '
argv
',
'
builtin_module_names
', '
byteorder
', '
callstats
', '
copyright
',
'
displayhook
', '
exc_info
', '
excepthook
',
'
exec_prefix
', '
executable
', '
exit
', '
getdefaultencoding
', '
getdlopenflags
',
'
getrecursionlimit
', '
getrefcount
', '
hexversion
', '
maxint
', '
maxunicode
',
'
meta_path
', '
modules
', '
path
', '
path_hooks
', '
path_importer_cache
',
'
platform
', '
prefix
', '
ps1
', '
ps2
', '
setcheckinterval
', '
setdlopenflags
',
'
setprofile
', '
setrecursionlimit
', '
settrace
', '
stderr
', '
stdin
', '
stdout
',
>>> dir(sys) # doctest: +NORMALIZE_WHITESPACE
['
__displayhook__
', '
__doc__
', '
__excepthook__
', '
__name__
', '
__package__
',
'
__stderr__
', '
__stdin__
', '
__stdout__
', '
_clear_type_cache
',
'
_current_frames
', '
_getframe
', '
_mercurial
', '
_xoptions
', '
abiflags
',
'
api_version
', '
argv
', '
builtin_module_names
', '
byteorder
', '
call_tracing
',
'
callstats
', '
copyright
', '
displayhook
', '
dont_write_bytecode
', '
exc_info
',
'
excepthook
', '
exec_prefix
', '
executable
', '
exit
', '
flags
', '
float_info
',
'
float_repr_style
', '
getcheckinterval
', '
getdefaultencoding
',
'
getdlopenflags
', '
getfilesystemencoding
', '
getobjects
', '
getprofile
',
'
getrecursionlimit
', '
getrefcount
', '
getsizeof
', '
getswitchinterval
',
'
gettotalrefcount
', '
gettrace
', '
hash_info
', '
hexversion
', '
int_info
',
'
intern
', '
maxsize
', '
maxunicode
', '
meta_path
', '
modules
', '
path
',
'
path_hooks
', '
path_importer_cache
', '
platform
', '
prefix
', '
ps1
',
'
setcheckinterval
', '
setdlopenflags
', '
setprofile
', '
setrecursionlimit
',
'
setswitchinterval
', '
settrace
', '
stderr
', '
stdin
', '
stdout
', '
subversion
',
'
version
', '
version_info
', '
warnoptions
']
Without arguments, :func:`dir` lists the names you have defined currently::
...
...
@@ -306,7 +311,7 @@ Without arguments, :func:`dir` lists the names you have defined currently::
>>> import fibo
>>> fib = fibo.fib
>>> dir()
['
__builtins__
', '
__
doc__
', '
__file__
', '
__
name__
', '
a
', '
fib
', '
fibo
', '
sys
']
['
__builtins__
', '
__name__
', '
a
', '
fib
', '
fibo
', '
sys
']
Note that it lists all types of names: variables, modules, functions, etc.
...
...
@@ -317,28 +322,31 @@ want a list of those, they are defined in the standard module
:mod:`builtins`::
>>> import builtins
>>> dir(builtins)
['
ArithmeticError
', '
AssertionError
', '
AttributeError
', '
BaseException
', '
Buffer
Error
', '
BytesWarning
', '
DeprecationWarning
', '
EOFError
', '
Ellipsis
', '
Environme
ntError
', '
Exception
', '
False
', '
FloatingPointError
', '
FutureWarning
', '
Generato
rExit
', '
IOError
', '
ImportError
', '
ImportWarning
', '
IndentationError
', '
IndexErr
or
', '
KeyError
', '
KeyboardInterrupt
', '
LookupError
', '
MemoryError
', '
NameError
',
'
None
', '
NotImplemented
', '
NotImplementedError
', '
OSError
', '
OverflowError
', '
P
endingDeprecationWarning
', '
ReferenceError
', '
RuntimeError
', '
RuntimeWarning
', '
StopIteration
', '
SyntaxError
', '
SyntaxWarning
', '
SystemError
', '
SystemExit
', '
Ta
bError
', '
True
', '
TypeError
', '
UnboundLocalError
', '
UnicodeDecodeError
', '
Unicod
eEncodeError
', '
UnicodeError
', '
UnicodeTranslateError
', '
UnicodeWarning
', '
UserW
arning
', '
ValueError
', '
Warning
', '
ZeroDivisionError
', '
__build_class__
', '
__deb
ug__
', '
__doc__
', '
__import__
', '
__name__
', '
__package__
', '
abs
', '
all
', '
any
',
'
ascii
', '
bin
', '
bool
', '
bytearray
', '
bytes
', '
chr
', '
classmethod
', '
compile
', '
complex
', '
copyright
', '
credits
', '
delattr
', '
dict
', '
dir
', '
divmod
', '
enumerate
', '
eval
', '
exec
', '
exit
', '
filter
', '
float
', '
format
', '
frozenset
', '
getattr
',
'
globals
', '
hasattr
', '
hash
', '
help
', '
hex
', '
id
', '
input
', '
int
', '
isinstance
',
'
issubclass
', '
iter
', '
len
', '
license
', '
list
', '
locals
', '
map
', '
max
', '
memory
view
', '
min
', '
next
', '
object
', '
oct
', '
open
', '
ord
', '
pow
', '
print
', '
property
'
, '
quit
', '
range
', '
repr
', '
reversed
', '
round
', '
set
', '
setattr
', '
slice
', '
sort
ed
', '
staticmethod
', '
str
', '
sum
', '
super
', '
tuple
', '
type
', '
vars
', '
zip
']
>>> dir(builtins) # doctest: +NORMALIZE_WHITESPACE
['
ArithmeticError
', '
AssertionError
', '
AttributeError
', '
BaseException
',
'
BufferError
', '
BytesWarning
', '
DeprecationWarning
', '
EOFError
',
'
Ellipsis
', '
EnvironmentError
', '
Exception
', '
False
', '
FloatingPointError
',
'
FutureWarning
', '
GeneratorExit
', '
IOError
', '
ImportError
',
'
ImportWarning
', '
IndentationError
', '
IndexError
', '
KeyError
',
'
KeyboardInterrupt
', '
LookupError
', '
MemoryError
', '
NameError
', '
None
',
'
NotImplemented
', '
NotImplementedError
', '
OSError
', '
OverflowError
',
'
PendingDeprecationWarning
', '
ReferenceError
', '
ResourceWarning
',
'
RuntimeError
', '
RuntimeWarning
', '
StopIteration
', '
SyntaxError
',
'
SyntaxWarning
', '
SystemError
', '
SystemExit
', '
TabError
', '
True
',
'
TypeError
', '
UnboundLocalError
', '
UnicodeDecodeError
',
'
UnicodeEncodeError
', '
UnicodeError
', '
UnicodeTranslateError
',
'
UnicodeWarning
', '
UserWarning
', '
ValueError
', '
Warning
',
'
ZeroDivisionError
', '
_
', '
__build_class__
', '
__debug__
', '
__doc__
',
'
__import__
', '
__name__
', '
__package__
', '
abs
', '
all
', '
any
', '
ascii
',
'
bin
', '
bool
', '
bytearray
', '
bytes
', '
callable
', '
chr
', '
classmethod
',
'
compile
', '
complex
', '
copyright
', '
credits
', '
delattr
', '
dict
', '
dir
',
'
divmod
', '
enumerate
', '
eval
', '
exec
', '
exit
', '
filter
', '
float
', '
format
',
'
frozenset
', '
getattr
', '
globals
', '
hasattr
', '
hash
', '
help
', '
hex
', '
id
',
'
input
', '
int
', '
isinstance
', '
issubclass
', '
iter
', '
len
', '
license
',
'
list
', '
locals
', '
map
', '
max
', '
memoryview
', '
min
', '
next
', '
object
',
'
oct
', '
open
', '
ord
', '
pow
', '
print
', '
property
', '
quit
', '
range
', '
repr
',
'
reversed
', '
round
', '
set
', '
setattr
', '
slice
', '
sorted
', '
staticmethod
',
'
str
', '
sum
', '
super
', '
tuple
', '
type
', '
vars
', '
zip
']
.. _tut-packages:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment