dot notation
You have made it through the end of the book. Do you understand the following?
AClass.attribute
in the same file
class AClass(object):
attribute = None
or
class AClass(object):
def __init__(self, attribute):
self.attribute = attribute
AClass.method()
in the same file
class AClass(object):
def method(self):
return None
AClass.method(*args, **kwargs)
in the same file
class AClass(object):
def method(self, *args, **kwargs):
return None
module.attribute
the definiton in
module.pyattribute = Nonehow to use it in a different file_
import module module.attribute
module.function()
the definiton in
module.pydef function(): return Nonehow to use it in a different file_
import module module.function()
module.function(*args, **kwargs)
the definiton in
module.pydef function(*args, **kwargs)how to use it in a different file_
import module module.function(*args, **kwargs)
module.AClass.attribute
the definiton in
module.pyclass AClass(object): attribute = Nonehow to use it in a different file_
import module instance = module.AClass() instance.attributeor the name in
module.pyclass AClass(object): def __init__(self, attribute): self.attribute = attributehow to use it in a different file_
import module instance = module.AClass(attribute='Attribute') instance.attribute
module.AClass.method()
the definiton in
module.pyclass AClass(object): def method(self): return Nonehow to use it in a different file_
import module instance = module.AClass() instance.method()
module.AClass.method(*args, **kwargs)
the definiton in
module.pyclass AClass(object): def method(self, *args, **kwargs): return Nonehow to use it in a different file_
import module instance = module.AClass() instance.method(*args, **kwargs)
rate pumping python
If this has been a 7 star experience for you, please leave a 5 star review. It helps other people get into the book too