Class instantiation uses function notation. : Class instantiation : Class : Python examples (example source code) Organized by topic

C++
PHP
Python
Python Home »  Class   » [  Class instantiation  ]  Screenshots 
 



Class instantiation uses function notation.



#Just pretend that the class object is a 
#parameterless function that returns a new instance of the class.

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


x = MyClass()

# creates a new instance of the class and assigns this object to the local variable x.



           
       
Related examples in the same category
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.