Message159438
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? |
|
Date |
User |
Action |
Args |
2012-04-27 02:58:46 | thread13 | set | recipients:
+ thread13, georg.brandl, benjamin.peterson |
2012-04-27 02:58:46 | thread13 | set | messageid: <1335495526.15.0.298160882509.issue14671@psf.upfronthosting.co.za> |
2012-04-27 02:58:42 | thread13 | link | issue14671 messages |
2012-04-27 02:58:41 | thread13 | create | |
|