This is an old copy of the Python FAQ. The information here may be outdated.

Category: programming

This index is updated by an off-site script, at irregular intervals.

Are there coding standards or a style guide for Python programs?
How can I create a stand-alone binary from a Python script?
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 have modules that mutually import each other?
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 pass optional or keyword parameters from one function to another?
How can I sort one list by values from another list?
How can my code discover the name of an object?
How do I apply a method to a sequence of objects?
How do I call a method defined in a base class from a derived class that overrides 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 string to a number?
How do I convert between tuples and lists?
How do I copy an object in Python?
How do I create a multidimensional list?
How do I create static class data and static class methods?
How do I escape SQL values when using the DB-API?
How do I find the current module name?
How do I get a list of all instances of a given class?
How do I modify a string in place?
How do I share global variables across modules?
How do I specify hexadecimal and octal integers?
How do I use strings to call functions/methods?
How do I write a function with output parameters (call by reference)?
How do you make a higher order function in Python?
How do you make an array in Python?
How do you remove duplicates from a list?
How do you set a global variable in a function?
I try to use __spam and I get an error about _ClassName__spam.
__import__(‘x.y.z’) returns module ‘x’; how do I get z?
Is there a scanf() or sscanf() equivalent?
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 an equivalent to Perl’s chomp() for removing trailing newlines from strings?
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?
What are the “best practices” for using import in a module?
What are the rules for local and global variables in Python?
What does ‘UnicodeError: ASCII decoding error: ordinal not in range(128)’ and ‘UnicodeError: ASCII encoding error: ordinal not in range(128)’ mean?
What is a class?
What is a generator?
What is a method?
What is a sequence?
What is an iterator?
What is delegation?
What is used for?
What is self?
When I edit an imported module and reimport it, the changes don’t show up. Why does this happen?
Why does -22 / 10 return -3?
Why doesn’t Python release the memory when I delete a large object?


A Django site. rendered by a django application. hosted by webfaction.