[python-win32] attribut de classe

Mark Hammond mhammond at skippinet.com.au
Tue Aug 22 09:14:29 CEST 2006


> If I open twice the COM server, in the same application, when
> the first
> instance change the attr of class, the change is not visible
> from the second
> instance.

When a COM attribute is set, Python does the equivalent of:

  setattr(instance, 'attr', 'value')

So - even if you have:

  class Foo:
    attr = 'original value'

If 'Foo' was a COM object, it is equivalent to:

  f1 = Foo()
  f2 = Foo()

  setattr(f1, 'attr', 'new value')

The way Python works, this means that 'f1' now has an *instance* attribute
'attr' - the setattr() did *not* change the class attribute - so 'f2' will
still return 'original value' when queried for that attribute.

Hope this helps,

Mark






>
> Am I correct, or am I fail?
>
> @-salutations
>
> Michel Claveau
>
>
>
>
> _______________________________________________
> Python-win32 mailing list
> Python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>



More information about the Python-win32 mailing list