Date   
Re: Screen fills with ^@^@^@^@^@^@.... when running inside emacs

Stéphane Lozier
 

The screen fills with ^@ when you run your start script from bash or with "comint-run"? Which version are you running? Are you using the .deb package?

On Fri, Dec 27, 2019 at 8:13 AM <intertricity@...> wrote:
Hey there, been trying to track down and troubleshoot this behaviour. I'm using Kubuntu 19.10. I created a script to start mono:

#!/bin/bash
mono ipy.exe

To run ironpython as a single command for emacs using "comint-run" to hopefully interact with whole functions and lines between emacs and the buffer interactively. https://www.emacswiki.org/emacs/ComintMode

The problem is the screen displays the prompt ">>>" but right after, the screen fills non stop with the ^@ character, so I get lines and lines of ^@^@^@^@^@^@^@^@^@

I think this may be the Ctrl-@ null character, I'm not sure. I could probably filter it out, but I was hoping to get some insight into this issue, if its something I should do to the IronPython source, or if I should just filter it out on the emacs side. Any help is appreciated!

Re: IronPython with Anaconda 3.7

Alex Earl
 

You can't mix and match python versions. You would need a 2.7 version of Anaconda because 2.7 is the version of python that ItonPython currently implements.


On Sat, Dec 28, 2019, 17:38 Ajay Kumar Wahi <AjayKumar.Wahi@...> wrote:

Hello everyone,

 

For past few days I am trying to integrate python script into C# application using IronPython. I have Anaconda 3.7.4 installed on the machine. I have added IronPython 2.7.9 as a reference to the project.

The targeted .Net framework is 4.7.2.

 

I am getting exception message while executing python script.

 

 

Below is the C# function that is setting up python environment and executing script:

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

ScriptEngine pythonEngine = IronPython.Hosting.Python.CreateEngine();

 

            ICollection<string> searchPaths = pythonEngine.GetSearchPaths();

            //string pythonInstallPath = Environment.GetEnvironmentVariable("Path");

            //searchPaths.Add(pythonInstallPath);

            //searchPaths.Add(@"C:\ProgramData\Anaconda3\libs");

            //searchPaths.Add(@"C:\ProgramData\Anaconda3\pkgs");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\python37.zip");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\DLLs");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib");

            searchPaths.Add(@"C:\ProgramData\Anaconda3");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\win32");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\win32\lib");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\pythonwin");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\IPython\extensions");

            pythonEngine.SetSearchPaths(searchPaths);

            ScriptSource pythonScript = pythonEngine.CreateScriptSourceFromFile(@"..\..\..\PythonScripts\QC_dummy_file.py");

            var scope = pythonEngine.CreateScope();

 

            object result = pythonScript.Execute(scope);

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

 

Can anyone please share if there is any solution to this problem? Or if there is any specific version of .Net Framework or Anaconda or IronPython that works together?

 

Regards,

Ajay

 

This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

IronPython with Anaconda 3.7

Ajay Kumar Wahi
 

Hello everyone,

 

For past few days I am trying to integrate python script into C# application using IronPython. I have Anaconda 3.7.4 installed on the machine. I have added IronPython 2.7.9 as a reference to the project.

The targeted .Net framework is 4.7.2.

 

I am getting exception message while executing python script.

 

 

Below is the C# function that is setting up python environment and executing script:

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 

ScriptEngine pythonEngine = IronPython.Hosting.Python.CreateEngine();

 

            ICollection<string> searchPaths = pythonEngine.GetSearchPaths();

            //string pythonInstallPath = Environment.GetEnvironmentVariable("Path");

            //searchPaths.Add(pythonInstallPath);

            //searchPaths.Add(@"C:\ProgramData\Anaconda3\libs");

            //searchPaths.Add(@"C:\ProgramData\Anaconda3\pkgs");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\python37.zip");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\DLLs");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib");

            searchPaths.Add(@"C:\ProgramData\Anaconda3");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\win32");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\win32\lib");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\pythonwin");

            searchPaths.Add(@"C:\ProgramData\Anaconda3\Lib\site-packages\IPython\extensions");

            pythonEngine.SetSearchPaths(searchPaths);

            ScriptSource pythonScript = pythonEngine.CreateScriptSourceFromFile(@"..\..\..\PythonScripts\QC_dummy_file.py");

            var scope = pythonEngine.CreateScope();

 

            object result = pythonScript.Execute(scope);

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 

 

Can anyone please share if there is any solution to this problem? Or if there is any specific version of .Net Framework or Anaconda or IronPython that works together?

 

Regards,

Ajay

 

