I lurk in #python. It gets a lot of questions that are, shall we say, frequently asked. This is my attempt to catalogue interesting and useful questions. The answers will gradually become separate posts—perhaps on other blogs if someone else gets to them first. Let me know if there should be other questions, if the answers are unclear, or the answers have bugs in them!
- How do I pass by reference? Does Python pass by reference or pass by value?
- Why can’t I create closures within a loop? How do I change a variable in an outer scope? How is Python scoped?
- How do I access a variable whose name is in a string? How do I use “variable variables”?
- What does
isdo? Should I use
- Why doesn’t division work correctly?
- Why are floats inaccurate? What type should I use to handle currency?
- How do I test whether a variable is defined?
- What is
unicodeand why do I care? Why am I getting
- How do I make a tuple with one element? What’s this trailing comma?
- How do I check what type a variable is?
- Why can’t I just do
super(type(self), self)? How does
- What’s the difference between tuples and lists?
- What’s the difference between
- Why can’t I put attribute defaults at class level? Why doesn’t my class counter work?
- How do I make a private attribute? What’s
- How do I inherit from a built-in class, like
- Why don’t my imports work?
- How do I change the value of a global in another module?
- Why do I need to specify
self? How do I take a reference to an object’s method?
- How does
@propertywork? Why does it call my
__getattr__? What’s a “descriptor”?
- How do I make a decorator with optional arguments? How do decorators work?
- Metaclasses are insane!
- I come from C/Java/Prolog/something. How do I write “natural”-looking Python?
- I only know PHP. How do I write a Web application in Python?
- Okay, great; now how do I deploy it?
- How do I parse HTML?
- How do I use a single parameter with the DB-API?
- How do I write a networking application? How do I use sockets?
- How do I do networking with a GUI?
- How do I use threads?
- How do I write a plugin system? How do I reload a module at runtime?
- How do I write an IRC bot?
- How do I store user passwords? How do I do anything related to encryption?
- How do I supply a password for an SSH connection or
- How do I encrypt my program’s source code?
- What are the worst features in Python?