In <[EMAIL PROTECTED]>, tonyr1988
wrote:

> if __name__=='__main__':
>       x = DemoClass
>       x.WriteToFile

In Python classes, functions and methods are first class objects.  You
bind the `DemoClass` class object to the name `x`, you are *not* creating
an instance of `DemoClass`.

Then you access the attribute `WriteToFile` of the `DemoClass` class
object.  But you don't do anything with it.

In [39]: class DemoClass(object): pass
   ....:

In [40]: x = DemoClass

In [41]: x
Out[41]: <class '__main__.DemoClass'>

In [42]: y = DemoClass()

In [43]: y
Out[43]: <__main__.DemoClass object at 0xb5a3fd4c>

In [44]: x()
Out[44]: <__main__.DemoClass object at 0xb5a3fc2c>

You have to call the class object and the method to see any effects.

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to