This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient. Any review, use, distribution, or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Re: Copy/Deepcopy C# lists

Stéphane Lozier
 

copy/deepcopy for "unknown" types use pickling and it looks like pickling of strongly typed generic lists using custom Python classes doesn't work properly (it becomes List[Object_1$1] instead of List[MyClass]). Converting to a Python list is one option, otherwise, you can try using the slicing notation (e.g. l2 = l1[:]) or a .NET method (e.g. List constructor or the .ToList() method of Linq).

Stéphane


On Tue, Dec 17, 2019 at 8:24 PM <christoph.neyer@...> wrote:

Is there a way to copy C# typed lists that I'm missing? Currently, the builtin copy/deepcopy fails, but I can workaround it by moving the items to a python list, deepcopying it and casting it back. 

Code:

```

import copy
from System.Collections.Generic import List
class MyClass(object):
def __init__(self, my_attr=10):
self.x = my_attr

c_sharp_list = List[MyClass]([MyClass(my_attr=0), MyClass(my_attr=1)])
print('C#: {}'.format(c_sharp_list))
try:
# this fails
copied_list = copy.deepcopy(c_sharp_list)
print(copied_list)
except Exception as e:
print("failed to deep copy: {}".format(e))

# workaround
# copy the List to a python list
python_list = [x for x in c_sharp_list]
print('Uncopied python list: {}'.format(python_list))
copied_python_list = copy.deepcopy(python_list)
print('Copied python list: {}'.format(copied_python_list))
# cast it back to a typed list
copied_list = List[MyClass](copied_python_list)
print('Copied C# list: {}'.format(copied_list))

```

Output:

```

C#: List[Object_1$1]([<MyClass object at 0x0000000000000290>, <MyClass object at 0x0000000000000291>])

failed to deep copy: Type 'IronPython.NewTypes.System.Object_1$1' in Assembly 'Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Uncopied python list: [<MyClass object at 0x0000000000000290>, <MyClass object at 0x0000000000000291>]

Copied python list: [<MyClass object at 0x000000000000029D>, <MyClass object at 0x000000000000029E>]

Copied C# list: List[Object_1$1]([<MyClass object at 0x000000000000029D>, <MyClass object at 0x000000000000029E>])

```

Screen fills with ^@^@^@^@^@^@.... when running inside emacs

intertricity@...
 

Hey there, been trying to track down and troubleshoot this behaviour. I'm using Kubuntu 19.10. I created a script to start mono:

#!/bin/bash
mono ipy.exe

To run ironpython as a single command for emacs using "comint-run" to hopefully interact with whole functions and lines between emacs and the buffer interactively. https://www.emacswiki.org/emacs/ComintMode

The problem is the screen displays the prompt ">>>" but right after, the screen fills non stop with the ^@ character, so I get lines and lines of ^@^@^@^@^@^@^@^@^@

I think this may be the Ctrl-@ null character, I'm not sure. I could probably filter it out, but I was hoping to get some insight into this issue, if its something I should do to the IronPython source, or if I should just filter it out on the emacs side. Any help is appreciated!

Copy/Deepcopy C# lists

christoph.neyer@...
 

Is there a way to copy C# typed lists that I'm missing? Currently, the builtin copy/deepcopy fails, but I can workaround it by moving the items to a python list, deepcopying it and casting it back. 

Code:

```

import copy
from System.Collections.Generic import List
class MyClass(object):
def __init__(self, my_attr=10):
self.x = my_attr

c_sharp_list = List[MyClass]([MyClass(my_attr=0), MyClass(my_attr=1)])
print('C#: {}'.format(c_sharp_list))
try:
# this fails
copied_list = copy.deepcopy(c_sharp_list)
print(copied_list)
except Exception as e:
print("failed to deep copy: {}".format(e))

# workaround
# copy the List to a python list
python_list = [x for x in c_sharp_list]
print('Uncopied python list: {}'.format(python_list))
copied_python_list = copy.deepcopy(python_list)
print('Copied python list: {}'.format(copied_python_list))
# cast it back to a typed list
copied_list = List[MyClass](copied_python_list)
print('Copied C# list: {}'.format(copied_list))

```

Output:

```

C#: List[Object_1$1]([<MyClass object at 0x0000000000000290>, <MyClass object at 0x0000000000000291>])

failed to deep copy: Type 'IronPython.NewTypes.System.Object_1$1' in Assembly 'Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

Uncopied python list: [<MyClass object at 0x0000000000000290>, <MyClass object at 0x0000000000000291>]

Copied python list: [<MyClass object at 0x000000000000029D>, <MyClass object at 0x000000000000029E>]

Copied C# list: List[Object_1$1]([<MyClass object at 0x000000000000029D>, <MyClass object at 0x000000000000029E>])

```

