(A Semi-Official) Python FAQ Zone
This effbot zone, a sister site to the Python Tutorial Wiki, contains a copy of the standard Python FAQ. This site replaces the version hosted at infogami. This site is being used as an editing and staging area; “stable” versions will be published over at python.org at regular intervals, once all the tools are in place.
Note: We’re rebuilding. Sorry for the mess.
To contribute, you can:
Review an article, and add comments and suggestions if you find something that can or should be improved.
Show me a random article!Suggest a new article.
It’s perfectly okay to just read an article, of course.
There’s also an RSS feed available, which lists recently modified articles.
Overviews (17)
- Category: cleanup [cleanup-index]
- Category: comments [comments-index]
- Category: cpython [cpython-index]
- Category: database [database-index]
- Category: design [design-index]
- Category: extending [extending-index]
- Category: garbage [garbage-index]
- Category: general [general-index]
- Category: gui [gui-index]
- Category: history [history-index]
- Category: installed [installed-index]
- Category: library [library-index]
- Category: old [old-index]
- Category: programming [programming-index]
- Category: tkinter [tkinter-index]
- Category: tutor [tutor-index]
- Category: windows [windows-index]
Articles (210)
A
- Are there any books on Python? [are-there-any-books-on-python]
- Are there any interfaces to database packages in Python? [are-there-any-interfaces-to-database-packages-in-python]
- Are there any published articles about Python that I can reference? [are-there-any-published-articles-about-python-that-i-can-reference]
- Are there coding standards or a style guide for Python programs? [are-there-coding-standards-or-a-style-guide-for-python-programs]
- Are there copyright restrictions on the use of Python? [are-there-copyright-restrictions-on-the-use-of-python]
- Are there other FTP sites that mirror the Python distribution? [are-there-other-ftp-sites-that-mirror-the-python-distribution]
C
- Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)? [can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance]
- Can I create my own functions in C? [can-i-create-my-own-functions-in-c]
- Can I create my own functions in C++? [can-i-create-my-own-functions-in-cplusplus]
- Can I have Tk events handled while waiting for I/O? [can-i-have-tk-events-handled-while-waiting-for-i-o]
- Can Python be compiled to machine code, C or some other language? [can-python-be-compiled-to-machine-code-c-or-some-other-language]
- Can't we get rid of the Global Interpreter Lock? [can-t-we-get-rid-of-the-global-interpreter-lock]
- Can't you emulate threads in the interpreter instead of relying on an OS-specific thread implementation? [can-t-you-emulate-threads-in-the-interpreter-instead-of-relying-on-an-os-specific-thread-implementation]
- cgi.py (or other CGI programming) doesn't work sometimes on NT or win95! [cgi-py-or-other-cgi-programming-doesn-t-work-sometimes-on-nt-or-win95]
D
- Do I have to like "Monty Python's Flying Circus"? [do-i-have-to-like-monty-python-s-flying-circus]
H
- Have any significant projects been done in Python? [have-any-significant-projects-been-done-in-python]
- How are dictionaries implemented? [how-are-dictionaries-implemented]
- How are lists implemented? [how-are-lists-implemented]
- How can I create a stand-alone binary from a Python script? [how-can-i-create-a-stand-alone-binary-from-a-python-script]
- How can I embed Python into a Windows application? [how-can-i-embed-python-into-a-windows-application]
- How can I evaluate an arbitrary Python expression from C? [how-can-i-evaluate-an-arbitrary-python-expression-from-c]
- How can I execute arbitrary Python statements from C? [how-can-i-execute-arbitrary-python-statements-from-c]
- How can I find the methods or attributes of an object? [how-can-i-find-the-methods-or-attributes-of-an-object]
- How can I get a dictionary to display its keys in a consistent order? [how-can-i-get-a-dictionary-to-display-its-keys-in-a-consistent-order]
- How can I have modules that mutually import each other? [how-can-i-have-modules-that-mutually-import-each-other]
- How can I mimic CGI form submission (METHOD=POST)? [how-can-i-mimic-cgi-form-submission-method-post]
- How can I organize my code to make it easier to change the base class? [how-can-i-organize-my-code-to-make-it-easier-to-change-the-base-class]
- How can I overload constructors (or methods) in Python? [how-can-i-overload-constructors-or-methods-in-python]
- How can I pass optional or keyword parameters from one function to another? [how-can-i-pass-optional-or-keyword-parameters-from-one-function-to-another]
- How can I sort one list by values from another list? [how-can-i-sort-one-list-by-values-from-another-list]
- How can my code discover the name of an object? [how-can-my-code-discover-the-name-of-an-object]
- How does Python manage memory? [how-does-python-manage-memory]
- How does the Python version numbering scheme work? [how-does-the-python-version-numbering-scheme-work]
- How do I access a module written in Python from C? [how-do-i-access-a-module-written-in-python-from-c]
- How do I access the serial (RS232) port? [how-do-i-access-the-serial-rs232-port]
- How do I apply a method to a sequence of objects? [how-do-i-apply-a-method-to-a-sequence-of-objects]
- How do I avoid blocking in the connect() method of a socket? [how-do-i-avoid-blocking-in-the-connect-method-of-a-socket]
- How do I call a method defined in a base class from a derived class that overrides it? [how-do-i-call-a-method-defined-in-a-base-class-from-a-derived-class-that-overrides-it]
- How do I call an object's method from C? [how-do-i-call-an-object-s-method-from-c]
- How do I catch the output from PyErr_Print() (or anything that prints to stdout/stderr)? [how-do-i-catch-the-output-from-pyerr-print-or-anything-that-prints-to-stdout-stderr]
- How do I check for a keypress without blocking? [how-do-i-check-for-a-keypress-without-blocking]
- How do I check if an object is an instance of a given class or of a subclass of it? [how-do-i-check-if-an-object-is-an-instance-of-a-given-class-or-of-a-subclass-of-it]
- How do I convert a number to a string? [how-do-i-convert-a-number-to-a-string]
- How do I convert a string to a number? [how-do-i-convert-a-string-to-a-number]
- How do I convert between tuples and lists? [how-do-i-convert-between-tuples-and-lists]
- How do I copy a file? [how-do-i-copy-a-file]
- How do I copy a file on Windows? [how-do-i-copy-a-file-on-windows]
- How do I copy an object in Python? [how-do-i-copy-an-object-in-python]
- How do I create a multidimensional list? [how-do-i-create-a-multidimensional-list]
- How do I create a .pyc file? [how-do-i-create-a-pyc-file]
- How do I create documentation from doc strings? [how-do-i-create-documentation-from-doc-strings]
- How do I create static class data and static class methods? [how-do-i-create-static-class-data-and-static-class-methods]
- How do I debug an extension? [how-do-i-debug-an-extension]
- How do I delete a file? (And other file questions...) [how-do-i-delete-a-file-and-other-file-questions]
- How do I emulate os.kill() in Windows? [how-do-i-emulate-os-kill-in-windows]
- How do I escape SQL values when using the DB-API? [how-do-i-escape-sql-values-when-using-the-db-api]
- How do I extract C values from a Python object? [how-do-i-extract-c-values-from-a-python-object]
- How do I extract the downloaded documentation on Windows? [how-do-i-extract-the-downloaded-documentation-on-windows]
- How do I find a module or application to perform task X? [how-do-i-find-a-module-or-application-to-perform-task-x]
- How do I find the current module name? [how-do-i-find-the-current-module-name]
- How do I find undefined g++ symbols __builtin_new or __pure_virtual? [how-do-i-find-undefined-g-symbols-builtin-new-or-pure-virtual]
- How do I freeze Tkinter applications? [how-do-i-freeze-tkinter-applications]
- How do I generate random numbers in Python? [how-do-i-generate-random-numbers-in-python]
- How do I get a beta test version of Python? [how-do-i-get-a-beta-test-version-of-python]
- How do I get a list of all instances of a given class? [how-do-i-get-a-list-of-all-instances-of-a-given-class]
- How do I get a single keypress at a time? [how-do-i-get-a-single-keypress-at-a-time]
- How do I get documentation on Python? [how-do-i-get-documentation-on-python]
- How do I interface to C++ objects from Python? [how-do-i-interface-to-c-objects-from-python]
- How do I iterate over a sequence in reverse order? [how-do-i-iterate-over-a-sequence-in-reverse-order]
- How do I keep editors from inserting tabs into my Python source? [how-do-i-keep-editors-from-inserting-tabs-into-my-python-source]
- How do I make a Python script executable on Unix? [how-do-i-make-a-python-script-executable-on-unix]
- How do I make python scripts executable? [how-do-i-make-python-scripts-executable]
- How do I modify a string in place? [how-do-i-modify-a-string-in-place]
- How do I obtain a copy of the Python source? [how-do-i-obtain-a-copy-of-the-python-source]
- How do I parcel out work among a bunch of worker threads? [how-do-i-parcel-out-work-among-a-bunch-of-worker-threads]
- How do I print to a Windows printer? [how-do-i-print-to-a-windows-printer]
- How do I program using threads? [how-do-i-program-using-threads]
- How do I read (or write) binary data? [how-do-i-read-or-write-binary-data]
- How do I run a Python program under Windows? [how-do-i-run-a-python-program-under-windows]
- How do I run a subprocess with pipes connected to both input and output? [how-do-i-run-a-subprocess-with-pipes-connected-to-both-input-and-output]
- How do I send mail from a Python script? [how-do-i-send-mail-from-a-python-script]
- How do I share global variables across modules? [how-do-i-share-global-variables-across-modules]
- How do I specify hexadecimal and octal integers? [how-do-i-specify-hexadecimal-and-octal-integers]
- How do I submit bug reports and patches for Python? [how-do-i-submit-bug-reports-and-patches-for-python]
- How do I tell "incomplete input" from "invalid input"? [how-do-i-tell-incomplete-input-from-invalid-input]
- How do I test a Python program or component? [how-do-i-test-a-python-program-or-component]
- How do I use Py_BuildValue() to create a tuple of arbitrary length? [how-do-i-use-py-buildvalue-to-create-a-tuple-of-arbitrary-length]
- How do I use Python for CGI? [how-do-i-use-python-for-cgi]
- How do I use strings to call functions/methods? [how-do-i-use-strings-to-call-functions-methods]
- How do I watch a directory for changes on Windows? [how-do-i-watch-a-directory-for-changes-on-windows]
- How do I write a function with output parameters (call by reference)? [how-do-i-write-a-function-with-output-parameters-call-by-reference]
- How do you implement persistent objects in Python? [how-do-you-implement-persistent-objects-in-python]
- How do you make a higher order function in Python? [how-do-you-make-a-higher-order-function-in-python]
- How do you make an array in Python? [how-do-you-make-an-array-in-python]
- How do you remove duplicates from a list? [how-do-you-remove-duplicates-from-a-list]
- How do you set a global variable in a function? [how-do-you-set-a-global-variable-in-a-function]
- How do you specify and enforce an interface spec in Python? [how-do-you-specify-and-enforce-an-interface-spec-in-python]
- How fast are exceptions? [how-fast-are-exceptions]
- How many people are using Python? [how-many-people-are-using-python]
- How stable is Python? [how-stable-is-python]
I
- I added a module using the Setup file and the make fails; why? [i-added-a-module-using-the-setup-file-and-the-make-fails-why]
- I can't get key bindings to work in Tkinter: why? [i-can-t-get-key-bindings-to-work-in-tkinter-why]
- I can't seem to use os.read() on a pipe created with os.popen(); why? [i-can-t-seem-to-use-os-read-on-a-pipe-created-with-os-popen-why]
- If my program crashes with a bsddb (or anydbm) database open, it gets corrupted. How come? [if-my-program-crashes-with-a-bsddb-or-anydbm-database-open-it-gets-corrupted-how-come]
- Importing Tkinter fails on Windows 95/98: why? [importing-tkinter-fails-on-windows-95-98-why]
- __import__('x.y.z') returns module 'x'; how do I get z? [import-x-y-z-returns-module-x-how-do-i-get-z]
- Can I delete Python? [installed-can-i-delete-python]
- What is Python? [installed-what-is-python]
- Why is Python installed on my machine? [installed-why-is-python-installed-on-my-machine]
- Is a PYD file the same as a DLL? [is-a-pyd-file-the-same-as-a-dll]
- Is it possible to write obfuscated one-liners in Python? [is-it-possible-to-write-obfuscated-one-liners-in-python]
- Is it reasonable to propose incompatible changes to Python? [is-it-reasonable-to-propose-incompatible-changes-to-python]
- Is Python a good language for beginning programmers? [is-python-a-good-language-for-beginning-programmers]
- Is Python Y2K (Year 2000) Compliant? [is-python-y2k-year-2000-compliant]
- Is there a curses/termcap package for Python? [is-there-a-curses-termcap-package-for-python]
- Is there an equivalent of C's "?:" ternary operator? [is-there-an-equivalent-of-c-s-ternary-operator]
- Is there an equivalent to C's onexit() in Python? [is-there-an-equivalent-to-c-s-onexit-in-python]
- Is there an equivalent to Perl's chomp() for removing trailing newlines from strings? [is-there-an-equivalent-to-perl-s-chomp-for-removing-trailing-newlines-from-strings]
- Is there a newsgroup or mailing list devoted to Python? [is-there-a-newsgroup-or-mailing-list-devoted-to-python]
- Is there a scanf() or sscanf() equivalent? [is-there-a-scanf-or-sscanf-equivalent]
- Is there a source code level debugger with breakpoints, single-stepping, etc.? [is-there-a-source-code-level-debugger-with-breakpoints-single-stepping-etc]
- Is there a tool to help find bugs or perform static analysis? [is-there-a-tool-to-help-find-bugs-or-perform-static-analysis]
- I tried to open Berkeley DB file, but bsddb produces bsddb.error: (22, 'Invalid argument'). Help! How can I restore my data? [i-tried-to-open-berkeley-db-file-but-bsddb-produces-bsddb-error-22-invalid-argument-help-how-can-i-restore-my-data]
- I try to use __spam and I get an error about _ClassName__spam. [i-try-to-use-spam-and-i-get-an-error-about-someclassname-spam]
- I've never programmed before. Is there a Python tutorial? [i-ve-never-programmed-before-is-there-a-python-tutorial]
- I want to compile a Python module on my Linux system, but some files are missing. Why? [i-want-to-compile-a-python-module-on-my-linux-system-but-some-files-are-missing-why]
- I want to do a complicated sort: can you do a Schwartzian Transform in Python? [i-want-to-do-a-complicated-sort-can-you-do-a-schwartzian-transform-in-python]
M
- Missing cw3215mt.dll (or missing cw3215.dll) [missing-cw3215mt-dll-or-missing-cw3215-dll]
- My class defines __del__ but it is not called when I delete the object. [my-class-defines-del-but-it-is-not-called-when-i-delete-the-object]
- My program is too slow. How do I speed it up? [my-program-is-too-slow-how-do-i-speed-it-up]
P
- PyRun_SimpleFile() crashes on Windows but not on Unix; why? [pyrun-simplefile-crashes-on-windows-but-not-on-unix-why]
S
- Suggestions [suggest]
- Tutor FAQ Suggestions [suggest-tutor]
T
- How do I get data out of HTML? [tutor-how-do-i-get-data-out-of-html]
- How do I make an executable out of my Python program? [tutor-how-do-i-make-an-executable-out-of-my-python-program]
- How do I make public and private attributes and methods in my classes? [tutor-how-do-i-make-public-and-private-attributes-and-methods-in-my-classes]
- How do I perform matrix operations using Python? [tutor-how-do-i-perform-matrix-operations-using-python]
- I'm learning Python. What should I program? [tutor-im-learning-python-what-should-i-program]
- I need help; I'm getting an error in my program. What should I do? [tutor-i-need-help-im-getting-an-error-in-my-program-what-should-i-do]
- What are some good books on Python? [tutor-what-are-some-good-books-on-python]
- What is 'if __name__ == "__main__"' for? [tutor-what-is-if-name-main-for]
- What is Python Tutor? [tutor-what-is-python-tutor]
- What is the policy on homework? [tutor-what-is-the-policy-on-homework]
- What's the best editor/IDE for Python? [tutor-whats-the-best-editor-ide-for-python]
- What's the difference between "import foo" and "from foo import *"? [tutor-whats-the-difference-between-import-foo-and-from-foo-import]
- Why doesn't my regular expression work? [tutor-why-doesnt-my-regular-expression-work]
- Why do my replies go to the person who sent the message and not to the list? [tutor-why-do-my-replies-go-to-the-person-who-sent-the-message-and-not-to-the-list]
W
- Warning about CTL3D32 version from installer [warning-about-ctl3d32-version-from-installer]
- What are the "best practices" for using import in a module? [what-are-the-best-practices-for-using-import-in-a-module]
- What are the rules for local and global variables in Python? [what-are-the-rules-for-local-and-global-variables-in-python]
- What does "SystemError: _PyImport_FixupExtension: module yourmodule not loaded" mean? [what-does-systemerror-pyimport-fixupextension-module-yourmodule-not-loaded-mean]
- What does 'UnicodeError: ASCII decoding error: ordinal not in range(128)' and 'UnicodeError: ASCII encoding error: ordinal not in range(128)' mean? [what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean]
- What is a class? [what-is-a-class]
- What is a generator? [what-is-a-generator]
- What is a method? [what-is-a-method]
- What is an iterator? [what-is-an-iterator]
- What is a sequence? [what-is-a-sequence]
- What is delegation? [what-is-delegation]
- What is __init__.py used for? [what-is-init-py-used-for]
- What is Python? [what-is-python]
- What is Python good for? [what-is-python-good-for]
- What is self? [what-is-self]
- What is the Global Interpreter Lock? [what-is-the-global-interpreter-lock]
- What is the Python Software Foundation? [what-is-the-python-software-foundation]
- What is this bsddb185 module my application keeps complaining about? [what-is-this-bsddb185-module-my-application-keeps-complaining-about]
- What kinds of global value mutation are thread-safe? [what-kinds-of-global-value-mutation-are-thread-safe]
- What module should I use to help with generating HTML? [what-module-should-i-use-to-help-with-generating-html]
- What new developments are expected for Python in the future? [what-new-developments-are-expected-for-python-in-the-future]
- What platform-independent GUI toolkits exist for Python? [what-platform-independent-gui-toolkits-exist-for-python]
- What platform-specific GUI toolkits exist for Python? [what-platform-specific-gui-toolkits-exist-for-python]
- What WWW tools are there for Python? [what-www-tools-are-there-for-python]
- When I edit an imported module and reimport it, the changes don't show up. Why does this happen? [when-i-edit-an-imported-module-and-reimport-it-the-changes-don-t-show-up-why-does-this-happen]
- When importing module X, why do I get "undefined symbol: PyUnicodeUCS2*"? [when-importing-module-x-why-do-i-get-undefined-symbol-pyunicodeucs2]
- Where do I start if I want to learn about the CPython implementation? [where-do-i-start-if-i-want-to-learn-about-the-cpython-implementation]
- Where do nested functions live? [where-do-nested-functions-live]
- Where in the world is www.python.org located? [where-in-the-world-is-www-python-org-located]
- Where is Freeze for Windows? [where-is-freeze-for-windows]
- Where is the math.py (socket.py, regex.py, etc.) source file? [where-is-the-math-py-socket-py-regex-py-etc-source-file]
- Why am I getting strange results with simple arithmetic operations? [why-am-i-getting-strange-results-with-simple-arithmetic-operations]
- Why are colons required for the if/while/def/class statements? [why-are-colons-required-for-the-if-while-def-class-statements]
- Why are default values shared between objects? [why-are-default-values-shared-between-objects]
- Why are floating point calculations so inaccurate? [why-are-floating-point-calculations-so-inaccurate]
- Why are Python strings immutable? [why-are-python-strings-immutable]
- Why are there separate tuple and list data types? [why-are-there-separate-tuple-and-list-data-types]
- Why can't I use an assignment in an expression? [why-can-t-i-use-an-assignment-in-an-expression]
- Why can't lambda forms contain statements? [why-can-t-lambda-forms-contain-statements]
- Why can't raw strings (r-strings) end with a backslash? [why-can-t-raw-strings-r-strings-end-with-a-backslash]
- Why does -22 / 10 return -3? [why-does-22-10-return-3]
- Why does my C extension suddenly crash under 2.5? [why-does-my-c-extension-suddenly-crash-under-2.5]
- Why doesn't closing sys.stdout (stdin, stderr) really close it? [why-doesn-t-closing-sys-stdout-stdin-stderr-really-close-it]
- Why doesn't list.sort() return the sorted list? [why-doesn-t-list-sort-return-the-sorted-list]
- Why doesn't os.popen() and win32pipe.popen() work on Win9x? [why-doesn-t-os-popen-win32pipe-popen-work-on-win9x]
- Why doesn't os.popen() work in PythonWin on NT? [why-doesn-t-os-popen-work-in-pythonwin-on-nt]
- Why doesn't Python have a "with" statement like some other languages? [why-doesn-t-python-have-a-with-statement-like-some-other-languages]
- Why doesn't Python release the memory when I delete a large object? [why-doesnt-python-release-the-memory-when-i-delete-a-large-object]
- Why does Python sometimes take so long to start? [why-does-python-sometimes-take-so-long-to-start]
- Why does Python use indentation for grouping of statements? [why-does-python-use-indentation-for-grouping-of-statements]
- Why does Python use methods for some functionality (e.g. list.index()) but functions for other (e.g. len(list))? [why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list]
- Why do my Tkinter images not appear? [why-do-my-tkinter-images-not-appear]
- Why don't my signal handlers work? [why-don-t-my-signal-handlers-work]
- Why is cPickle so slow? [why-is-cpickle-so-slow]
- Why is it called Python? [why-is-it-called-python]
- Why is join() a string method instead of a list or tuple method? [why-is-join-a-string-method-instead-of-a-list-or-tuple-method]
- Why isn't all memory freed when Python exits? [why-isn-t-all-memory-freed-when-python-exits]
- Why isn't there a switch or case statement in Python? [why-isn-t-there-a-switch-or-case-statement-in-python]
- Why is there no goto? [why-is-there-no-goto]
- Why must dictionary keys be immutable? [why-must-dictionary-keys-be-immutable]
- Why must 'self' be used explicitly in method definitions and calls? [why-must-self-be-used-explicitly-in-method-definitions-and-calls]
- Why was Python created in the first place? [why-was-python-created-in-the-first-place]
- Writing C is hard; are there any alternatives? [writing-c-is-hard-are-there-any-alternatives]
Comment:
I would suggest that articles be organized by concept categories or subcategories. Listing them alphabetically on the basis of the first letter of the question asked essentially requires the reader to scan through the entire list for the concept of interest.
I realize that there is already an Overviews section. Subdividing this and alphabetizing the resulting entries would be very useful.
Posted by Francisco Torres (2006-11-07)
The index below is autogenerated by the zone software used to maintain the FAQ; it's not something we plan to use for the published FAQ /F
Comment:
It might be cool to list questions by popularity on some page--this would allow effort to be targetted to the most valuable questions.
Posted by Mike Klaas (2006-11-07)
Comment:
The article index is hard to scan. I suggest that you either omit common phrases like "How can I" or show them just once, e. g.
Posted by Peter Otten (2006-10-27)