diff --git a/parse.py b/parse.py index a2e4438..900e4a4 100644 --- a/parse.py +++ b/parse.py @@ -7,7 +7,7 @@ parse() is the opposite of format() The `Format String Syntax`_ is supported with anonymous (fixed-position), -named and formatted fields are supported:: +named and formatted fields:: {[field name]:[format spec]} @@ -71,17 +71,17 @@ where a more complex type specification might have been used. So, for example, some typed parsing, and None resulting if the typing does not match: ->>> parse('Hello {:d} {:w}', 'Hello 12 people') - ->>> print parse('Hello {:d} {:w}', 'Hello twelve people') +>>> parse('Our {:d} {:w} are...', 'Our 3 weapons are...') + +>>> parse('Our {:d} {:w} are...', 'Our three weapons are...') None And messing about with alignment: ->>> parse('hello {:<} world', 'hello there world') - ->>> parse('hello {:^} world', 'hello there world') - +>>> parse('with {:>} herring', 'with a herring') + +>>> parse('spam {:^} spam', 'spam lovely spam') + Note that the "center" alignment does not test to make sure the value is actually centered. It just strips leading and trailing whitespace.