A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-January/051246.html below:

[Python-Dev] PEP 246 - concrete assistance to developers of new adapter classes

[Python-Dev] PEP 246 - concrete assistance to developers of new adapter classes [Python-Dev] PEP 246 - concrete assistance to developers of new adapter classesNick Coghlan ncoghlan at iinet.net.au
Fri Jan 21 14:02:18 CET 2005
Phillip's monkey-typing PEP (and his goal of making it easy to write well 
behaved adapters) got me wondering about the benefits of providing an 
adaptation. Adapter class that could be used to reduce the boiler plate required 
when developing new adapters. Inheriting from it wouldn't be *required* in any 
way - doing so would simply make it easier to write a good adapter by 
eliminating or simplifying some of the required code. Being written in Python, 
it could also serve as good documentation of recommended adapter behaviour.

For instance, it could by default preserve a reference to the original object 
and use that for any further adaptation requests:

class Adapter(object):
   def __init__(self, original):
     self.original = original

   def __conform__(self, protocol):
     return adapt(self.original, protocol)

Does anyone else (particularly those with PEAK and Zope interface experience) 
think such a class would be beneficial in encouraging good practices?

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4