[IronPython] Dynamically import namespace from C# DLL

Danny Fernandez fernandez.dan at gmail.com
Tue Jul 27 23:06:36 CEST 2010


Thanks for the tip this should get the ball rolling.

On Tue, Jul 27, 2010 at 2:43 PM, Dino Viehland <dinov at microsoft.com> wrote:

>  You can call __import__ directly and then use getattr() to get the
> values, such as:
>
>
>
> getattr(__import__(‘System’), ‘Collections’)
>
>
>
> __import__ returns the top-level namespace so you’ll need to handle each
> dot yourself.
>
>
>
> *From:* users-bounces at lists.ironpython.com [mailto:
> users-bounces at lists.ironpython.com] *On Behalf Of *Danny Fernandez
> *Sent:* Tuesday, July 27, 2010 1:37 PM
> *To:* Discussion of IronPython
> *Subject:* [IronPython] Dynamically import namespace from C# DLL
>
>
>
> I am trying to figure out how to import types from a namesapce at run time.
> I can do a from ... import * but my goal is only to
> to import the types only when I need access to those types from a namespace
> and the namespace is not known until it is calculated by
>
> a request.
> I tried the simpliest and straightforward
>
> namespace = "A.B.C.TargetNameSpace"
> from namespace import *
>
> but that didn't work.  I tried to figure out maybe I can leverage
> reflection. I was able to get all the types from a given namespace
> but I was stuck trying to expose these types to my other parts of my
> script.  I'm using 2.6.1. with .NET 3.5.
>
> I appreciate any feeback.
>
> Danny
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100727/8f7f26ce/attachment.html>


More information about the Ironpython-users mailing list