2

Consider this C# code:

public static class Graphics {
  public static Color white = new Color(255, 255, 255);
}

I can compile and import this from IronPython:

>>> import clr
>>> clr.AddReference("Graphics")
>>> import Graphics
>>> Graphics.white
<Color 255,255,255>

But I can't:

>>> import clr
>>> clr.AddReference("Graphics")
>>> from Graphics import *
>>> white
Traceback (most recent call last):
  File "/home/dblank/Calico/src/engine.py", line 159, in execute
    source.Execute(self.manager.scope)
  File "<string>", line 1, in <module>
<type 'exceptions.NameError'>: name 'white' is not defined

Is there something I can do to make white accessible?

1 Answer 1

2

If you mark the field as readonly then we'll allow importing it via import * because it'll get added to Graphics.all.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, that did it. Is there a way to make public static properties visible? public static int MyValue { get {} set {} }; doesn't seem to appear.
Oh, and what is .all? Can we add things to that in C#?

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.