homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dsdale24
Recipients Darren.Dale, benjamin.peterson, daniel.urban, dsdale24, eric.araujo, michael.foord, ncoghlan, stutzbach
Date 2011年06月11日.13:21:22
SpamBayes Score 9.619381e-09
Marked as misclassified No
Message-id <BANLkTi=hu9+Q4na7zSrbGvsff6=6p0n7Aw@mail.gmail.com>
In-reply-to <1307796917.62.0.113519414273.issue11610@psf.upfronthosting.co.za>
Content
On Sat, Jun 11, 2011 at 8:55 AM, Nick Coghlan <report@bugs.python.org> wrote:
>
> Nick Coghlan <ncoghlan@gmail.com> added the comment:
>
> inspect.getattr_static has the necessary logic to search for descriptors without invoking them.
Unfortunately, we can't import inspect, even inside ABCMeta.__new__.
> However, it may be better to revert to the idea of pushing this functionality back onto the individual descriptors and have the problematic descriptors like property and staticmethod simply implement __isabstractmethod__ as a property.
>
> property:
> @property
> def __isabstractmethod__(self):
>  return (self.fget.__isabstractmethod__ or
>      self.fset.__isabstractmethod__ or
>      self.fdel.__isabstractmethod__)
>
> staticmethod/classmethod:
>
> @property
> def __isabstractmethod__(self):
>  return self.__func__.__isabstractmethod__
That's a good idea.
> With this approach, the "one true way" to handle abstract descriptors would be to do:
>
> #instance method
> @abstractmethod
> def f(self):
>  ...
>
> @property
> @abstractmethod
> def f(self):
>  ...
>
> @classmethod
> @abstractmethod
> def f(self):
>  ...
>
> @staticmethod
> @abstractmethod
> def f(self):
>  ...
>
> This wouldn't allow for the prettier error messages, but it's much cleaner than having ABCMeta trawling through class attribute dir() lists.
Those classes could conceivably do:
@property
def __abstractmethods__(self):
 return ("...", ...)
It would not be required, but if ABCMeta found it, it could use it.
Just a thought.
Darren
History
Date User Action Args
2011年06月11日 13:21:22dsdale24setrecipients: + dsdale24, ncoghlan, benjamin.peterson, stutzbach, eric.araujo, michael.foord, daniel.urban, Darren.Dale
2011年06月11日 13:21:22dsdale24linkissue11610 messages
2011年06月11日 13:21:22dsdale24create

AltStyle によって変換されたページ (->オリジナル) /