Class Method គឺជា method ទាំងឡាយណា ដែលត្រូវការថ្នាក់សំរាប់ patameter ទីមួយនៅក្នុង method នោះ។ ពិនិត្យកម្មវិធីខាងក្រោមនេះ៖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class Cash(): def __init__( self ): print ( 'The constructor has been called.' ) def display(cl): print (cl) display = classmethod (display) money = Cash() Cash.display() money.display() |
1 2 3 | The constructor has been called. <class '__main__.Cash' > <class '__main__.Cash' > |
ជារួម ការ call class method បណ្តាលអោយថ្នាក់មួយត្រូវផ្តល់ជា argument អោយ method នោះជាស្វ័យប្រវត្តិ ទោះចង់ក្តីមិនចង់ក្តី៕