Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76915 > unrolled thread

Re: why the attribute be deleted still in dir(man)?

Started byluofeiyu <elearn2014@gmail.com>
First post2014-08-24 07:35 +0800
Last post2014-08-24 07:35 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: why the attribute be deleted still in dir(man)? luofeiyu <elearn2014@gmail.com> - 2014-08-24 07:35 +0800

#76915 — Re: why the attribute be deleted still in dir(man)?

Fromluofeiyu <elearn2014@gmail.com>
Date2014-08-24 07:35 +0800
SubjectRe: why the attribute be deleted still in dir(man)?
Message-ID<mailman.13366.1408836983.18130.python-list@python.org>
dear ChrisA ,dynamic is python feature, it is to create descriptor in 
run time ,
that is the meaning in the codes,and maybe it is a bug:

the attribute  can be displayed  in dir(man)  after be deleted.




On 8/24/2014 6:56 AM, Chris Angelico wrote:
> On Sun, Aug 24, 2014 at 8:49 AM, luofeiyu <elearn2014@gmail.com> wrote:
>> class Person(object):
>>         def addProperty(self, attribute):
>>                getter = lambda self: self._getProperty(attribute)
>>                setter = lambda self, value: self._setProperty(attribute,
>> value)
>>                deletter = lambda self:self.delProperty(attribute)
>>                setattr(self.__class__, attribute,
>> property(fget=getter,fset=setter,fdel=deletter,doc="Auto-generated method"))
>>         def _setProperty(self, attribute, value):
>>               setattr(self, '_' + attribute, value.title())
>>        def _getProperty(self, attribute):
>>              return getattr(self, '_' + attribute)
>>        def delProperty(self,attribute):
>>              delattr(self,'_' + attribute)
> Look. Forget properties. Python is not Java or C++, and you almost
> never need this kind of thing. Read up a tutorial on doing classes
> Python's way, and you'll find that all this sort of thing just doesn't
> matter. You've come here with a significant number of questions about
> properties, and it looks as if you're trying to do everything through
> them - which is utterly and completely useless, especially when you
> use properties to be as dynamic as you're doing. Just don't do it.
>
> ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web