On 10/17/05, Steven Bethard <[EMAIL PROTECTED]> wrote: > I'm not sure if you'll like it any better, but I combined Michael > Urman's suggestion with my late-binding property recipe to get: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/442418 > It solves the name-repetition problem and the late-binding problem (I > believe), at the cost of either adding an extra argument to the > functions forming the property or confusing the "self" argument a > little.
That is probably as good as you can get it *if* you prefer the nested class over a property call with string arguments. Personally, I find the nested class inheriting from Property a lot more "magical" than the call to property() with string arguments. I wonder if at some point in the future Python will have to develop a macro syntax so that you can write Property foo: def get(self): return self._foo ...etc... which would somehow translate into code similar to your recipe. But until then, I prefer the simplicity of foo = property('get_foo', 'set_foo') -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com