[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-29 Thread Q

Q abon...@gmail.com added the comment:

thanks, that's rather convenient

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-29 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-26 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

This is a result of how old-style classes are implemented.

If you look at type(Old()), you can see that it isn't Old, but instance.

(And instance is a subclass of object again.)

issubclass for old-style classes doesn't check type(o) but o.__class__, which 
are different: the former is instance and the latter your class.  That is one 
reason we removed old-style classes in Python 3...

--
nosy: +georg.brandl
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-26 Thread Q

Q abon...@gmail.com added the comment:

I do not mean to reopen the bug (there are supposedly much more important 
things to work on in Python). 

But just for the record, let me state that I feel like there is some misleading 
inconsistency here:

- by definition, a new style class is Any class which inherits from object ( 
see http://docs.python.org/glossary.html#term-new-style-class ) ;

- to support this statement, new classes are indeed explicitly defined in the 
form NewClass(object) ;

- now isinstance(), that is supposed to return whether an object is an 
instance of a class or of a subclass thereof (see help(isinstance)), returns 
True for old-style objects.

It also seems reasonable if the descendants of a class will inherit its powers, 
which -- in the case of the old-style classes -- they obviously don't.

Furthermore, I personally see no /point/ in returning True for 
isinstance(Old(), object): as it is quite misleading, one could easily have 
made it returning e.g. None as well.

As I completely accept the fact it's a feature -- ( may be slightly confusing, 
and probably also useless -- but ... hey, nobody's perfect ) -- should I take 
then calling

issubclass(obj.__class__, object) 

to be the official way to distinguish between the new-style and the old-style 
classes?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-26 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

2012/4/26 Q rep...@bugs.python.org:
 issubclass(obj.__class__, object)

 to be the official way to distinguish between the new-style and the old-style 
 classes?

Just do type(cls) is types.ClassType.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-25 Thread Q

Changes by Q abon...@gmail.com:


--
title: isinstance(obj, object) returns True for _old style_ classes - 
isinstance(obj, object) returns True for _old style_ class instances

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-25 Thread Q

Q abon...@gmail.com added the comment:

In addition:

 issubclass(Old, object)
False

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-25 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Yes, everything is a object. issubclass, though, works differently for 
old-style and new-style classes.

--
nosy: +benjamin.peterson
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14671] isinstance(obj, object) returns True for _old style_ class instances

2012-04-25 Thread Q

Q abon...@gmail.com added the comment:

 help(isinstance)

isinstance(...)
isinstance(object, class-or-type-or-tuple) - bool

Return whether an object is an instance of a class or of a subclass thereof.
(...)

So are the old-style class instances descendants of the object?

I feel like I am missing something (except for the fact that you have closed 
the bug).

--
resolution: invalid - 
status: closed - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue14671
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com