Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    apipkg 1.2

    Download button

    No screenshots available
    Downloads: 263  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Holger Krekel | More programs
    MIT/X Consortium Lic... / FREE
    June 10th, 2012, 10:32 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    apipkg description

    Namespace control and lazy-import mechanism

    apipkg is a library that allows you to control the exported namespace of a Python package and greatly reduce the number of imports for your users. It is a small pure python module that works on virtually all Python versions, including CPython2.3 to Python3.1, Jython and PyPy. It co-operates well with Python's help() system, custom importers (PEP302) and common command line completion tools.

    Usage is very simple: you can require 'apipkg' as a dependency or you can copy paste the >> import mypkg
    >>> mypkg.path
    < ApiModule 'mypkg.path '>
    >>> mypkg.sub.Class1 # '_mypkg.somemodule' gets imported now
    < class _mypkg.somemodule.Class1 at 0xb7d428fc >
    >>> mypkg.sub.Class2 # '_mypkg.othermodule' gets imported now
    < class _mypkg.somemodule.Class1 at 0xb7d428fc >

    The mypkg.sub namespace and both its classes are lazy loaded. Note that no imports apart from the root 'import mypkg' is required. This means that whoever uses your Api only ever needs this one import. Of course you can still use the import statement like so:

    from mypkg.sub import Class1

    Including apipkg in your package


    If you don't want to add an apipkg dependency to your package you can copy the apipkg.py file somewhere to your own package, for example _mypkg/apipkg.py in the above example. You then import the initpkg function from that new place and are good to go.


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    namespace control | import mechanism | Python library | namespace | control | library

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM