You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage.rst
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ Using the HumanName Parser
4
4
Example Usage
5
5
-------------
6
6
7
+
The examples use Python 3, but Python 2.6+ is supported.
8
+
7
9
.. doctest::
8
10
:options: +NORMALIZE_WHITESPACE
9
11
@@ -43,8 +45,8 @@ Example Usage
43
45
suffix: 'Jr.'
44
46
nickname: ''
45
47
]>
46
-
>>> name.suffix= ["custom","values"]
47
-
>>> name.suffix
48
+
>>> name.middle= ["custom","values"]
49
+
>>> name.middle
48
50
'custom values'
49
51
>>> name.full_name ='Doe-Ray, Jonathan "John" A. Harris'
50
52
>>> name.as_dict()
@@ -63,12 +65,12 @@ Example Usage
63
65
['Juan', 'Q. Xavier', 'de la Vega']
64
66
>>> name = HumanName('bob v. de la macdole-eisenhower phd')
65
67
>>> name.capitalize()
66
-
>>> unicode(name)
68
+
>>> str(name)
67
69
'Bob V. de la MacDole-Eisenhower Ph.D.'
68
70
>>> # Don't touch mixed case names
69
71
>>> name = HumanName('Shirley Maclaine')
70
72
>>> name.capitalize()
71
-
>>> unicode(name)
73
+
>>> str(name)
72
74
'Shirley Maclaine'
73
75
74
76
Capitalization Support
@@ -86,7 +88,7 @@ entered in all upper or lower case.
86
88
87
89
>>> name = HumanName("bob v. de la macdole-eisenhower phd")
88
90
>>> name.capitalize()
89
-
>>> unicode(name)
91
+
>>> str(name)
90
92
'Bob V. de la MacDole-Eisenhower Ph.D.'
91
93
92
94
It will not adjust the case of mixed case names.
@@ -96,7 +98,7 @@ Nickname Handling
96
98
------------------
97
99
98
100
The content of parenthesis or double quotes in the name will be
99
-
available from the nickname attribute. (Added in v0.2.9)
101
+
available from the nickname attribute.
100
102
101
103
.. doctest:: nicknames
102
104
:options: +NORMALIZE_WHITESPACE
@@ -118,7 +120,8 @@ Change the output string with string formatting
118
120
The string representation of a `HumanName` instance is controlled by its `string_format` attribute. The default value, "{title} {first} {middle} {last} {suffix} ({nickname})", includes parenthesis around nicknames. Trailing commas and empty quotes and parenthesis are automatically removed if the name has no nickname pieces.
119
121
120
122
You can change the default formatting for all `HumanName` instances by setting a new
121
-
`CONSTANTS.string_format` value.
123
+
:py:attr:`~nameparser.config.Constants.string_format` value on the shared
0 commit comments