: You can't do that for ordinary modules, since their getattr() is fixed
: and requires that the name is already defined in the dictionary.
: However you can do it with object types you define yourself (and I
: seem to understand that you are already doing that). I see two ways
: of exploiting this for the khoros module:
: - Instead of making these functions part of the module, add a magic
: object to the module and make them methods of that object -- it can
: then do the lazy import. Then tell your users to use methods of this
: object.
: - In the initialization of the module, manipulate sys.modules so that
: sys.modules['khoros'] is not a module but a special object as in the
: previous item (there may be a line in add_module that prevents this
: from working -- I'm willing to take it out).
Can you explain this a little bit further?
I'm asking because I'm thinking about an Obj-C Interface for Python.
The first simple implementation would do something like this:
import ObjC
cls = ObjC.get_class("SomeObjC_Class")
obj = ObjC.send_method(cls,"alloc")
ObjC.send_method(obj,"init")
ObjC.send_method(obj,"doSpam")
If I understand it right I could implement a better version:
import ObjC
cls = ObjC_Class("SomeObjC_Class")
obj = cls.send_method(cls,"alloc")
obj.send_method(obj,"init")
obj.send_method(obj,"doSpam")
But I want to do the following:
import ObjC
vw = View()
vw.initWithFrame(x,y,heigth,width)
ls = List()
ls.init()
ls.insert(vw);
Where View and List are ObjC classes from a library you have to link.
The Obj-C runtime system makes the following information available:
A lisf of classes; the class and instance methods and their argument/return
types. So everything is there. But what to do ?
--
Ciao, Olli
| Oliver Geisser * Steindruefft 11 * 33184 Altenbeken * Germany | | e-mail: ogeisser@uni-paderborn.de * Phone: 05255/7966 | | I prefer ASCII-Mail, but you can also send me NeXT-Mail |