Importing from a module which contains more than one Class...

GKalman kalman_g at
Mon May 11 05:57:05 CEST 2009

OS= MS Vista
File structure:
.../Module  (i.e a Folder with 2 sub-folders)
    .../Module_Class    (sub-folder #1)
    .../Module_Class_Testing  (sub_folder #2)

Here is the code for the two (simplified) Python files:

#this is
import sys


from MyClass import *
from MyOtherClass import *     # error msg: no such module!

print c.double_it()

cc=MyOtherClass(5.0)          #error
print cc.triple_it()               #error

#this is
class MyClass:
    def __init__(self,x):
    def double_it(self):
        return 2*self.x

class MyOtherClass:
    def __init__(self,y):
    def triple_it(self):
        return 3*self.y

As I mentioned above,  the code for MyClass & MyOtherClass is in the same
file . This program only works with a single Class in a file. That is when
the File name is the SAME as the Class name.

How to import from a File which contains more than one (unrelated) Classes?

View this message in context:
Sent from the Python - python-list mailing list archive at

More information about the Python-list mailing list