Python Forum

Full Version: Why can't I explicitly call __bool__() on sequence type?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(Aug-17-2021, 07:17 PM)quazirfan Wrote: [ -> ]I come from Java background where every class implicitly inherits from object class. I was under the assumption it is the same with python.
Actually, you are right - everything inherits from object, at least in python3 (in python2 there were old-style or classical class and new-style class).

You can see with isinstance
>>> type(type)
<class 'type'>
>>> isinstance(type, object)
True
>>> isinstance(str, object)
True
>>> isinstance(type, type)
True
>>> isinstance(str, type)
True
>>> type.__bases__
(<class 'object'>,)
>>> str.__bases__
(<class 'object'>,)
I miss Python 2's old style classes. They were the remnants of Python 1's classes. At that time there was no class named object. Good old times!
Pages: 1 2