Accessing 'Package Data'

Discussion in 'Python' started by Stefan Arentz, Oct 9, 2007.

  1. At http://docs.python.org/dist/node12.html it is described how to add
    package data to a module. This was pretty easy to do, but now how do I
    access this data from my module? Is there an API to load a 'package
    resource' ala Java's classloader?

    S.
    Stefan Arentz, Oct 9, 2007
    #1
    1. Advertising

  2. Stefan Arentz wrote:

    >
    > At http://docs.python.org/dist/node12.html it is described how to add
    > package data to a module. This was pretty easy to do, but now how do I
    > access this data from my module? Is there an API to load a 'package
    > resource' ala Java's classloader?


    You can always use os.path + the __file__-attribute of the containing
    package.

    And there is the 3rd-party pkg_resources, part of setuptools:

    http://peak.telecommunity.com/DevCenter/PkgResources

    Diez
    Diez B. Roggisch, Oct 9, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parvinder
    Replies:
    6
    Views:
    736
    Thomas G. Marshall
    Feb 27, 2005
  2. Dave
    Replies:
    2
    Views:
    463
  3. George P
    Replies:
    3
    Views:
    671
    Alex Martelli
    Sep 11, 2004
  4. David Pratt
    Replies:
    4
    Views:
    326
    David Pratt
    May 13, 2006
  5. Amit Brahme

    Accessing package data through variable

    Amit Brahme, Mar 15, 2006, in forum: Perl Misc
    Replies:
    12
    Views:
    194
    Uri Guttman
    Mar 17, 2006
Loading...

Share This Page