1.11M Members

Problem importing module



I have few question regarding importing modules. I have created a folder for my python work


I have exported this to set the $PATH. And now if I issue the command

echo $PATH

I am getting the string the "/usr/home/pratz/pyfiles" in the list. If I am not wrong then this means that the path is been set correctly. Also, I have set the python path in the environment variable and even that is correct.
Now I have a module called "mod.py" and it has a class "cls1" and this class contains a function func()

mod.py -> cls1 -> func()

Now I create another class cls2 and inherit the class cls1

import mod.py
class cls2 (cls1):

Python says that cls1 is not defined. Need help with this.
Also, how can I call the base class method / function from the derived class, I mean to say

c = cls1()

I know that the first one is correct, is that the second one will also work?? Any help is appreciated. Thank you.


Most likely this should work ...

import mod

class cls2(mod.cls1):
This article has been dead for over six months: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: