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
Note
For lists and tuples only values of a single level are parsed correctly i.e. (1, 2) and [2, ‘s’] work but [1, [3, 5], 6] doesn’t
Dependencies¶
Dunder has no external dependencies.
Version History¶
Version | Description |
---|---|
0.1.1 | Use some selfdogfooding in setup.py |
0.1 | First release |