Fuzzyman wrote:
> On Nov 26, 11:56 pm, Carl Banks <[EMAIL PROTECTED]> wrote:
>> On Nov 20, 3:50 pm, [EMAIL PROTECTED] (John J. Lee) wrote:
>>> Not much to add to the subject line.  I mean something like this:
>>> ProxyClass.__name__ = ProxiedClass.__name__
>>> I've been told that this is common practice.  Is it?  Would this
>>> surprise you if you ran into it in a debugging session?
>>> One very real advantage that I can see is avoiding breaking existing
>>> doctests.
>>
>> Python 3.0 has a proposal, accepted I believe, to allow classes to
>> control the behavior of issubclass and ininstance, so there appears to
>> be tacit support from the language for mimicking the proxied classes
>> in such ways.
> 
> In Python 2 you can already lie to 'isinstance' and 'issubclass' by
> catching calls to the '__class__' and '__bases__' attribute. I'm not
> sure yet whether this is a good thing however. :-)

The Python 3 machinery allows *other* classes to lie about whether or 
not your object is an instance or subclass of them, without requiring 
them to set your __class__ or __bases__.  So, for example, you can 
create a class ``Integer`` and make ``issubclass(int, Integer)`` true. 
For more information see:

     http://www.python.org/dev/peps/pep-3119/

STeVe
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to