Python capability do like plugins ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leon

    #1

    Python capability do like plugins ?

    example :
    /home/test/plugins
    a.py
    b.py
    c.py

    main program can dynamic import plugins directory's files....not normal
    ¡uimport¡v
    like winamp


  • Alex Martelli

    #2
    Re: Python capability do like plugins ?

    Leon <square690410@y ahoo.com.tw> wrote:
    [color=blue]
    > example :
    > /home/test/plugins
    > a.py
    > b.py
    > c.py
    >
    > main program can dynamic import plugins directory's files....not normal
    > ¡uimport¡v
    > like winamp[/color]

    The main program can insert the plugins directory into sys.path and
    import at will (e.g with __import__) or do it with the imp module or in
    several other ways. There's a number of recipes in the cookbook...


    Alex

    Comment

    • Leon

      #3
      Re: Python capability do like plugins ?

      Thanks.....
      I use a simple method...

      sys.commands module --> get file list
      re module --> filter file name and path
      imp module --> load module
      getattr() --> get varabiles

      because none dll for unix, I don't know how to use *.pyd
      and how to make *.pyd from *.py


      "Alex Martelli" <aleaxit@yahoo. com>
      ???????:1glurfj .zi6798qu4p2fN% aleaxit@yahoo.c om...[color=blue]
      > Leon <square690410@y ahoo.com.tw> wrote:
      >[color=green]
      >> example :
      >> /home/test/plugins
      >> a.py
      >> b.py
      >> c.py
      >>
      >> main program can dynamic import plugins directory's files....not normal
      >> ¡uimport¡v
      >> like winamp[/color]
      >
      > The main program can insert the plugins directory into sys.path and
      > import at will (e.g with __import__) or do it with the imp module or in
      > several other ways. There's a number of recipes in the cookbook...
      >
      >
      > Alex[/color]


      Comment

      • Alex Martelli

        #4
        Re: Python capability do like plugins ?

        Leon <square690410@y ahoo.com.tw> wrote:
        [color=blue]
        > Thanks.....
        > I use a simple method...
        >
        > sys.commands module --> get file list
        > re module --> filter file name and path
        > imp module --> load module
        > getattr() --> get varabiles
        >
        > because none dll for unix, I don't know how to use *.pyd
        > and how to make *.pyd from *.py[/color]

        Not sure what you mean by "because none dll for unix". A *.pyd on
        Windows is a DLL (meant for Python extension); you cannot make it from a
        *.py, you make it from a *.c or the like. Equivalent on different Unix
        variants are *.so, *.dynlib, and others yet.


        Alex

        Comment

        • Leon

          #5
          Re: Python capability do like plugins ?

          Thank you very much,help me understand it ^_^
          Now,I only use it (simple soluation). if other better soluation when modify
          it
          "Alex Martelli" <aleaxit@yahoo. com> ¼¶¼g©ó¶l¥ó·s»D
          :1glwgve.20tqi2 sdvlc0N%aleaxit @yahoo.com...[color=blue]
          > Leon <square690410@y ahoo.com.tw> wrote:
          >[color=green]
          > > Thanks.....
          > > I use a simple method...
          > >
          > > sys.commands module --> get file list
          > > re module --> filter file name and path
          > > imp module --> load module
          > > getattr() --> get varabiles
          > >
          > > because none dll for unix, I don't know how to use *.pyd
          > > and how to make *.pyd from *.py[/color]
          >
          > Not sure what you mean by "because none dll for unix". A *.pyd on
          > Windows is a DLL (meant for Python extension); you cannot make it from a
          > *.py, you make it from a *.c or the like. Equivalent on different Unix
          > variants are *.so, *.dynlib, and others yet.
          >
          >
          > Alex[/color]


          Comment

          Working...