How to give a custom object instance a type name ?

G

Graeme Matthew

Hi all, quick one,

I hope I am explaining this properly, I am wanting to do some introspection
on custom object instances, for example:

import md5<type 'md5.md5'>

I can at least test here by doing something like if type(m) == 'md5.md5':


Here is a custom Dispatcher class that I have written
<type 'instance'>

How do I get the same as with instance 'm' above where the type displays the
actual object instance name, however my
custom dispatcher instance is just a generic 'instance', is there some
builtin where this is set ?

many thanks

Graeme
 
U

Ulrich Petri

Graeme Matthew said:
Here is a custom Dispatcher class that I have written

<type 'instance'>

You did Java before ;)?
How do I get the same as with instance 'm' above where the type displays the
actual object instance name, however my
custom dispatcher instance is just a generic 'instance', is there some
builtin where this is set ?

how about
HTH
Ciao Ulrich
 
K

Kim Petersen

Graeme said:
Hi all, quick one,

I hope I am explaining this properly, I am wanting to do some introspection
on custom object instances, for example:

import md5


<type 'md5.md5'>

I can at least test here by doing something like if type(m) == 'md5.md5':

how about doing this instead:

isinstance(m,md5.md5)
Here is a custom Dispatcher class that I have written



<type 'instance'>

How do I get the same as with instance 'm' above where the type displays the
actual object instance name, however my
custom dispatcher instance is just a generic 'instance', is there some
builtin where this is set ?

isinstance(x,Dispatcher)

otherwise if you _really_ need the name - just do as some others indicated.


--
Med Venlig Hilsen / Regards

Kim Petersen - Kyborg A/S (Udvikling)
IT - Innovationshuset
Havneparken 2
7100 Vejle
Tlf. +4576408183 || Fax. +4576408188
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top