Embedded python: dotted (sub) module name

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • logistix at cathoderaymission.net

    Embedded python: dotted (sub) module name

    I get the feeling I'm just picking the wrong google search phrase
    here, because I'm finding nothing. I'm trying to namespace out some
    embedded python modules. This works:

    Py_InitModule(" game", py_game_methods );

    but this doesn't:

    Py_InitModule(" quake.game", py_game_methods );

    What am I missing here? Any help would be appreciated.
  • Carl Banks

    #2
    Re: Embedded python: dotted (sub) module name

    logistix at cathoderaymissi on.net wrote:[color=blue]
    > I get the feeling I'm just picking the wrong google search phrase
    > here, because I'm finding nothing. I'm trying to namespace out some
    > embedded python modules. This works:
    >
    > Py_InitModule(" game", py_game_methods );
    >
    > but this doesn't:
    >
    > Py_InitModule(" quake.game", py_game_methods );
    >
    > What am I missing here? Any help would be appreciated.[/color]


    A module's package is defined the importer, not by the module itself.
    Move a module file to a different directory, and BAM, it's in a
    different package.

    If your only wish is to make it so that someone can import your
    extension module using "from quake import game", then it is enough to
    just copy the DLL or shared lib into the proper directory. (Well, you
    also have to remember to put an __init__.py file in the quake
    directory.)


    --
    CARL BANKS

    Comment

    • logistix at cathoderaymission.net

      #3
      Re: Embedded python: dotted (sub) module name

      Carl Banks <imbosol@aerojo ckey.com> wrote in message news:<xj%Va.284 6$cI2.2183@nwrd ny01.gnilink.ne t>...[color=blue]
      > logistix at cathoderaymissi on.net wrote:[color=green]
      > > I get the feeling I'm just picking the wrong google search phrase
      > > here, because I'm finding nothing. I'm trying to namespace out some
      > > embedded python modules. This works:
      > >
      > > Py_InitModule(" game", py_game_methods );
      > >
      > > but this doesn't:
      > >
      > > Py_InitModule(" quake.game", py_game_methods );
      > >
      > > What am I missing here? Any help would be appreciated.[/color]
      >
      >
      > A module's package is defined the importer, not by the module itself.
      > Move a module file to a different directory, and BAM, it's in a
      > different package.
      >
      > If your only wish is to make it so that someone can import your
      > extension module using "from quake import game", then it is enough to
      > just copy the DLL or shared lib into the proper directory. (Well, you
      > also have to remember to put an __init__.py file in the quake
      > directory.)[/color]

      Thanks, but I don't have a physical .pyd since this is an embedded
      interpreter. I'm just calling my 'init_module()' function directly
      from C, similar to the way array and other modules are statically
      added to the python dll.

      Comment

      Working...