[Tutor] Questions regarding class documentation ...

Alan Gauld alan.gauld at blueyonder.co.uk
Tue Jan 27 17:36:57 EST 2004


> class and objects discussion I switched over to reading the Alan
Gauld
> tutorial on the topic;

Maybe you should have read the modules topic too :-)

>  >>>import sampledict  # name sampledict.py
>
> however, when I attempted to run the sample code in the
documentation:
>
>  >>> print defaultdict
> ...
> NameError: name 'defaultdict' is not defined

As I'm sure others have replied by now (but I'm just back from a
business trip and catching up by digest) import only makes the
module name visible. You need to use that to qualify the names
inside the module.

> It is very difficult to gain a firm grasp of this topic when the
results
> are so haphazard and not internally consistent.

Maybe reading the modules bit of my tutor plus the "Whats in a
name?" topic might help. But really its easy enough one the
light-bulb comes on, it's just about adjusting to a new way
of working having come from a C/C++ background.
import is not the same as #include

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list