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.py

    attribute = None
    
  • how to use it in a different file_

    import module
    
    module.attribute
    

module.function()

  • the definiton in module.py

    def function():
        return None
    
  • how to use it in a different file_

    import module
    
    module.function()
    

module.function(*args, **kwargs)

  • the definiton in module.py

    def function(*args, **kwargs)
    
  • how to use it in a different file_

    import module
    
    module.function(*args, **kwargs)
    

module.AClass.attribute

  • the definiton in module.py

    class AClass(object):
    
        attribute = None
    
  • how to use it in a different file_

    import module
    
    instance = module.AClass()
    instance.attribute
    
  • or the name in module.py

    class AClass(object):
    
        def __init__(self, attribute):
            self.attribute = attribute
    
  • how to use it in a different file_

    import module
    
    instance = module.AClass(attribute='Attribute')
    instance.attribute
    

module.AClass.method()

  • the definiton in module.py

    class AClass(object):
    
        def method(self):
            return None
    
  • how to use it in a different file_

    import module
    
    instance = module.AClass()
    instance.method()
    

module.AClass.method(*args, **kwargs)

  • the definiton in module.py

    class AClass(object):
    
        def method(self, *args, **kwargs):
            return None
    
  • how 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