Adding imports?

View: New views
4 Messages — Rating Filter:   Alert me  

Adding imports?

by Slide-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is it possible to add imports to a script without just adding text to the source code before compilation?

Maybe something on the script scope or something?

Thanks

--
slide-o-blog
http://slide-o-blog.blogspot.com/

_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Re: Adding imports?

by Dino Viehland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

You can do:

 

scope.SetVariable(“name”, engine.ImportModule(“module_name”));

 

Where ImportModule is an extension method defined in IronPython.Hosting.Python.

 

From: users-bounces@... [mailto:users-bounces@...] On Behalf Of Slide
Sent: Wednesday, November 04, 2009 9:05 AM
To: Discussion of IronPython
Subject: [IronPython] Adding imports?

 

Is it possible to add imports to a script without just adding text to the source code before compilation?

Maybe something on the script scope or something?

Thanks

--
slide-o-blog
http://slide-o-blog.blogspot.com/


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Re: Adding imports?

by Slide-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That is perfect! Thanks!

On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland <dinov@...> wrote:

You can do:

 

scope.SetVariable(“name”, engine.ImportModule(“module_name”));

 

Where ImportModule is an extension method defined in IronPython.Hosting.Python.

 

From: users-bounces@... [mailto:users-bounces@...] On Behalf Of Slide
Sent: Wednesday, November 04, 2009 9:05 AM
To: Discussion of IronPython
Subject: [IronPython] Adding imports?

 

Is it possible to add imports to a script without just adding text to the source code before compilation?

Maybe something on the script scope or something?

Thanks

--
slide-o-blog
http://slide-o-blog.blogspot.com/


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




--
slide-o-blog
http://slide-o-blog.blogspot.com/

_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Re: Adding imports?

by Dave Purrington-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You can load assemblies as well. For example, the hosting assembly:

            Assembly mainAssembly = Assembly.GetExecutingAssembly();
            string rootDir = Directory.GetParent(mainAssembly.Location).FullName;

            _engine.Runtime.LoadAssembly(mainAssembly);


On Wed, Nov 4, 2009 at 12:11 PM, Slide <slide.o.mix@...> wrote:
That is perfect! Thanks!

On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland <dinov@...> wrote:

You can do:

 

scope.SetVariable(“name”, engine.ImportModule(“module_name”));

 

Where ImportModule is an extension method defined in IronPython.Hosting.Python.

 

From: users-bounces@... [mailto:users-bounces@...] On Behalf Of Slide
Sent: Wednesday, November 04, 2009 9:05 AM
To: Discussion of IronPython
Subject: [IronPython] Adding imports?

 

Is it possible to add imports to a script without just adding text to the source code before compilation?

Maybe something on the script scope or something?

Thanks

--
slide-o-blog
http://slide-o-blog.blogspot.com/


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



_______________________________________________
Users mailing list
Users@...
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com