Why does super(bool) give None

Chris Angelico rosuav at gmail.com
Fri Apr 24 02:31:01 EDT 2020


On Fri, Apr 24, 2020 at 4:16 PM Cecil Westerhof <Cecil at decebal.nl> wrote:
>
> issubclass(bool, int) gives True
> but
> super(bool) gives <super: bool, None>
>
> Do I not understand the meaning of super, or is this inconsistent?
>
> (Until now I have not down much work with classes in Python.)
>

One-arg super is an unbound object, and the "None" just indicates
that. (Although every Python that I've tried says NULL there, not
None. What version are you using?) It doesn't say what "the parent
class" is, because super doesn't actually work with parent classes -
it lets you call the *next* class. (In complex inheritance trees, that
can mean going across a diamond or anything.)

I've never actually looked at the repr of a super object - I've always
just called a method on it immediately after constructing it. Never
seen a need to hang onto one :)

ChrisA


More information about the Python-list mailing list