Question on class module import
MRAB
python at mrabarnett.plus.com
Fri Dec 4 18:53:42 EST 2009
monkeyboy wrote:
> Hello,
>
> I want to write a wrapper class around a windows dll. If I put the
> class in a module "Refprop.py" then import the class where I want to
> use it, does the whole module get read by the interpreter or just the
> class code?...
>
[snip]
The whole module will be run.
In Python 'def' and 'class' aren't declarations, but statements, which
have the side-effect of creating the function or class and binding it to
a name in the enclosing namespace.
If a module contains:
print "The start"
class Foo():
pass
print "The finished"
and then you import it, it'll print "The Start", then create a class
called "Foo" within the module's namespace, then print "The end".
More information about the Python-list
mailing list