| Rev | Line |   | 
|---|
| [12] | 1 | # Copyright David Abrahams 2004. Distributed under the Boost | 
|---|
 | 2 | # Software License, Version 1.0. (See accompanying | 
|---|
 | 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 
|---|
 | 4 | """ | 
|---|
 | 5 | >>> from dict_ext import * | 
|---|
 | 6 | >>> def printer(*args): | 
|---|
 | 7 | ...     for x in args: print x, | 
|---|
 | 8 | ...     print | 
|---|
 | 9 | ... | 
|---|
 | 10 | >>> print new_dict() | 
|---|
 | 11 | {} | 
|---|
 | 12 | >>> print data_dict() | 
|---|
 | 13 | {1: {'key2': 'value2'}, 'key1': 'value1'} | 
|---|
 | 14 | >>> tmp = data_dict() | 
|---|
 | 15 | >>> print dict_keys(tmp) | 
|---|
 | 16 | [1, 'key1'] | 
|---|
 | 17 | >>> print dict_values(tmp) | 
|---|
 | 18 | [{'key2': 'value2'}, 'value1'] | 
|---|
 | 19 | >>> print dict_items(tmp) | 
|---|
 | 20 | [(1, {'key2': 'value2'}), ('key1', 'value1')] | 
|---|
 | 21 | >>> print dict_from_sequence([(1,1),(2,2),(3,3)]) | 
|---|
 | 22 | {1: 1, 2: 2, 3: 3} | 
|---|
 | 23 | >>> test_templates(printer) | 
|---|
 | 24 | a test string | 
|---|
 | 25 | 13 | 
|---|
 | 26 | None | 
|---|
 | 27 | {1.5: 13, 1: 'a test string'} | 
|---|
 | 28 | default | 
|---|
 | 29 | default | 
|---|
 | 30 | """ | 
|---|
 | 31 |  | 
|---|
 | 32 | def run(args = None): | 
|---|
 | 33 |     import sys | 
|---|
 | 34 |     import doctest | 
|---|
 | 35 |  | 
|---|
 | 36 |     if args is not None: | 
|---|
 | 37 |         sys.argv = args | 
|---|
 | 38 |     return doctest.testmod(sys.modules.get(__name__)) | 
|---|
 | 39 |      | 
|---|
 | 40 | if __name__ == '__main__': | 
|---|
 | 41 |     print "running..." | 
|---|
 | 42 |     import sys | 
|---|
 | 43 |     status = run()[0] | 
|---|
 | 44 |     if (status == 0): print "Done." | 
|---|
 | 45 |     sys.exit(status) | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.