Creating property accessors and mutators is quite common in Object-Oriented Programming. Python provides two main ways of implementing getters, setters and deleters; either with the ``++@property++`` decorator, or with the ``++property++`` function.
The following program illustrates how using the built-in operations will call the custom methods defined above.
----
with_decorator = WithPropertyDecorator()
with_decorator.foo = 1 # the method defined under @foo.setter will be called.
some_var = with_decorator.foo # the method defined under @foo.getter will be called.
del with_decorator.foo # the method defined under @foo.deleter will be called.
with_method = WithPropertyMethod()
with_method.foo = 1 # the method set_foo will be called.
some_var = with_method.foo # the method get_foo will be called.
del with_method.foo # the method del_foo will be called.
----
Defining a property this way allows for flexibility when refactoring the implementation of the getters, setters and deleters method, as all the accesses and modifications are done through the Python built-in operators (``++=++``,``++.++``) and keyword (``++del++``).
Property getter, setter and deleter methods are called by the Python interpreter with a specific number of arguments:
* Property getter and deleter methods only require a "self" argument.
* Property setter methods require a "self" argument as well as a value.
Adding any other parameters, or removing these mandatory parameters will throw a ``++TypeError++`` exception at runtime when trying to access or modify the property.
== How to fix it
Make sure to specify the correct number of argument for each setter, getter and deleter methods.