on-internet
← Community

How to get setters and getters in python

Stack Overflow ·

To use the following: class MyClass: def __init__(self): self.title = None @title.setter def title(self, title): print ('TITLE SETTER: %s' % title) self._title = title NameError: name 'title' is not defined What's wrong with the above code?

Comments

Sign in or sign up to comment and upvote.

No comments yet.