I decided to give learning python a go today, going in the traditional "try random things until something works" way.
I started reading about classes, and then properties, and I tried to create some on my own. Most examples, and even examples from questions on this site, define properties like this:
class C(object):
def __init__(self):
self._x = None
@property
def x(self):
"""I'm the 'x' property."""
return self._x
@x.setter
# etc. taken from the python tutorial
When I start typing "@pro" in my text editor and hit tab, it completes to this:
# ... Class stuff ...
@def foo():
doc = "The foo property."
def fget(self):
return self._foo
def fset(self, value):
self._foo = value
foo = property(**foo())
Do these do the same thing, if they do, which one should I use (i.e. which is considered better practice)?