It may be a stupid, unnecessary request but I don't know how to do it in Python (I don't have enough skills, probably). If I will be successful it'll boost my efficiency, and I will be able to order my new library functions smarter. I'm also little curious. Anyway...
Say I have a Python script called "xScript.py" that is written like this:
class xClass():
xVariable = ""
def __init__(self, xParameter):
self.xVariable=xParameter
#All these functions below use xVariable
def xFunction(self):
...
def yFunction(self):
...
def zFunction(self):
...
def aFunction(self):
...
def bFunction(self):
...
def cFunction(self):
...
def dFunction(self):
...
class yClass():
def xFunction(self):
#Some Stupid Wrong Syntax (Doesn't Work)
return xClass(xClass.xVariable).xFunction()
Copying and pasting xFunction, yFunction and zFunction to yClass will do but it's something lazy, is there anyway to do that programmatically?
I want to achieve all these functions can be accessed like:
a=xClass("firstVariable")
a.xFunction()
...
a.dFunction()
a.yClass().xFunction()
a.yClass().yFunction()
a.yClass().zFunction()
a.yClass().aFunction() #<-- This should throw an error in my case
Also the functions in yClass should behave the same as the functions in xClass (I wanted to point that because having the same function names is not enough). Thanks...