954,557 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Problem importing module

Hello,

I have few question regarding importing modules. I have created a folder for my python work
/usr/home/pratz/pyfiles
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()
c.func()
or
mod.func()

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

pratz
Newbie Poster
9 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Most likely this should work ...

import mod

class cls2(mod.cls1):
    pass
vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: