1,105,169 Community Members

Problem importing module

Member Avatar
pratz
Newbie Poster
9 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
vegaseat
DaniWeb's Hypocrite
6,984 posts since Oct 2004
Reputation Points: 1,544 [?]
Q&As Helped to Solve: 1,872 [?]
Skill Endorsements: 67 [?]
Moderator
 
0
 

Most likely this should work ...

import mod

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