René's URL Explorer Experiment
go
Title:
Programming FAQ — Python 2.7.18 documentation
direct link
Domain:
docs.python.org
Links
:
no longer supported
https://devguide.python.org/devcycle/#end-of-life-branches
Python documentation for the current stable release
https://docs.python.org/3/faq/programming.html
index
https://docs.python.org/2/genindex.html
modules
https://docs.python.org/2/py-modindex.html
next
https://docs.python.org/2/faq/design.html
previous
https://docs.python.org/2/faq/general.html
Python
https://www.python.org/
Python 2.7.18 documentation
https://docs.python.org/2/index.html
Python Frequently Asked Questions
https://docs.python.org/2/faq/index.html
Programming FAQ
https://docs.python.org/2/faq/programming.html#id1
¶
https://docs.python.org/2/faq/programming.html#programming-faq
Programming FAQ
https://docs.python.org/2/faq/programming.html#programming-faq
General Questions
https://docs.python.org/2/faq/programming.html#general-questions
Is there a source code level debugger with breakpoints, single-stepping, etc.?
https://docs.python.org/2/faq/programming.html#is-there-a-source-code-level-debugger-with-breakpoints-single-stepping-etc
Is there a tool to help find bugs or perform static analysis?
https://docs.python.org/2/faq/programming.html#is-there-a-tool-to-help-find-bugs-or-perform-static-analysis
How can I create a stand-alone binary from a Python script?
https://docs.python.org/2/faq/programming.html#how-can-i-create-a-stand-alone-binary-from-a-python-script
Are there coding standards or a style guide for Python programs?
https://docs.python.org/2/faq/programming.html#are-there-coding-standards-or-a-style-guide-for-python-programs
My program is too slow. How do I speed it up?
https://docs.python.org/2/faq/programming.html#my-program-is-too-slow-how-do-i-speed-it-up
Core Language
https://docs.python.org/2/faq/programming.html#core-language
Why am I getting an UnboundLocalError when the variable has a value?
https://docs.python.org/2/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value
What are the rules for local and global variables in Python?
https://docs.python.org/2/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python
Why do lambdas defined in a loop with different values all return the same result?
https://docs.python.org/2/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result
How do I share global variables across modules?
https://docs.python.org/2/faq/programming.html#how-do-i-share-global-variables-across-modules
What are the “best practices” for using import in a module?
https://docs.python.org/2/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module
Why are default values shared between objects?
https://docs.python.org/2/faq/programming.html#why-are-default-values-shared-between-objects
How can I pass optional or keyword parameters from one function to another?
https://docs.python.org/2/faq/programming.html#how-can-i-pass-optional-or-keyword-parameters-from-one-function-to-another
What is the difference between arguments and parameters?
https://docs.python.org/2/faq/programming.html#what-is-the-difference-between-arguments-and-parameters
Why did changing list ‘y’ also change list ‘x’?
https://docs.python.org/2/faq/programming.html#why-did-changing-list-y-also-change-list-x
How do I write a function with output parameters (call by reference)?
https://docs.python.org/2/faq/programming.html#how-do-i-write-a-function-with-output-parameters-call-by-reference
How do you make a higher order function in Python?
https://docs.python.org/2/faq/programming.html#how-do-you-make-a-higher-order-function-in-python
How do I copy an object in Python?
https://docs.python.org/2/faq/programming.html#how-do-i-copy-an-object-in-python
How can I find the methods or attributes of an object?
https://docs.python.org/2/faq/programming.html#how-can-i-find-the-methods-or-attributes-of-an-object
How can my code discover the name of an object?
https://docs.python.org/2/faq/programming.html#how-can-my-code-discover-the-name-of-an-object
What’s up with the comma operator’s precedence?
https://docs.python.org/2/faq/programming.html#what-s-up-with-the-comma-operator-s-precedence
Is there an equivalent of C’s “?:” ternary operator?
https://docs.python.org/2/faq/programming.html#is-there-an-equivalent-of-c-s-ternary-operator
Is it possible to write obfuscated one-liners in Python?
https://docs.python.org/2/faq/programming.html#is-it-possible-to-write-obfuscated-one-liners-in-python
Numbers and strings
https://docs.python.org/2/faq/programming.html#numbers-and-strings
How do I specify hexadecimal and octal integers?
https://docs.python.org/2/faq/programming.html#how-do-i-specify-hexadecimal-and-octal-integers
Why does -22 // 10 return -3?
https://docs.python.org/2/faq/programming.html#why-does-22-10-return-3
How do I convert a string to a number?
https://docs.python.org/2/faq/programming.html#how-do-i-convert-a-string-to-a-number
How do I convert a number to a string?
https://docs.python.org/2/faq/programming.html#how-do-i-convert-a-number-to-a-string
How do I modify a string in place?
https://docs.python.org/2/faq/programming.html#how-do-i-modify-a-string-in-place
How do I use strings to call functions/methods?
https://docs.python.org/2/faq/programming.html#how-do-i-use-strings-to-call-functions-methods
Is there an equivalent to Perl’s chomp() for removing trailing newlines from strings?
https://docs.python.org/2/faq/programming.html#is-there-an-equivalent-to-perl-s-chomp-for-removing-trailing-newlines-from-strings
Is there a scanf() or sscanf() equivalent?
https://docs.python.org/2/faq/programming.html#is-there-a-scanf-or-sscanf-equivalent
What does ‘UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)’ mean?
https://docs.python.org/2/faq/programming.html#what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean
Sequences (Tuples/Lists)
https://docs.python.org/2/faq/programming.html#sequences-tuples-lists
How do I convert between tuples and lists?
https://docs.python.org/2/faq/programming.html#how-do-i-convert-between-tuples-and-lists
What’s a negative index?
https://docs.python.org/2/faq/programming.html#what-s-a-negative-index
How do I iterate over a sequence in reverse order?
https://docs.python.org/2/faq/programming.html#how-do-i-iterate-over-a-sequence-in-reverse-order
How do you remove duplicates from a list?
https://docs.python.org/2/faq/programming.html#how-do-you-remove-duplicates-from-a-list
How do you make an array in Python?
https://docs.python.org/2/faq/programming.html#how-do-you-make-an-array-in-python
How do I create a multidimensional list?
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list
How do I apply a method to a sequence of objects?
https://docs.python.org/2/faq/programming.html#how-do-i-apply-a-method-to-a-sequence-of-objects
Why does a_tuple[i] += [‘item’] raise an exception when the addition works?
https://docs.python.org/2/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works
Dictionaries
https://docs.python.org/2/faq/programming.html#dictionaries
How can I get a dictionary to display its keys in a consistent order?
https://docs.python.org/2/faq/programming.html#how-can-i-get-a-dictionary-to-display-its-keys-in-a-consistent-order
I want to do a complicated sort: can you do a Schwartzian Transform in Python?
https://docs.python.org/2/faq/programming.html#i-want-to-do-a-complicated-sort-can-you-do-a-schwartzian-transform-in-python
How can I sort one list by values from another list?
https://docs.python.org/2/faq/programming.html#how-can-i-sort-one-list-by-values-from-another-list
Objects
https://docs.python.org/2/faq/programming.html#objects
What is a class?
https://docs.python.org/2/faq/programming.html#what-is-a-class
What is a method?
https://docs.python.org/2/faq/programming.html#what-is-a-method
What is self?
https://docs.python.org/2/faq/programming.html#what-is-self
How do I check if an object is an instance of a given class or of a subclass of it?
https://docs.python.org/2/faq/programming.html#how-do-i-check-if-an-object-is-an-instance-of-a-given-class-or-of-a-subclass-of-it
What is delegation?
https://docs.python.org/2/faq/programming.html#what-is-delegation
How do I call a method defined in a base class from a derived class that overrides it?
https://docs.python.org/2/faq/programming.html#how-do-i-call-a-method-defined-in-a-base-class-from-a-derived-class-that-overrides-it
How can I organize my code to make it easier to change the base class?
https://docs.python.org/2/faq/programming.html#how-can-i-organize-my-code-to-make-it-easier-to-change-the-base-class
How do I create static class data and static class methods?
https://docs.python.org/2/faq/programming.html#how-do-i-create-static-class-data-and-static-class-methods
How can I overload constructors (or methods) in Python?
https://docs.python.org/2/faq/programming.html#how-can-i-overload-constructors-or-methods-in-python
I try to use __spam and I get an error about _SomeClassName__spam.
https://docs.python.org/2/faq/programming.html#i-try-to-use-spam-and-i-get-an-error-about-someclassname-spam
My class defines __del__ but it is not called when I delete the object.
https://docs.python.org/2/faq/programming.html#my-class-defines-del-but-it-is-not-called-when-i-delete-the-object
How do I get a list of all instances of a given class?
https://docs.python.org/2/faq/programming.html#how-do-i-get-a-list-of-all-instances-of-a-given-class
Why does the result of id() appear to be not unique?
https://docs.python.org/2/faq/programming.html#why-does-the-result-of-id-appear-to-be-not-unique
Modules
https://docs.python.org/2/faq/programming.html#modules
How do I create a .pyc file?
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-pyc-file
How do I find the current module name?
https://docs.python.org/2/faq/programming.html#how-do-i-find-the-current-module-name
How can I have modules that mutually import each other?
https://docs.python.org/2/faq/programming.html#how-can-i-have-modules-that-mutually-import-each-other
__import__(‘x.y.z’) returns
; how do I get z?
https://docs.python.org/2/faq/programming.html#import-x-y-z-returns-module-x-how-do-i-get-z
When I edit an imported module and reimport it, the changes don’t show up. Why does this happen?
https://docs.python.org/2/faq/programming.html#when-i-edit-an-imported-module-and-reimport-it-the-changes-don-t-show-up-why-does-this-happen
General Questions
https://docs.python.org/2/faq/programming.html#id2
¶
https://docs.python.org/2/faq/programming.html#general-questions
Is there a source code level debugger with breakpoints, single-stepping, etc.?
https://docs.python.org/2/faq/programming.html#id3
¶
https://docs.python.org/2/faq/programming.html#is-there-a-source-code-level-debugger-with-breakpoints-single-stepping-etc
documented in the Library Reference Manual
https://docs.python.org/2/library/pdb.html#module-pdb
Python for Windows Extensions
https://sourceforge.net/projects/pywin32/
https://www.activestate.com/activepython
https://www.activestate.com/activepython
Boa Constructor
http://boa-constructor.sourceforge.net/
Eric
http://eric-ide.python-projects.org/
http://bashdb.sourceforge.net/pydb/
http://bashdb.sourceforge.net/pydb/
https://www.gnu.org/software/ddd
https://www.gnu.org/software/ddd
https://wingware.com/
https://wingware.com/
https://komodoide.com/
https://komodoide.com/
https://www.jetbrains.com/pycharm/
https://www.jetbrains.com/pycharm/
Is there a tool to help find bugs or perform static analysis?
https://docs.python.org/2/faq/programming.html#id4
¶
https://docs.python.org/2/faq/programming.html#is-there-a-tool-to-help-find-bugs-or-perform-static-analysis
http://pychecker.sourceforge.net/
http://pychecker.sourceforge.net/
Pylint
https://www.pylint.org/
https://docs.pylint.org/
https://docs.pylint.org/
How can I create a stand-alone binary from a Python script?
https://docs.python.org/2/faq/programming.html#id5
¶
https://docs.python.org/2/faq/programming.html#how-can-i-create-a-stand-alone-binary-from-a-python-script
http://www.py2exe.org/
http://www.py2exe.org/
cx_Freeze
http://cx-freeze.sourceforge.net/
Are there coding standards or a style guide for Python programs?
https://docs.python.org/2/faq/programming.html#id6
¶
https://docs.python.org/2/faq/programming.html#are-there-coding-standards-or-a-style-guide-for-python-programs
PEP 8
https://www.python.org/dev/peps/pep-0008
My program is too slow. How do I speed it up?
https://docs.python.org/2/faq/programming.html#id7
¶
https://docs.python.org/2/faq/programming.html#my-program-is-too-slow-how-do-i-speed-it-up
Pyrex
http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
Psyco
http://psyco.sourceforge.net
performance tips
https://wiki.python.org/moin/PythonSpeed/PerformanceTips
https://www.python.org/doc/essays/list2str
https://www.python.org/doc/essays/list2str
profile
https://docs.python.org/2/library/profile.html#module-profile
map()
https://docs.python.org/2/library/functions.html#map
zip()
https://docs.python.org/2/library/functions.html#zip
methods of string objects
https://docs.python.org/2/library/stdtypes.html#string-methods
methods on string objects
https://docs.python.org/2/library/stdtypes.html#string-methods
the old % operations
https://docs.python.org/2/library/stdtypes.html#string-formatting
sorting mini-HOWTO
https://wiki.python.org/moin/HowTo/Sorting
Core Language
https://docs.python.org/2/faq/programming.html#id8
¶
https://docs.python.org/2/faq/programming.html#core-language
Why am I getting an UnboundLocalError when the variable has a value?
https://docs.python.org/2/faq/programming.html#id9
¶
https://docs.python.org/2/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value
What are the rules for local and global variables in Python?
https://docs.python.org/2/faq/programming.html#id10
¶
https://docs.python.org/2/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python
global
https://docs.python.org/2/reference/simple_stmts.html#global
Why do lambdas defined in a loop with different values all return the same result?
https://docs.python.org/2/faq/programming.html#id11
¶
https://docs.python.org/2/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result
How do I share global variables across modules?
https://docs.python.org/2/faq/programming.html#id12
¶
https://docs.python.org/2/faq/programming.html#how-do-i-share-global-variables-across-modules
What are the “best practices” for using import in a module?
https://docs.python.org/2/faq/programming.html#id13
¶
https://docs.python.org/2/faq/programming.html#what-are-the-best-practices-for-using-import-in-a-module
sys.modules
https://docs.python.org/2/library/sys.html#sys.modules
Why are default values shared between objects?
https://docs.python.org/2/faq/programming.html#id14
¶
https://docs.python.org/2/faq/programming.html#why-are-default-values-shared-between-objects
How can I pass optional or keyword parameters from one function to another?
https://docs.python.org/2/faq/programming.html#id15
¶
https://docs.python.org/2/faq/programming.html#how-can-i-pass-optional-or-keyword-parameters-from-one-function-to-another
apply()
https://docs.python.org/2/library/functions.html#apply
What is the difference between arguments and parameters?
https://docs.python.org/2/faq/programming.html#id16
¶
https://docs.python.org/2/faq/programming.html#what-is-the-difference-between-arguments-and-parameters
Parameters
https://docs.python.org/2/glossary.html#term-parameter
arguments
https://docs.python.org/2/glossary.html#term-argument
Why did changing list ‘y’ also change list ‘x’?
https://docs.python.org/2/faq/programming.html#id17
¶
https://docs.python.org/2/faq/programming.html#why-did-changing-list-y-also-change-list-x
mutable
https://docs.python.org/2/glossary.html#term-mutable
immutable
https://docs.python.org/2/glossary.html#term-immutable
dict
https://docs.python.org/2/library/stdtypes.html#dict
set
https://docs.python.org/2/library/stdtypes.html#set
str
https://docs.python.org/2/library/functions.html#str
int
https://docs.python.org/2/library/functions.html#int
tuple
https://docs.python.org/2/library/functions.html#tuple
is
https://docs.python.org/2/reference/expressions.html#is
id()
https://docs.python.org/2/library/functions.html#id
How do I write a function with output parameters (call by reference)?
https://docs.python.org/2/faq/programming.html#id18
¶
https://docs.python.org/2/faq/programming.html#how-do-i-write-a-function-with-output-parameters-call-by-reference
How do you make a higher order function in Python?
https://docs.python.org/2/faq/programming.html#id19
¶
https://docs.python.org/2/faq/programming.html#how-do-you-make-a-higher-order-function-in-python
How do I copy an object in Python?
https://docs.python.org/2/faq/programming.html#id20
¶
https://docs.python.org/2/faq/programming.html#how-do-i-copy-an-object-in-python
copy.copy()
https://docs.python.org/2/library/copy.html#copy.copy
copy.deepcopy()
https://docs.python.org/2/library/copy.html#copy.deepcopy
copy()
https://docs.python.org/2/library/stdtypes.html#dict.copy
How can I find the methods or attributes of an object?
https://docs.python.org/2/faq/programming.html#id21
¶
https://docs.python.org/2/faq/programming.html#how-can-i-find-the-methods-or-attributes-of-an-object
How can my code discover the name of an object?
https://docs.python.org/2/faq/programming.html#id22
¶
https://docs.python.org/2/faq/programming.html#how-can-my-code-discover-the-name-of-an-object
What’s up with the comma operator’s precedence?
https://docs.python.org/2/faq/programming.html#id23
¶
https://docs.python.org/2/faq/programming.html#what-s-up-with-the-comma-operator-s-precedence
Is there an equivalent of C’s “?:” ternary operator?
https://docs.python.org/2/faq/programming.html#id24
¶
https://docs.python.org/2/faq/programming.html#is-there-an-equivalent-of-c-s-ternary-operator
Is it possible to write obfuscated one-liners in Python?
https://docs.python.org/2/faq/programming.html#id25
¶
https://docs.python.org/2/faq/programming.html#is-it-possible-to-write-obfuscated-one-liners-in-python
lambda
https://docs.python.org/2/reference/expressions.html#lambda
lambda
https://docs.python.org/2/reference/expressions.html#lambda
Numbers and strings
https://docs.python.org/2/faq/programming.html#id26
¶
https://docs.python.org/2/faq/programming.html#numbers-and-strings
How do I specify hexadecimal and octal integers?
https://docs.python.org/2/faq/programming.html#id27
¶
https://docs.python.org/2/faq/programming.html#how-do-i-specify-hexadecimal-and-octal-integers
Why does -22 // 10 return -3?
https://docs.python.org/2/faq/programming.html#id28
¶
https://docs.python.org/2/faq/programming.html#why-does-22-10-return-3
How do I convert a string to a number?
https://docs.python.org/2/faq/programming.html#id29
¶
https://docs.python.org/2/faq/programming.html#how-do-i-convert-a-string-to-a-number
int()
https://docs.python.org/2/library/functions.html#int
float()
https://docs.python.org/2/library/functions.html#float
ValueError
https://docs.python.org/2/library/exceptions.html#exceptions.ValueError
eval()
https://docs.python.org/2/library/functions.html#eval
eval()
https://docs.python.org/2/library/functions.html#eval
eval()
https://docs.python.org/2/library/functions.html#eval
How do I convert a number to a string?
https://docs.python.org/2/faq/programming.html#id30
¶
https://docs.python.org/2/faq/programming.html#how-do-i-convert-a-number-to-a-string
str()
https://docs.python.org/2/library/functions.html#str
hex()
https://docs.python.org/2/library/functions.html#hex
oct()
https://docs.python.org/2/library/functions.html#oct
Format String Syntax
https://docs.python.org/2/library/string.html#formatstrings
PEP 238
https://www.python.org/dev/peps/pep-0238
__future__
https://docs.python.org/2/library/__future__.html#module-__future__
the % operator
https://docs.python.org/2/library/stdtypes.html#string-formatting
How do I modify a string in place?
https://docs.python.org/2/faq/programming.html#id31
¶
https://docs.python.org/2/faq/programming.html#how-do-i-modify-a-string-in-place
How do I use strings to call functions/methods?
https://docs.python.org/2/faq/programming.html#id32
¶
https://docs.python.org/2/faq/programming.html#how-do-i-use-strings-to-call-functions-methods
getattr()
https://docs.python.org/2/library/functions.html#getattr
getattr()
https://docs.python.org/2/library/functions.html#getattr
locals()
https://docs.python.org/2/library/functions.html#locals
eval()
https://docs.python.org/2/library/functions.html#eval
eval()
https://docs.python.org/2/library/functions.html#eval
Is there an equivalent to Perl’s chomp() for removing trailing newlines from strings?
https://docs.python.org/2/faq/programming.html#id33
¶
https://docs.python.org/2/faq/programming.html#is-there-an-equivalent-to-perl-s-chomp-for-removing-trailing-newlines-from-strings
Is there a scanf() or sscanf() equivalent?
https://docs.python.org/2/faq/programming.html#id34
¶
https://docs.python.org/2/faq/programming.html#is-there-a-scanf-or-sscanf-equivalent
split()
https://docs.python.org/2/library/stdtypes.html#str.split
int()
https://docs.python.org/2/library/functions.html#int
float()
https://docs.python.org/2/library/functions.html#float
What does ‘UnicodeError: ASCII [decoding,encoding] error: ordinal not in range(128)’ mean?
https://docs.python.org/2/faq/programming.html#id35
¶
https://docs.python.org/2/faq/programming.html#what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean
UnicodeError
https://docs.python.org/2/library/exceptions.html#exceptions.UnicodeError
Sequences (Tuples/Lists)
https://docs.python.org/2/faq/programming.html#id36
¶
https://docs.python.org/2/faq/programming.html#sequences-tuples-lists
How do I convert between tuples and lists?
https://docs.python.org/2/faq/programming.html#id37
¶
https://docs.python.org/2/faq/programming.html#how-do-i-convert-between-tuples-and-lists
tuple()
https://docs.python.org/2/library/functions.html#tuple
What’s a negative index?
https://docs.python.org/2/faq/programming.html#id38
¶
https://docs.python.org/2/faq/programming.html#what-s-a-negative-index
How do I iterate over a sequence in reverse order?
https://docs.python.org/2/faq/programming.html#id39
¶
https://docs.python.org/2/faq/programming.html#how-do-i-iterate-over-a-sequence-in-reverse-order
reversed()
https://docs.python.org/2/library/functions.html#reversed
How do you remove duplicates from a list?
https://docs.python.org/2/faq/programming.html#id40
¶
https://docs.python.org/2/faq/programming.html#how-do-you-remove-duplicates-from-a-list
https://code.activestate.com/recipes/52560/
https://code.activestate.com/recipes/52560/
How do you make an array in Python?
https://docs.python.org/2/faq/programming.html#id41
¶
https://docs.python.org/2/faq/programming.html#how-do-you-make-an-array-in-python
How do I create a multidimensional list?
https://docs.python.org/2/faq/programming.html#id42
¶
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list
NumPy
http://www.numpy.org/
How do I apply a method to a sequence of objects?
https://docs.python.org/2/faq/programming.html#id43
¶
https://docs.python.org/2/faq/programming.html#how-do-i-apply-a-method-to-a-sequence-of-objects
Why does a_tuple[i] += [‘item’] raise an exception when the addition works?
https://docs.python.org/2/faq/programming.html#id44
¶
https://docs.python.org/2/faq/programming.html#why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works
Dictionaries
https://docs.python.org/2/faq/programming.html#id45
¶
https://docs.python.org/2/faq/programming.html#dictionaries
How can I get a dictionary to display its keys in a consistent order?
https://docs.python.org/2/faq/programming.html#id46
¶
https://docs.python.org/2/faq/programming.html#how-can-i-get-a-dictionary-to-display-its-keys-in-a-consistent-order
I want to do a complicated sort: can you do a Schwartzian Transform in Python?
https://docs.python.org/2/faq/programming.html#id47
¶
https://docs.python.org/2/faq/programming.html#i-want-to-do-a-complicated-sort-can-you-do-a-schwartzian-transform-in-python
How can I sort one list by values from another list?
https://docs.python.org/2/faq/programming.html#id48
¶
https://docs.python.org/2/faq/programming.html#how-can-i-sort-one-list-by-values-from-another-list
Objects
https://docs.python.org/2/faq/programming.html#id49
¶
https://docs.python.org/2/faq/programming.html#objects
What is a class?
https://docs.python.org/2/faq/programming.html#id50
¶
https://docs.python.org/2/faq/programming.html#what-is-a-class
What is a method?
https://docs.python.org/2/faq/programming.html#id51
¶
https://docs.python.org/2/faq/programming.html#what-is-a-method
What is self?
https://docs.python.org/2/faq/programming.html#id52
¶
https://docs.python.org/2/faq/programming.html#what-is-self
Why must ‘self’ be used explicitly in method definitions and calls?
https://docs.python.org/2/faq/design.html#why-self
How do I check if an object is an instance of a given class or of a subclass of it?
https://docs.python.org/2/faq/programming.html#id53
¶
https://docs.python.org/2/faq/programming.html#how-do-i-check-if-an-object-is-an-instance-of-a-given-class-or-of-a-subclass-of-it
isinstance()
https://docs.python.org/2/library/functions.html#isinstance
What is delegation?
https://docs.python.org/2/faq/programming.html#id54
¶
https://docs.python.org/2/faq/programming.html#what-is-delegation
the language reference
https://docs.python.org/2/reference/datamodel.html#attribute-access
__setattr__()
https://docs.python.org/2/reference/datamodel.html#object.__setattr__
__setattr__()
https://docs.python.org/2/reference/datamodel.html#object.__setattr__
__setattr__()
https://docs.python.org/2/reference/datamodel.html#object.__setattr__
How do I call a method defined in a base class from a derived class that overrides it?
https://docs.python.org/2/faq/programming.html#id55
¶
https://docs.python.org/2/faq/programming.html#how-do-i-call-a-method-defined-in-a-base-class-from-a-derived-class-that-overrides-it
super()
https://docs.python.org/2/library/functions.html#super
How can I organize my code to make it easier to change the base class?
https://docs.python.org/2/faq/programming.html#id56
¶
https://docs.python.org/2/faq/programming.html#how-can-i-organize-my-code-to-make-it-easier-to-change-the-base-class
How do I create static class data and static class methods?
https://docs.python.org/2/faq/programming.html#id57
¶
https://docs.python.org/2/faq/programming.html#how-do-i-create-static-class-data-and-static-class-methods
How can I overload constructors (or methods) in Python?
https://docs.python.org/2/faq/programming.html#id58
¶
https://docs.python.org/2/faq/programming.html#how-can-i-overload-constructors-or-methods-in-python
I try to use __spam and I get an error about _SomeClassName__spam.
https://docs.python.org/2/faq/programming.html#id59
¶
https://docs.python.org/2/faq/programming.html#i-try-to-use-spam-and-i-get-an-error-about-someclassname-spam
My class defines __del__ but it is not called when I delete the object.
https://docs.python.org/2/faq/programming.html#id60
¶
https://docs.python.org/2/faq/programming.html#my-class-defines-del-but-it-is-not-called-when-i-delete-the-object
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
gc.collect()
https://docs.python.org/2/library/gc.html#gc.collect
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
weakref
https://docs.python.org/2/library/weakref.html#module-weakref
sys.exc_clear()
https://docs.python.org/2/library/sys.html#sys.exc_clear
__del__()
https://docs.python.org/2/reference/datamodel.html#object.__del__
sys.stderr
https://docs.python.org/2/library/sys.html#sys.stderr
How do I get a list of all instances of a given class?
https://docs.python.org/2/faq/programming.html#id61
¶
https://docs.python.org/2/faq/programming.html#how-do-i-get-a-list-of-all-instances-of-a-given-class
Why does the result of id() appear to be not unique?
https://docs.python.org/2/faq/programming.html#id62
¶
https://docs.python.org/2/faq/programming.html#why-does-the-result-of-id-appear-to-be-not-unique
id()
https://docs.python.org/2/library/functions.html#id
Modules
https://docs.python.org/2/faq/programming.html#id63
¶
https://docs.python.org/2/faq/programming.html#modules
How do I create a .pyc file?
https://docs.python.org/2/faq/programming.html#id64
¶
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-pyc-file
py_compile
https://docs.python.org/2/library/py_compile.html#module-py_compile
compileall
https://docs.python.org/2/library/compileall.html#module-compileall
py_compile
https://docs.python.org/2/library/py_compile.html#module-py_compile
compileall
https://docs.python.org/2/library/compileall.html#module-compileall
How do I find the current module name?
https://docs.python.org/2/faq/programming.html#id65
¶
https://docs.python.org/2/faq/programming.html#how-do-i-find-the-current-module-name
How can I have modules that mutually import each other?
https://docs.python.org/2/faq/programming.html#id66
¶
https://docs.python.org/2/faq/programming.html#how-can-i-have-modules-that-mutually-import-each-other
__import__(‘x.y.z’) returns
; how do I get z?
https://docs.python.org/2/faq/programming.html#id67
¶
https://docs.python.org/2/faq/programming.html#import-x-y-z-returns-module-x-how-do-i-get-z
import_module()
https://docs.python.org/2/library/importlib.html#importlib.import_module
importlib
https://docs.python.org/2/library/importlib.html#module-importlib
When I edit an imported module and reimport it, the changes don’t show up. Why does this happen?
https://docs.python.org/2/faq/programming.html#id68
¶
https://docs.python.org/2/faq/programming.html#when-i-edit-an-imported-module-and-reimport-it-the-changes-don-t-show-up-why-does-this-happen
Table of Contents
https://docs.python.org/2/contents.html
Programming FAQ
https://docs.python.org/2/faq/programming.html
General Questions
https://docs.python.org/2/faq/programming.html#general-questions
Core Language
https://docs.python.org/2/faq/programming.html#core-language
Numbers and strings
https://docs.python.org/2/faq/programming.html#numbers-and-strings
Sequences (Tuples/Lists)
https://docs.python.org/2/faq/programming.html#sequences-tuples-lists
Dictionaries
https://docs.python.org/2/faq/programming.html#dictionaries
Objects
https://docs.python.org/2/faq/programming.html#objects
Modules
https://docs.python.org/2/faq/programming.html#modules
General Python FAQ
https://docs.python.org/2/faq/general.html
Design and History FAQ
https://docs.python.org/2/faq/design.html
Show Source
https://docs.python.org/2/_sources/faq/programming.rst.txt
index
https://docs.python.org/2/genindex.html
modules
https://docs.python.org/2/py-modindex.html
next
https://docs.python.org/2/faq/design.html
previous
https://docs.python.org/2/faq/general.html
Python
https://www.python.org/
Python 2.7.18 documentation
https://docs.python.org/2/index.html
Python Frequently Asked Questions
https://docs.python.org/2/faq/index.html
Copyright
https://docs.python.org/2/copyright.html
Please donate.
https://www.python.org/psf/donations/
Found a bug
https://docs.python.org/2/bugs.html
Sphinx
http://sphinx.pocoo.org/
URLs of
crawlers that visited me
.