From: Neil G. <mis...@gm...> - 2015-05-14 03:06:23
|
I don't want to ruffle any feathers, and I'm sure this comes up all the time, but I'm wondering why don't we have a decorator on classes that generates all of the boilerplate methods? For example: @generate_boilerplate([('linestyle', 'ls'), …] class Patch(…): would generate get_ls, set_ls to point to get_linestyle and set_linestyle and their docstrings and would generate linestyle = property(get_linestyle, set_linestyle) and their docstring. This would reduce a lot of boilerplate code and provide the modern getters and setters. In the future, a user could enable an option to disable the old style interface and remove it from 'dir', etc. What's the reason for not providing the "new"-style getters and setters? |