constructor inquiry

Steven Taschuk staschuk at
Sun Apr 6 21:57:18 CEST 2003

Quoth Miranda Evans:
> Thank you for the tip about the built-in type() and isinstance()
> functions.  They reveal that the xl object is of type instance and
> that xl is not an instance of the xlEv class.  This answers the first
> part of question 3.  [...]

Btw, type instance is for instances of old-style classes;
new-style classes inherit from object and will give better
information from type().  For example:

	>>> class Foo: # old-style
	...     pass
	>>> type(Foo())
	<type 'instance'>
	>>> class Bar(object): # new-style
	...     pass
	>>> type(Bar())
	<class '__main__.Bar'>

It is possible to obtain more detailed information for an instance
of an old-style class via __class__:

	>>> Foo().__class__
	<class __main__.Foo at 0x8116484>

You could use this to answer the question: If xl is not an
instance of xlEv, what is it an instance of?

It might also be interesting to see the result of dir(xl).

> So, the xl object is not an instance of xlEv class, but it knows about
> the same type attribute that was assigned to an instance of the xlEv
> class...that's the connection I'm not making.

It is mysterious.  I'd like to know more about what's happening in
win32com.client.DispatchWithEvents; this seems to be the only
place the instance of xlEv could be being created.  (The instance
that you see as self in OnSheetBeforeDoubleClick.)

What do the docs say this function does with its last argument?

Steven Taschuk                                     staschuk at
Receive them ignorant; dispatch them confused.  (Weschler's Teaching Motto)

More information about the Python-list mailing list