Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-21 Thread Guido van Rossum
On Mon, Nov 21, 2011 at 9:22 AM, Michael Foord wrote: > On 20/11/2011 21:41, Guido van Rossum wrote: >> >> On Sun, Nov 20, 2011 at 10:44 AM, Michael Foord >>  wrote: >>> >>> On 20 Nov 2011, at 16:35, Guido van Rossum wrote: >>> Um, what?! __class__ *already* has a special meaning. Those exam

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-21 Thread Michael Foord
On 20/11/2011 21:41, Guido van Rossum wrote: On Sun, Nov 20, 2011 at 10:44 AM, Michael Foord wrote: On 20 Nov 2011, at 16:35, Guido van Rossum wrote: Um, what?! __class__ *already* has a special meaning. Those examples violate that meaning. No wonder they get garbage results. The correct wa

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-20 Thread Guido van Rossum
On Sun, Nov 20, 2011 at 10:44 AM, Michael Foord wrote: > > On 20 Nov 2011, at 16:35, Guido van Rossum wrote: > >> Um, what?! __class__ *already* has a special meaning. Those examples >> violate that meaning. No wonder they get garbage results. >> >> The correct way to override isinstance is explai

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-20 Thread Michael Foord
On 20 Nov 2011, at 16:35, Guido van Rossum wrote: > Um, what?! __class__ *already* has a special meaning. Those examples > violate that meaning. No wonder they get garbage results. > > The correct way to override isinstance is explained here: > http://www.python.org/dev/peps/pep-3119/#overloadin

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-20 Thread Guido van Rossum
Um, what?! __class__ *already* has a special meaning. Those examples violate that meaning. No wonder they get garbage results. The correct way to override isinstance is explained here: http://www.python.org/dev/peps/pep-3119/#overloading-isinstance-and-issubclass . --Guido On Sat, Nov 19, 2011 a

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-20 Thread Vinay Sajip
Michael Foord voidspace.org.uk> writes: > The Python compiler can do strange things with assignment to __class__ in the > presence of super. This issue has now been fixed, but it may be what is > biting you: > > http://bugs.python.org/issue12370 > > If this *is* the problem, then see the workarou

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-19 Thread Michael Foord
On 19 November 2011 23:11, Vinay Sajip wrote: > Michael Foord voidspace.org.uk> writes: > > > That works fine in Python 3 (mock.Mock does it): > > > > >>> class Foo(object): > > ... @property > > ... def __class__(self): > > ... return int > > ... > > >>> a = Foo() > > >>> isinstance(a, i

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-19 Thread Vinay Sajip
Michael Foord voidspace.org.uk> writes: > That works fine in Python 3 (mock.Mock does it): > > >>> class Foo(object): > ... @property > ... def __class__(self): > ... return int > ... > >>> a = Foo() > >>> isinstance(a, int) > True > >>> a.__class__ > > > There must be something else g

Re: [Python-Dev] Python 3, new-style classes and __class__

2011-11-19 Thread Michael Foord
On 19/11/2011 22:06, Vinay Sajip wrote: I was looking through the errors which occur when running the test suite of Django's py3k branch under Python 3, and one particular set of errors caught my eye which is unrelated to the bytes/str dance. These errors occur in some Django utility code, which