[Tutor] Importing modules/classes

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu Aug 25 02:17:17 CEST 2005



> class dummy_class:
>     def __init__(self):
>         print "__init__"
>
>     def run(self):
>         print "run"
>
>
> Now, I have another file test_dummy.py, which only has the foll 2 lines
>
> import dummy_class
> d=dummy_class()


Hi Hans,

In Python, modules are containers.  They can contain possibly more than
one thing, so you need to make sure to fully qualify the class:

    import dummy_class
    d = dummy_class.dummy_class()

Does this make sense?



More information about the Tutor mailing list