doc fixes

This commit is contained in:
Richard Jones
2011-11-18 16:10:48 +11:00
parent 00a9eacc7d
commit 5b37c42685
+8 -8
View File
@@ -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')
<Result ('12', 'people') {}>
>>> print parse('Hello {:d} {:w}', 'Hello twelve people')
>>> parse('Our {:d} {:w} are...', 'Our 3 weapons are...')
<Result ('3', 'weapons') {}>
>>> parse('Our {:d} {:w} are...', 'Our three weapons are...')
None
And messing about with alignment:
>>> parse('hello {:<} world', 'hello there world')
<Result ('there',) {}>
>>> parse('hello {:^} world', 'hello there world')
<Result ('there',) {}>
>>> parse('with {:>} herring', 'with a herring')
<Result ('a',) {}>
>>> parse('spam {:^} spam', 'spam lovely spam')
<Result ('lovely',) {}>
Note that the "center" alignment does not test to make sure the value is
actually centered. It just strips leading and trailing whitespace.