What is the difference between Explicit attribute vs @Property in Python?

What is the difference between Explicit attribute vs @Property in Python?

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

class Geometry(object):
    # Explicit attribute:
    geo_color = "green"
    # Property:
    @property 
    def color(self): 
        return self._color
    @color.setter
    def color(self, value):
        self._color = value
#
class Line(Geometry):
    def Draw(self, Point1, Point2):
        # draw line ...
        pass

line = Line()
line.geo_color = "white"
color = line.geo_color
print line.geo_color
print color

Hi @onrender,

There are a number of important differences between “properties” and “member access”.

The most significant is that you can, through a property, make a member read-only (you can access the state, but you cannot change it).

You can also return a computed value from a property (generate a value “on-the-fly”, as though it were a variable).

I’m sure there is more…

https://docs.python.org/3/tutorial/classes.html

– Dale