Linux SoftwareProgrammingLibrariesPython config module 0.3.6

Python config module 0.3.6


Python config module allows a hierarchical configuration scheme with support for mappings and sequences, cross-references between one
Developer:   Vinay Sajip
      more software by author →
Price:  0.00
License:   Freely Distributable
File size:   30K
Language:   
OS:   
Rating:   0 /5 (0 votes)
Your vote:  
enlarge screenshot


Python config module allows a hierarchical configuration scheme with support for mappings and sequences, cross-references between one part of the configuration and another, the ability to flexibly access real Python objects without full-blown eval(), an include facility, simple expression evaluation, and the ability to change, save, cascade, and merge configurations.

It interfaces easily with environment variables and command line options. Python config module has been developed on Python 2.3, but should work on version 2.2 or greater.

Usage

The simplest scenario is, of course, "Hello, world". Let's look at a very simple configuration file simple.cfg where a message to be printed is configured:

# The message to print (this is a comment)
message: 'Hello, world!'

and the program which uses it:

from config import Config

# You can pass any file-like object; if it has a name attribute,
# that name is used when file format error messages are printed
f = file('simple.cfg')
cfg = Config(f)
print cfg.message

which results in the expected:

Hello, world!

A configuration file is, at the top level, a list of key-value pairs. Each value, as we'll see later, can be a sequence or a mapping, and these can be nested without any practical limit.

In addition to attribute access (cfg.message in the example above), you can also access a value in the configuration using the getByPath method of a configuration: cfg.getByPath('message') would be equivalent. The parameter passed to getByPath is the path of the required value. The getByPath method is useful for when the path is variable. It could even be read from a configuration.

There is also a get method which acts like the dictionary method of the same name - you can pass a default value which is returned if the value is not found in the configuration. The get method works with dictionary keys or attribute names, rather than paths. Hence, you may call cfg.getByPath('a.b') which is equivalent to cfg.a.b, or you can call cfg.a.get('b', 1234) which will return cfg.a.b if it is defined, and 1234 otherwise.

What's New in This Release:
  • This release makes classes derive from an object (previously, they were old-style classes).
  • ConfigMerger has been changed to use a more flexible merge strategy.
  • Multi-line strings (using """ or ''') are now supported.
  • A typo involving raising a ConfigError was fixed.
    tags you can  hello world  the configuration  cfg getbypath  getbypath method  the getbypath  the path  this release  call cfg  get method  cfg message  simple cfg  and the  

    Download Python config module 0.3.6


     http://www.red-dove.com/config-0.3.6.tar.gz


    Authors software

    Python logging module 0.4.9.5 (by Vinay Sajip)
    The Python logging module implements a standard logging system for Python programs

    Python config module 0.3.6 (by Vinay Sajip)
    Python config module allows a hierarchical configuration scheme with support for mappings and sequences, cross-references between one


    Similar software

    Python config module 0.3.6 (by Vinay Sajip)
    Python config module allows a hierarchical configuration scheme with support for mappings and sequences, cross-references between one

    PXP::Config 0.1.2 (by PXP::Config Team)
    PXP::Config is a Perl module for PXP configuration.

    SYNOPSIS

    # do this only once at server initialization:
    PXP::Config::init(f

    Config::IniFiles 2.38 (by Scott Hutton)
    Config::IniFiles is a module for reading .ini-style configuration files.

    SYNOPSIS

    use Config::IniFiles;
    my $cfg = new Conf

    Pipeline::Config 0.05 (by Steve Purkis)
    SYNOPSIS

    use Error qw( :try );
    use Pipeline::Config;

    my $config = Pipeline::Config->new();

    try {
    my $pipe =

    pyrad 0.9 (by Wichert Akkerman)
    pyrad is a Python RADIUS client.

    pyrad contains several modules:

    pyrad.client
    RADIUS client class

    FXPy 1.0.5 (by Lyle Johnson)
    FXPy is a Python extension module which provides an interface to the FOX cross-platform GUI library

    Stem 0.10 (by Stem Systems)
    Stem project is a modular network application suite and toolkit

    InfoBox 0.9 (by Paweł Drygas)
    InfoBox is a notification tool based on specifications from http://www.galago-project.org/

    Kernel Configuration Comparison 0.2 (by Salem Ganzhorn)
    Kernel Configuration Comparison (kccmp) provides a GUI for comparing two Linux kernel ".config" files.

    It shows configuration vari

    Net::DBus 0.33.2 (by Daniel Berrange)


    Other software in this category

    zlib 1.2.3 (by Jean-loup Gailly)
    zlib is designed to be a free, general-purpose, legally unencumbered, lossless data-compression library for use on virtually any comp

    libjpeg v6b (by Independent JPEG Group)
    libjpeg is a library for handling the JPEG (JFIF) image format

    OpenSSL 0.9.7c (by The OpenSSL Project Team)
    The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implement

    libxml2 2.6.27 (by DV)
    Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), libxml2 library i

    GNU C library 2.4 (by Andreas Jaeger)
    GNU C library (glibc) is one of the most important components of GNU Hurd and most modern Linux distributions.

    GNU C library is us

  •     search


    Featured Software

    jEdit 4.3 pre8
    jEdit is an Open Source text editor written in Java

    Opera 9.02
    Surf the Internet in a safer, faster, and easier way with Opera browser

    GNU Aspell 0.60.4
    GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell


    Subscribe in Rojo
    Google Reader
    Add to My Yahoo!

    Add to My AOL
    Subscribe with Bloglines
    Subscribe in NewsGator Online
    Add 'nixbit linux software' to Newsburst from CNET News.com
    del.icio.us nixbit linux software


    Top tags