Re: How to support .NET class slicing using python syntax

Stéphane Lozier
 

IronPython uses IronPython.Runtime.Slice. Looks like the NDArray class in Numpy.NET has a string overload that takes slice notation so you could add an overload like:

public NDarray this[IronPython.Runtime.Slice slice] {
    get {
        return this[$"{slice.start ?? string.Empty}:{slice.stop ?? string.Empty}:{slice.step ?? string.Empty}"];
    }
    set {
        this[$"{slice.start ?? string.Empty}:{slice.stop ?? string.Empty}:{slice.step ?? string.Empty}"] = value;
    }
}

Stéphane


On Thu, Dec 12, 2019 at 11:11 AM Hailiang Shen <hailiang@...> wrote:

Dear all, as far as I know there is still no equivalent numpy lib available to IronPython. Please correct me if this is not the case anymore.

 

We have a few scripts that require numpy lib (using very basic functions e.g. numpy.array). To respond, I am planning to create a C# lib to support these numpy functions, to minimize the effort on the users (ideally just by updating from numpy.net import numpy as np, and the rest of the code can be kept unchanged). One issue is to support slicing using python syntax, e.g. arr[1:3], where arr is a .NET class ndarray object. How can I modify ndarray class so its objects can be sliced in a pythonic way. Not sure implementing the special function __getitem__(self, index) will work since the index will be a slice object. A very simple example will work.

 

Also, what are other options you would use to mimic numpy lib?

 

Thanks for your inputs,

 

Hailiang

 

How to support .NET class slicing using python syntax

Hailiang Shen
 

Dear all, as far as I know there is still no equivalent numpy lib available to IronPython. Please correct me if this is not the case anymore.

 

We have a few scripts that require numpy lib (using very basic functions e.g. numpy.array). To respond, I am planning to create a C# lib to support these numpy functions, to minimize the effort on the users (ideally just by updating from numpy.net import numpy as np, and the rest of the code can be kept unchanged). One issue is to support slicing using python syntax, e.g. arr[1:3], where arr is a .NET class ndarray object. How can I modify ndarray class so its objects can be sliced in a pythonic way. Not sure implementing the special function __getitem__(self, index) will work since the index will be a slice object. A very simple example will work.

 

Also, what are other options you would use to mimic numpy lib?

 

Thanks for your inputs,

 

Hailiang

 

Re: IronPython 3 status

Stéphane Lozier
 

Apologies for the delay in responding. Unfortunately there is no rough date for availability. The project is progressing (albeit slowly) but there is still work to be done before I would even consider some sort of release. Contributions are welcome and would help speed up the process.

Stéphane


On Mon, Sep 16, 2019 at 12:49 PM Hailiang Shen <hailiang@...> wrote:

Dear development team, I understand IronPython 3 is still on the way. Is there a rough date when it will be available, considering python 2 will be retired first day of 2020 (3 months and 15 days away). Thanks

Hailiang

 

IronPython 3 status

Hailiang Shen
 

Dear development team, I understand IronPython 3 is still on the way. Is there a rough date when it will be available, considering python 2 will be retired first day of 2020 (3 months and 15 days away). Thanks

Hailiang

 

How to fetch an image from python to C# using Iron python 2.7

usmankaiz@...
 

Hi,
I am trying to use deep learning model for computer vision for gaming environment, the issue is, passing the image from c# to python is a bit slow, is there any a solution to make this process faster?

I just want the image and results processed by python to C# since other solutions have caused the lag/delay.

Regards,
Usman

Re: Speech Recognition inside Grasshopper for Rhino

Alex Earl
 

If the module requires a native built module, it will not work with IronPython. 


On Tue, Sep 3, 2019, 11:04 Povl Filip Sonne-Frederiksen via Groups.Io <psf=aarch.dk@groups.io> wrote:

Hey everyone,

I was hoping to maybe get some pointers. I’m trying to implement speech recognition using python inside rhino\grasshopper, which in turn relies on IronPython (2.7.8) as its platform.

So far I’ve managed to install SpeechRecognition 3.8.1 but this depends on PyAudio which is making all the trouble.

 

The error  I’m getting is: Python was built with Visual Studio version 6, and extensions need to be built with the same version of the compiler, but it isn't installed.

Do I need to get Visual Studio version 6 or is the some other compiler I can use, that will do the trick. (I’m on Windows 10 and have Visual Studio 2017)

 

Best

Povl

 

 

Full error message :

C:\IronPython 2.7>ipy -X:Frames -m pip install PyAudio-0.2.11.tar.gz

 

