Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property as a decorator in Python 2.4?

Tags:

python

I'm developing an application for someone who is tied down to Python 2.4. According to the Python builtins page's description of property that "the getter, setter, and deleter attributes were added" in Python 2.6. Is there still a way to use property as a decorator, or is it imperative to use the x = property(...) syntax?

like image 625
Keith Pinson Avatar asked May 01 '26 20:05

Keith Pinson


1 Answers

You can use it as a decorator, but you can only specify a getter if you do so. You can delete the getter, setter, and deleter methods once you have called property() though.

like image 112
Ignacio Vazquez-Abrams Avatar answered May 04 '26 08:05

Ignacio Vazquez-Abrams