skip to navigation
skip to content

smartparse 0.4.0

Makes the ConfigParser smarter.

Makes the ConfigParser smarter.

A SmartParser provides methods to parse options as objects of the datetime-modules, as list or as ‘smartlist’. Items of a smartlist are automatically tried to converted into different types (such as: int, float, time, date, datetime).

It also provides additional get- and itme-methods (xget, xitem): xget tries to get the option as one of the following types (in this order): int, float, boolean, time, date, datetime, smartlist. If every type fails the option is given as string.

Latest Version

The latest version of this project can be found at :


  • Option 1 : Install via pip

    pip install smartparse
  • Option 2 : If you have downloaded the source

    python install


How to use?

import io
from smartparse import SmartParser

CONFIG = """
bool = yes
int = 3
float = 3.3
time = 23:55:00
date = 2013.04.24
datetime = 2013.04.24 23:55:00
list = one two three four
smartlist = 3 4.4 1:55 yes 2013.04.24 2013.04.24_01:55

config = SmartParser(allow_no_value=True)
section = dict(self.config.xitems('Section'))

section['bool']             # True
section['datetime']         # datetime.datetime(2013, 4, 24, 23, 55)
section['list']             # ['one', 'two', 'three', 'four']
section['smartlist'][2]     # datetime.time(1, 55)
section['smartlist'][4]     #, 4, 24)

Changes v0.5:

Backwards incompatibility:
getsmartlist became getxlist. Removed the config-methods. Use the timeparser-module directly to change the configuration about parsing time-, date- and datetime-objects.

Reporting Bugs

Please report bugs at github issue tracker:


thomst <> Thomas Leichtfuß

File Type Py Version Uploaded on Size
smartparse-0.4.0.tar.gz (md5) Source 2014-03-23 3KB