[IronPython] Importing DLLs: namespaces and classes

Douglas Blank dblank at brynmawr.edu
Thu Sep 2 13:52:04 CEST 2010

I'm attempting to write C# code that behaves like a native Python/Ruby
library when imported. However, I can't get the same semantics. In Python:

1) if I put everything in a namespace, then I can issue "from library
import *", but if I put it in a class, then I can't "from ... import ...".

2) if I put everything in a class, then I can have static functions and
values, but I can't "from ... import ...". But namespaces can't have
static functions and values.

Here is a sample of what I'm trying, and what I want:

namespace myro {
  public class myro {
    public class Robot {
    public static Robot robot;
    public static void forward() {

In Python:

from myro import *
# should have robot, Robot, and forward in scope

import myro
# should have myro.robot, myro.Robot, myro.forward and scope

Is there something I'm doing wrong, or is there a hook that I can add to
my importer to get the desired behavior?

Thanks for any pointers!


More information about the Ironpython-users mailing list