Jorge Jorge - 1 year ago 79
Python Question

What's the pythonic way to use getters and setters?

I'm doing it like:

def set_property(property,value):
def get_property(property):


or

object.property = value
value = object.property


I'm new to Python, so i'm still exploring the syntax, and i'd like some advice on doing this.

Answer Source

The Pythonic way is to not use them. If you must have them then hide them behind a property.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download