Define a class : Class Definition « Class « Python






Define a class

 
class MyClass:
    "A simple example class"
    i = 12345
    def f(self):
        return 'hello world'

#__doc__ is also a valid attribute, returning the docstring belonging to the class: 
#"A simple example class".

           
         
  








Related examples in the same category

1.Class Time with properties
2.Class Time with customized attribute access.
3.Simple class with slots
4.Definition and test function for class Point.
5.User-Defined Classes
6.NameTag class
7.Class instance value setting