Quick actions

cmd+k|ctrl+k

Navigation

Languages

Class (6-12-2024)

Snippet info

Language

Python

Visibility

public

Author

chausage

Created

2024-12-06T01:38:32.206972Z

Updated

2024-12-06T02:58:42.316033Z

class Toy:
    '''This is a toy class''' #add a docstring
    head='blue'
    body='blue'
    def a(self):
        print('class internal function')
        return 123
toy1=Toy()
print(dir(toy1)) #print the hidden functions in toy1
print(Toy.__dict__)#print the hidden functions in Toy's Dict
print(toy1.__dict__) #print the hidden functions in toy1's Dict, nothing inside yet
print(toy1.a) #print address of Toy1.a function
toy1.a() #run Toy.a(toy1)
print(toy1.a()) #run 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__)
print(toy1.head) #print Toy.head 
Toy.a(Toy)
print(Toy.head)
INFO