Attribute access; recommended style

  • Use direct access if user is allowed to read and assign values to the attribute

  • Use properties to restrict access, with a corresponding underlying non-public class attribute

  • Use properties when assignment or reading requires a set of associated operations

  • Never use get/set functions explicitly
    myobj.compute_something()
    myobj.my_special_variable = yourobj.find_values(x,y)
    

    previousnexttable of contents