Python Forum
Why can't I explicitly call __bool__() on sequence type?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why can't I explicitly call __bool__() on sequence type?
#11
(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'>,)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#12
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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error : "can't multiply sequence by non-int of type 'float' " Ala 3 3,076 Apr-13-2021, 10:33 AM
Last Post: deanhystad
  TypeError: can't multiply sequence by non-int of type 'float' DimosG 3 3,354 Apr-04-2020, 05:16 AM
Last Post: michael1789
  TypeError: can't multiply sequence by non-int of type 'str' emmapaw24 2 2,486 Feb-03-2020, 05:50 PM
Last Post: michael1789
  Type hinting - return type based on parameter micseydel 2 2,473 Jan-14-2020, 01:20 AM
Last Post: micseydel
  Binding not explicitly declared happening karkas 4 2,861 Aug-05-2019, 05:09 PM
Last Post: karkas
  TypeError: can't multiply sequence by non-int of type 'str' rregorr 2 2,446 Jun-28-2019, 04:43 PM
Last Post: Yoriz
  TypeError: can't multiply sequence by non-int of type 'str' pythonnoob1234 4 4,282 May-21-2018, 06:12 PM
Last Post: wavic
  What do you call this type of parameter? league55 2 2,727 Feb-17-2018, 03:55 AM
Last Post: league55
  Cant multiply sequence by non-int type 'str' foxtreat 6 7,018 Apr-24-2017, 05:28 PM
Last Post: foxtreat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020