Chapter 9 Tutorial for Classes Not Working

Fredrik Lundh fredrik at pythonware.com
Fri Jun 30 17:13:01 CEST 2006


Tom Grove wrote:

> I am trying the classes example from the tutorial because some other 
> class related stuff I am doing is not working either.
> 
> Straight from Chapter 9:
> 
> class MyClass:
>     "A simple example class"
>     i = 12345
>     def f(self):
>         return 'hello world'
> 
> 
>  From here I run:
 >
>     x = MyClass

the tutorial says:

     Class instantiation uses function notation. Just pretend that the
     class object is a parameterless function that returns a new
     instance of the class. For example (assuming the above class):

	x = MyClass()

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

</F>




More information about the Python-list mailing list