[IronPython] Distinguishing DLR object from CLR object

Dino Viehland dinov at exchange.microsoft.com
Thu Jan 31 00:31:19 CET 2008


If by "DLR object" you mean an object which has dynamic behavior beyond just it's type you can check to see if it implements IDynamicObject.  But there really isn't anything considered to be a "DLR object".  They're all just CLR objects and some of them can have dynamic behavior.  Even normal CLR objects could have behaviors beyond just their normal CLR type - for example the various methods we add onto .NET strings that match the Python built-in string members.  But I think IDynamicObject will probably get you the answer you're looking for.

________________________________
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher [curt at hagenlocher.org]
Sent: Wednesday, January 30, 2008 3:15 PM
To: Discussion of IronPython
Subject: [IronPython] Distinguishing DLR object from CLR object

Is there a straightforward and reliable way from within IronPython to tell if a particular object is a "CLR object' or a "DLR object"?  I can make a guess for just IronPython by saying

isPythonObject = clr.GetClrType(type(obj)).FullName.startswith('IronPython')

but this is both ugly and unreliable.

--
Curt Hagenlocher
curt at hagenlocher.org<mailto:curt at hagenlocher.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080130/c40b8ea4/attachment.html>


More information about the Ironpython-users mailing list