2

I have a question about IronPython. I want to initialize List object from System.Collections.Generic in IronPython and use as a generic parameter my own written IronPython class. But then I get an error:

expected Array[Type], got classobj

Code snippet

Can anyone provide me with some help? Where I am doing something wrong?

1
  • I'd call this question a duplicate of this other question, but that other question does not have any answers. Commented Jun 13, 2017 at 18:56

1 Answer 1

3

To work around this issue, i use object instead of the class type, maybe not the best way to check the type...

list1 = List[object]()

Your syntax works if the FirstClass inherits from a C# type or builtins, but custom Python Class throw this error.


EDIT:

You can also use new style class on FirstClass to avoid this error and keep the right type checking in your array :

class First(object):
        i = 0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.