When should we use and when should we not use parentheses with dot notation?
to access class and instance variable, do not use parentheses.
to use methods, use parentheses. Example:
class Example(object): shared = "hello world" # class variable def __init__(self, name): self.name = name # instance variable def method_example(self): # method return "hello %s" % self.name e = Example("daniel") # accessing class variable print e.shared # accessing instance variable print e.name # accessing method print e.method_example()
now imaging strings and lists and so on are classes (you will get more about classes later), so when you create a string:
you create a instance of string class. The class has several methods and variable.
.upper() for example is a method
I know this is confusing right now, but this will make more sense once you learned about classes