+ 1

Python 3 - Properties

Hi All, does anyone have any clue to using a decorator to add a setter for a particular property?

26th Sep 2017, 1:27 PM
Elijah Lavai
Elijah Lavai - avatar
2 Respostas
+ 1
@your_property.setter
19th Nov 2020, 2:49 PM
Hoang Tran Thanh Tu
Hoang Tran Thanh Tu - avatar
0
its in the courses but just add @your_var.setter above a function with the same name as your_var (in this example) and then this function will be called when ever someone calls myclass.your_var = value parsing value to your setter function
28th Sep 2017, 3:15 PM
Philippe Dumonet
Philippe Dumonet - avatar