dot notation

You have made it to the end of this book. Do you understand these?


module

  • a file in module.py

  • used in a different file

    import module
    

module.variable

  • defined in module.py

    variable = None
    
  • used in a different file

    import module
    
    module.variable
    

module.function()

  • defined in module.py

    def function():
        return None
    
  • called in a different file

    import module
    
    module.function()
    

module.function(*args, **kwargs)

  • defined in module.py

    def function(*args, **kwargs):
    
  • called in a different file

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

module.AClass.attribute

  • defined in module.py

    class AClass(object):
    
        attribute = None
    

    used in a different file

    import module
    
    child = module.AClass()
    child.attribute
    
  • defined in module.py with __init__() method

    class AClass(object):
    
        def __init__(self, attribute=None):
            self.attribute = attribute
    

    used in a different file and setting the value for attribute

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

module.AClass.method()

  • defined in module.py

    class AClass(object):
    
        def method(self):
            return None
    
  • used in a different file

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

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

  • defined in module.py

    class AClass(object):
    
        def method(self, *args, **kwargs):
            return None
    
  • used in a different file

    import module
    
    child = module.AClass()
    child.method(*args, **kwargs)
    

rate pumping python

If this has been a 7 star experience for you, please CLICK HERE to leave a 5 star review of pumping python. It helps other people get into the book too