Main Sections

Python Subsections

Dunder.

This is a small Python module to extract dunder variables e.g. __version__ from a Python source code file and presents them as a dictionary.

Example

The following example demonstrates the functionality available in the module.

Using the following Python source file test.py

# -*- coding: utf-8 -*-

# Copyright 2014 Joe Bloggs Inc.

"""Module docstring"""

import datetime

__all__ = ['a']

__version__ = "0.1"
__author__ = "Joe Bloggs <joe.bloggs@example.com>"
__wally__ = 1
__dave__ = 1.1
__brian__ = (1, 2, 3)

def a():
    __walter__ = 'dave'

Running the following code will extract the ‘dunder’ variables and present them as a dictionary

>>> import dunder
>>> d = dunder.parse('test.py')
>>> print(d['__version__'])
0.1
>>> print(d['__walter__'])
dave

Dependencies

None

Download

Version Description URL
0.1.1 Use some selfdogfooding in setup.py dunder-0.1.1.zip
0.1 First release dunder-0.1.zip

Bug Reports

Please use the Dunder project page on Launchpad.net to submit bug reports.