Start | vars
 

vars(object)



Returnerar en dictionary med variabler och dess värde för ett objekt.
class Shape: def __init__(self, x, y): self.xpos = x self.ypos = y class Cirkel(Shape): def __init__(self, x, y, r): super().__init__(x, y) self.radie = r class Rektangel(Shape): def __init__(self, x, y, h, b): super().__init__(x, y) self.hojd = h self.bredd = b nyshape1 = Rektangel(11,11,5,10) nyshape2 = Cirkel(12,12,8) print(vars(nyshape1)) print(vars(nyshape2))
14.362096786499 ms