confused by isinstance()
Duncan Booth
duncan at NOSPAMrcp.co.uk
Fri Feb 1 04:21:15 EST 2002
"Francois Petitjean" <littlejohn.75 at free.fr> wrote in
news:3c5a3352$0$4604$626a54ce at news.free.fr:
> (1) It is trivial as it has :
> only one module
Two modules, Foo and __main__
> only one class
Two classes, one in each module. Foo.Foo and __main__.Foo
> only one instance
> and it uses only builtins and doesn't use 2.2 features.
>
When you run a script, it executes the code in the context of the module
called __main__. When you import a module it has a separate context even if
the script and the module came out of the same source file. Importing a
module executes each line in the file, even if you already ran most of them
as a script.
Every time you execute a class statement, even if the class name is the
same, you create a new class.
--
Duncan Booth duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
More information about the Python-list
mailing list