Per Erik Strandberg /cv /kurser /blog

Just a short demo for me to remember the syntax.

>>> class foo:
...     pass
... 
>>> class bar(foo):
...     pass
... 
>>> class baz(bar):
...     pass
... 
>>> class fubar(int,baz):
...     pass
... 
>>> f = foo()
>>> b1 = bar()
>>> b2 = baz()
>>> fu = fubar()
>>> 
>>> isinstance(fu,foo)
True
>>> isinstance(b1,foo)
True
>>> isinstance(b1,int)
False
>>> isinstance(fu,int)
True


This page belongs in Kategori Programmering.