On Wed, 2005-09-28 at 10:16, Jim Fulton wrote: > When we ask for the eggs attribute the first time, we call the > descriptor, which calls the eggs function. The function sets the eggs > attribute, overriding the descriptor. The next time the eggs attribute > is accessed, the saved value will be used without calling the > descriptor. > > I do this often enough that I think it would be useful to include it > in python, either as a builtin (like property) or in the library. (Or > possibly by adding an option to property to generate a read > descriptor.) I'd be happy to add this for 2.5.
I /must/ be missing something. Why not just use property as a decorator? class C: @property def eggs(self): print 'in eggs' self.eggs = 7 return self.eggs >>> c = C() >>> c.eggs in eggs 7 >>> c.eggs 7 -Barry
signature.asc
Description: This is a digitally signed message part
_______________________________________________ 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