[IronPython] How can IronPython access a public static value defined in C#?

Doug Blank doug.blank at gmail.com
Wed Jun 15 16:04:07 CEST 2011

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
  File "<string>", line 1, in <module>
<type 'exceptions.NameError'>: name 'white' is not defined

Is there something I can do to make white accessible with "from ... import *"?

Thanks for any pointers,


More information about the Ironpython-users mailing list