How to create a package in C # for use in IronPython

I saw the IronPython mailing list documentation that describes how to write an extension module in C #. I was able to follow the documentation and everything works fine. However, does anyone know how to make creating a hierarchical PACKAGE extension in C #? For example, you should do something like this for a module:

[assembly: PythonModule("my_module", typeof(test.MyModule))]
namespace test
{

    public static class MyModule
    {
        public static void hello_world()
        {
            Console.WriteLine("hello world");
        }
}

but how would you create a module called testme UNDER my_module, which you would import as follows:

from my_module import testme

A short example or a gentle push in the right direction would be great!

+3
source share
2 answers

PyCrypto .pyd , , Python. , IronPython .

PyCrypto, Python. ( IronPyCrypto) __init__.py PyCrypto,

# for the Hash package
if sys.platfrom == 'cli':
    from IronPyCrypto import MD2, MD4, SHA256

PyCrypto, .

+1

#, , .

namespace foo.bar{

  public class Meh{
     public void CanDoSomething(){
       //does something
     }
  }

}

go

import clr
clr.AddReference("My.DLL") # You may want to change it to AddReferenceByPath or depending on your needs

from foo.bar import Meh

mehvar = Meh()
mehvar.CanDoSomething()

, http://www.theautomatedtester.co.uk/seleniumtraining/selenium_two_ironpython.htm

+2
source

Source: https://habr.com/ru/post/1735097/


All Articles