Quick actions

cmd+k|ctrl+k

Navigation

Languages

Class 1 (6-12-2024)

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2024-12-06T03:00:28.606544Z

Updated

2024-12-06T08:52:25.717539Z

class Toy:
    '''This is a toy class''' #add a docstring
    head='blue'
    body='blue'
    def a(self,c): # create a function
        print('class internal function',c) #c is a word
    def __init__(self, leg): # sub-program's function
        self.leg=leg
toy1=Toy(2) 
print(Toy.__dict__)#print Toy's Dict
print(toy1.__dict__) #print toy1's Dict
print(toy1.a) #print address of Toy1.a function
print(toy1.a('abc')) #Toy.a(toy1) and return
toy1.x=1# assign value to toy1.x
print(toy1)#address of toy1
print(toy1.x)#value of toy1.x
print(toy1.__dict__)
toy2=Toy(4)
print(toy1.head) #print Toy.head 
INFO