The SDK
class is not a parent of the api
class in your example, i.e. api
does not inherit from SDK
, they are merely nested.
Therefore the self
object in your api.innerMethod
method is only an instance of the api
class and doesn't provide access to methods of the SDK
class.
I strongly recommend getting more knowledgeable about object-oriented programming concepts and grasp what the issue is here. It will help you tremendously.
As for using modules to achieve something along these lines, you can, for example, pull everything from the SDK
class to sdk.py
file, which would be the sdk
module.
sdk.py:
URL = 'http://example.com'
def checkUrl(url):
#some code
class api:
def innerMethod(self, url):
data = checkUrl(url)
#rest of code
main.py:
import sdk
api = sdk.api()
api.innerMethod('http://stackoverflow.com')
Or you may go even further and transform sdk
to a package with api
being a module inside it.
See https://docs.python.org/2/tutorial/modules.html for details on how to use modules and packages.