Georg Brandl [EMAIL PROTECTED] added the comment:
I repeat, what is this easy condition good for?
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4326
___
___
chafporte [EMAIL PROTECTED] added the comment:
but in python 2.5 you may do this:
if type(lInstance) == types.InstanceType:
...
else:
...
and I don't see an easy way to do this with python 2.6
(feel free to propose a solution if you have one)
___
Georg Brandl [EMAIL PROTECTED] added the comment:
What good is a comparison with InstanceType for? If you want to check
whether it's an instance of a custom class, you'll have to check for
instances of new-style classes anyway. If you want to check for UserList
instances, use isinstance().
New submission from chafporte [EMAIL PROTECTED]:
from UserList import UserList
lu = UserList()
type(lu)
python2.6 prints: class 'UserList.UserList'
python2.5 prints: type 'instance'
--
components: None
messages: 75885
nosy: chafporte
severity: normal
status: open
title: type of
Raymond Hettinger [EMAIL PROTECTED] added the comment:
That is because UserList is now a new-style class as a result of it
inheriting from the new abstract base classes. I believe this is the
way Guido wanted it and do not see any deleterious impacts from the change.
Recommend closing as won't
Benjamin Peterson [EMAIL PROTECTED] added the comment:
Isn't policy to keep old-style classes around for compatibility in 2.x?
Especially one like UserList which is meant to be used as a base class.
--
nosy: +benjamin.peterson
___
Python tracker
Raymond Hettinger [EMAIL PROTECTED] added the comment:
It has been the practice to not switch old-style to new-style just for
the hell of it. However, we do switch as part of large PEP driven
efforts like the ABC backport.
___
Python tracker [EMAIL
Benjamin Peterson [EMAIL PROTECTED] added the comment:
Fair enough.
--
resolution: - wont fix
status: open - closed
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4326
___
chafporte [EMAIL PROTECTED] added the comment:
but like that there is no way to detect if the object
is a class or an instance. type() says it's a class in both case !
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4326
Raymond Hettinger [EMAIL PROTECTED] added the comment:
import inspect
from UserList import UserList
lu = UserList()
inspect.isclass(UserList)
True
inspect.isclass(lu)
False
___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4326
chafporte [EMAIL PROTECTED] added the comment:
but for a user define class we have:
class AAA:
... pass
a = AAA()
type(a)
type 'instance'
and you can compare this with types.InstanceType
and it says True
where for the UserList instance the comparison with
types.InstanceType says False
it is
11 matches
Mail list logo