Please explain Python "__whatever__" construct.

Jason Scheirer jason.scheirer at gmail.com
Mon Jun 16 18:11:44 EDT 2008


On Jun 16, 2:56 pm, bsag... at gmail.com wrote:
> After a couple of weeks studying Python, I already have a few useful
> scripts, including one that downloads 1500 Yahoo stock quotes in 6
> seconds. However, many things are puzzling to me. I keep on seeing
> things like "__main__" in scripts.  A more obscure example would be
> "__add__" used in string concatenation. For example, I can use "Hello
> "+"world (or just "Hello" "world") to join those two words. But I can
> also use "Hello ".__add__("world"). When and why would I ever use
> "__main__" or the many other "__whatever__" constructs?

http://docs.python.org/lib/genindex.html#letter-_



More information about the Python-list mailing list