Roman Yakovenko schrieb: > On Feb 12, 2008 11:06 PM, Thomas Heller <[EMAIL PROTECTED]> wrote: >> Here is a fix for this problem: >> >> Index: comtypes/client/_generate.py >> =================================================================== >> --- comtypes/client/_generate.py (revision 59545) >> +++ comtypes/client/_generate.py (working copy) >> @@ -11,6 +11,10 @@ >> >> def _my_import(fullname): >> # helper function to import dotted modules >> + import comtypes.gen >> + if comtypes.client.gen_dir \ >> + and comtypes.client.gen_dir not in comtypes.gen.__path__: >> + comtypes.gen.__path__.append(comtypes.client.gen_dir) >> return __import__(fullname, globals(), locals(), ['DUMMY']) >> >> def _name_module(tlib): > > Thanks. If I understand right the code, I will not have to modify > sys.path . Am I right? >
I added the gen_dir to comtypes.gen.__path__ so that the codegenerator itself can import the new module itself after creation. So, if you later want to import the module as part of the comtypes.gen package, you will probably have to extend comtypes.gen.__path__ yourself somewhere in your own code. The purpose of changing gen_dir was two use cases: - allow dynamic module generation only in memory (for py2exe'd applications where comtypes.gen lives inside a zipfile), - or (but this is totally untested) care about cases where the comtypes.gen directory is unwritable. It may be that both use cases do not yet work as intended. If you want to create the module somewhere else so that you can manually change it or whatever, you should better move it to a private package directory, and rename it. That's what I do, and that's how many of the modules in comtypes were born. Thomas ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users