Wildemar Wildenburger said unto the world upon 05/23/2007 08:43 AM: > Bruno Desthuilliers wrote: >> here's an example using a property: >> >> class cpu_ports(object): >> def __init__(self, value=0): >> self._d = value >> @apply >> def value(): >> def fset(self, value): >> print 'vv' >> self._d = value >> def fget(self): >> return self._d >> return property(**locals()) >> > Wow! I've never seen properties written that way. Kind of takes all the > mess out of what it usually is. Nice. BUT! I don't quite get the > @apply-decorator here. The rest I get and so I gather what it is sort of > kind of supposed to do. I have only found the depricated apply() > function in the docs (which I also don't quite get just by scanning it). > Is it that? If yes: How does it work? If not: What's going on there? > > humbly ;) > W
Hi all, I had the same sort of question as Wildemar and I set about investigating as any good pythonista would by typing help(apply) at the interactive prompt. That produced a help text that started: Help on built-in function apply in module __builtin__: But: >>> [x for x in dir('__builtin__') if 'apply' in x] [] ? If apply is in the __builtin__ module, why doesn't dir('__builtin__') know about it? Best to all, Brian vdB -- http://mail.python.org/mailman/listinfo/python-list