constructor inquiry
Steven Taschuk
staschuk at telusplanet.net
Sat Apr 5 13:50:18 EST 2003
Quoth Miranda Evans:
[...]
> My questions are:
> 1) is it correct that the constructor for the xlEv class never got
> invoked? if so, is it correct to infer that in the sample code below,
> at no time does an object of class xlEv get instantiated?
Certainly your code doesn't instantiate one. I'm not sure about
this line:
> xl = win32com.client.DispatchWithEvents("Excel.Application", xlEv)
Since I know nothing about win32com, I don't know whether this can
be expected to instantiate the class you've passed in.
If you wanted to create an instance yourself here, you need xlEv()
instead of xlEv.
> 2) is it correct to infer that a class method (e.g.
> OnSheetBeforeDoubleClick) can get invoked without an instance of the
> class to which that method belongs getting instantiated?
Class methods can indeed be invoked without an instance; that's
the whole point of class methods. But I think you wanted
OnSheetBeforeDoubleClick to be an instance method.
> 3) is the 'xl' object in the demo() method an object of class xlEv?
> if so, how could the xl object come into existence without the
> constructor getting invoked? if not, how could the xl object have
> visibility to the type attribute?
You can start learning the answers to these questions by adding
print type(xl)
print isinstance(xl, xlEv)
at an appropriate point. What do these lines produce?
--
Steven Taschuk staschuk at telusplanet.net
"Telekinesis would be worth patenting." -- James Gleick
More information about the Python-list
mailing list