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
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
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.
the way python imports work, when you say import MODULE you are importing the MODULE namespace into your current global namespace. so you can then access objects within MODULE via dot syntax ie: MODULE.class() or MODULE.function(). Now since always typing out your module name when you access its contents isn't always the best, easiest solution, you can also use from MODULE import name to import objects from a module directly into your global namespace, then you can access them with just their name, you could get the last object name from my last example just like that name. So if name happend to be an object with a get_name method defined you could call it with name.get_name().