Hi Doug, The best .NET match for a Python module is a (static) class of static members. To avoid the specifying the namespace, you can use the PythonModuleAttribute. For example, in IronPython.SQLite I have:
[assembly: PythonModule("_sqlite3", typeof(IronPython.SQLite.PythonSQLite))] PythonSQLite is a static class containing static methods/variables. Using this, you can use `from _sqlite3 import *` and not have to worry about the namespaces. I don't know if IronRuby has anything similar. Another option (that I haven't tried) would be to have the class in the global namespace, but I'm not sure that would work. - Jeff On Thu, Sep 2, 2010 at 5:52 AM, Douglas Blank <dbl...@brynmawr.edu> wrote: > 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() { > robot.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! > > -Doug > _______________________________________________ > Users mailing list > Users@lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com