Processing c:\ironpython 2.7\pyaudio-0.2.11.tar.gz

Installing collected packages: PyAudio

  Running setup.py install for PyAudio ... error

    Complete output from command "C:\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\xyz\\appdata\\local\\temp\\pip-earp3s-build\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\xyz\appdata\local\temp\pip-v4gaeb-record\install-record.txt --single-version-externally-managed --compile:

    running install

    running build

    running build_py

    creating build

    creating build\lib.cli-2.7

    copying src\pyaudio.py -> build\lib.cli-2.7

    warning: build_py: byte-compiling is disabled, skipping.

 

    running build_ext

    building '_portaudio' extension

    error: Python was built with Visual Studio version 6, and extensions need to be built with the same version of the compiler, but it isn't installed.

 

    ----------------------------------------

Command ""C:\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\xyz\\appdata\\local\\temp\\pip-earp3s-build\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\xyz\appdata\local\temp\pip-v4gaeb-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\xyz\appdata\local\temp\pip-earp3s-build\

 

You are using pip version 8.1.1, however version 19.2.3 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.


Povl Filip Sonne-Frederiksen
Research Assistant
Cand.arch.
Logo
T: +45 8936 0000
E: psf@...
W: aarch.dk
Tagline

Speech Recognition inside Grasshopper for Rhino

psf@...
 

Hey everyone,

I was hoping to maybe get some pointers. I’m trying to implement speech recognition using python inside rhino\grasshopper, which in turn relies on IronPython (2.7.8) as its platform.

So far I’ve managed to install SpeechRecognition 3.8.1 but this depends on PyAudio which is making all the trouble.

 

The error  I’m getting is: Python was built with Visual Studio version 6, and extensions need to be built with the same version of the compiler, but it isn't installed.

Do I need to get Visual Studio version 6 or is the some other compiler I can use, that will do the trick. (I’m on Windows 10 and have Visual Studio 2017)

 

Best

Povl

 

 

Full error message :

C:\IronPython 2.7>ipy -X:Frames -m pip install PyAudio-0.2.11.tar.gz

 

Processing c:\ironpython 2.7\pyaudio-0.2.11.tar.gz

Installing collected packages: PyAudio

  Running setup.py install for PyAudio ... error

    Complete output from command "C:\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\xyz\\appdata\\local\\temp\\pip-earp3s-build\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\xyz\appdata\local\temp\pip-v4gaeb-record\install-record.txt --single-version-externally-managed --compile:

    running install

    running build

    running build_py

    creating build

    creating build\lib.cli-2.7

    copying src\pyaudio.py -> build\lib.cli-2.7

    warning: build_py: byte-compiling is disabled, skipping.

 

    running build_ext

    building '_portaudio' extension

    error: Python was built with Visual Studio version 6, and extensions need to be built with the same version of the compiler, but it isn't installed.

 

    ----------------------------------------

Command ""C:\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\xyz\\appdata\\local\\temp\\pip-earp3s-build\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\xyz\appdata\local\temp\pip-v4gaeb-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\xyz\appdata\local\temp\pip-earp3s-build\

 

You are using pip version 8.1.1, however version 19.2.3 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.


Povl Filip Sonne-Frederiksen
Research Assistant
Cand.arch.
Logo
T: +45 8936 0000
E: psf@...
W: aarch.dk
Tagline

Re: How to support debug in IronPython in .NET software

László Frank
 

Hello,

I am also developing a .Net based debugger and code reflector for IronPython so I would find interesting the "offical" answer. 
Till that time, as a starting point you may want to look at this article, my debugger code is mostly based on that.

Regards,
Laszlo

On Thu, Aug 8, 2019 at 8:15 PM Hailiang Shen <hailiang@...> wrote:

Hello all, our .NET program supports IronPython scripting. We are trying to support debugging (e.g. set break point, step into, step over, run to breakpoint). A script can get/set data in the .NET program. The script is run in the same thread as our script editor UI. I have a few questions as below:

 

  • Do we have to run the debug mode in a thread separate from the UI thread?
  • If so, what is the best way to modify our current get/set methods (many) so under script debug mode, program data can be get/set?
  • As you know, IronPython has excellent support for .NET libs. Will it be any issues to work with .NET libs under debug mode? Similarly, what about the impact on the IronPython libs (e.g. math, os)?
  • Will debug mode slow down a script run, comparing with the case of running without debug?

 

Are there other items we should pay attention to support debugging?

 

Thank you!

 

Hailiang

How to support debug in IronPython in .NET software

Hailiang Shen
 

