[ create a new paste ] login | about

Link: http://codepad.org/OkWYRue0    [ raw code | output | fork ]

Python, pasted on Feb 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Person(object):

    def __init__(self, id):
        self._name = None
        self._age  = None
    
    @property
    def name(self):
        return self._name
    
    @name.setter
    def name(self):
        self._name = 'sql query'
    
x = Person
x.name = 'test'

print x.name


Output:
1
2
3
4
5
6
Traceback (most recent call last):
  Line 1, in <module>
    class Person(object):
  Line 11, in Person
    @name.setter
AttributeError: 'property' object has no attribute 'setter'


Create a new paste based on this one


Comments: