[IronPython] Interfacing multiple Iron python scripts

Dino Viehland dinov at exchange.microsoft.com
Wed Nov 28 17:42:37 CET 2007

You'll need to put C:/TESTPROJS/Project3/Project1/ into Sys.path using PythonEngine.AddToPath.  That will then allow the import machinery to search in the right place to find the file to import.

From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kaveripakam, Sathish
Sent: Wednesday, November 28, 2007 7:18 AM
To: users at lists.ironpython.com
Subject: [IronPython] Interfacing multiple Iron python scripts

Hi All,

I am trying to integrate the C# code with multiple Iron Python scripts.

The idea is:                    C# code: main.cs calls the main function in mainpyfile.py. The mainpyfile.py has a call a function SetUP which is present in an  another ironpython script called Patch1.

The working behavior is:  C# code calls the mainpyfile.py as expected, but when mainpyfile.py tries to call the function in Patch1.py, I encountered a run time error saying Patch1 is not found. I have used "import Patch1" in mainpyfile.py file for the visibility of SetUp function in mainpyfile

Please do let me know, if there are any concerns in interfacing multiple Iron Python  files with C# code using .NET frame work? I am using Iron python 1.1 version using Visual Studio 2K.

Please find the description of the files:


static void Main(string[] rawArgs)

 PythonEngine engine = new PythonEngine();
 engine.Sys.argv = List.Make("C:/TESTPROJS/Project3/Project1/");
 EngineModule engineModule = engine.CreateModule(
  "__main__", new Dictionary<string, object>(), true);

 engine.DefaultModule = engineModule;

 string path = Path.Combine("C:/TESTPROJS/Project3/Project1/","mainpyfile.py" );



import Patch1

def main():
        print 'IN MAIN FUNCTION'

if __name__ == "__main__":


def SetUp:
      print 'PATCH-1'


Legal Notice:
The information in this electronic transmission may contain confidential or legally privileged information and is intended solely for the individual(s) named above. If you are not an intended recipient or an authorized agent, you are hereby notified that reading, distributing, or otherwise disseminating, copying or taking any action based on the contents of this transmission is strictly prohibited. Any unauthorized interception of this transmission is illegal under law. If you have received this transmission in error, please notify the sender by telephone [at the number indicated above/on +41 58 928 0101] as soon as possible and then destroy all copies of this transmission.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20071128/c0ea01e8/attachment.html>

More information about the Ironpython-users mailing list