Hello all, our .NET program supports IronPython scripting. We are trying to support debugging (e.g. set break point, step into, step over, run to breakpoint). A script can get/set data in the .NET program. The script is run in the same thread as our script editor UI. I have a few questions as below:

 

  • Do we have to run the debug mode in a thread separate from the UI thread?
  • If so, what is the best way to modify our current get/set methods (many) so under script debug mode, program data can be get/set?
  • As you know, IronPython has excellent support for .NET libs. Will it be any issues to work with .NET libs under debug mode? Similarly, what about the impact on the IronPython libs (e.g. math, os)?
  • Will debug mode slow down a script run, comparing with the case of running without debug?

 

Are there other items we should pay attention to support debugging?

 

Thank you!

 

Hailiang

Re: How to define a c# class to support IronPython power operator **

Hailiang Shen
 

Thanks for the speedy response. This sample works very well.

 

Hailiang

 

From: users@ironpython.groups.io <users@ironpython.groups.io> On Behalf Of Stéphane Lozier
Sent: July 5, 2019 5:23 PM
To: users@ironpython.groups.io
Subject: Re: [ironpython] How to define a c# class to support IronPython power operator **

 

There are a bunch of variations (e.g. using the name "__pow__", using the name "Power", static methods, instance methods), but here is one example:

 

        public class MyClass {
            private readonly double x;

            public MyClass(double x) {
                this.x = x;
            }

            public static MyClass __pow__(MyClass x, int y) {
                return new MyClass(Math.Pow(x.x, y));
            }

            public static MyClass __pow__(MyClass x, MyClass y) {
                return new MyClass(Math.Pow(x.x, y.x));
            }
        }

 

Stéphane

 

On Fri, Jul 5, 2019 at 4:43 PM Hailiang Shen <hailiang@...> wrote:

Hello all, I am defining a C# assembly to be used in IronPython. For one C# class, I need to support the IronPython power operator (**). For example in IronPython

 

MyClass1 ** 3 will automatically call my power function defined on my C# class.

MyClass1 ** MyClass2 will also automatically call my power function defined on my C# class.

 

It is simple to overload the overloadable operators https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/overloadable-operators, but I am not sure how to support the power operator. Could you suggest which C# operator I need to overload or is there one?

 

Hailiang

Re: How to define a c# class to support IronPython power operator **

Stéphane Lozier
 

There are a bunch of variations (e.g. using the name "__pow__", using the name "Power", static methods, instance methods), but here is one example:

        public class MyClass {
            private readonly double x;

            public MyClass(double x) {
                this.x = x;
            }

            public static MyClass __pow__(MyClass x, int y) {
                return new MyClass(Math.Pow(x.x, y));
            }

            public static MyClass __pow__(MyClass x, MyClass y) {
                return new MyClass(Math.Pow(x.x, y.x));
            }
        }

Stéphane


On Fri, Jul 5, 2019 at 4:43 PM Hailiang Shen <hailiang@...> wrote:

Hello all, I am defining a C# assembly to be used in IronPython. For one C# class, I need to support the IronPython power operator (**). For example in IronPython

 

MyClass1 ** 3 will automatically call my power function defined on my C# class.

MyClass1 ** MyClass2 will also automatically call my power function defined on my C# class.

 

It is simple to overload the overloadable operators https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/overloadable-operators, but I am not sure how to support the power operator. Could you suggest which C# operator I need to overload or is there one?

 

Hailiang

How to define a c# class to support IronPython power operator **

Hailiang Shen
 

Hello all, I am defining a C# assembly to be used in IronPython. For one C# class, I need to support the IronPython power operator (**). For example in IronPython

 

MyClass1 ** 3 will automatically call my power function defined on my C# class.

MyClass1 ** MyClass2 will also automatically call my power function defined on my C# class.

 

It is simple to overload the overloadable operators https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/overloadable-operators, but I am not sure how to support the power operator. Could you suggest which C# operator I need to overload or is there one?

 

Hailiang

Re: How do I access another api using Ironpython and VS2017

jpahto@...
 

System.Activator.GetObject requires to inputs: (Type, String)
If the String presents HKEY_CLASSES_ROOT, then how do I get the type from this.

I have tried the methods mentioned in guide:
https://ironpython.net/documentation/dotnet/dotnet.html#creating-a-com-object
But these do not seem to also work.

Re: How do I access another api using Ironpython and VS2017

Stéphane Lozier
 

Might just be a typo when you wrote your email, but clr.GetClrType(type("SldWorks.Application")) will give you System.String so obviously that won't work. If it's just a typo then I have no idea, you could try googling the error message ("Trying to create a proxy to an unbound type." in English).