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/customize.rst
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,6 +88,7 @@ Other editable attributes
88
88
* :py:obj:`~nameparser.config.Constants.suffix_delimiter` - additional delimiter used to split suffix groups after comma-splitting, e.g. ``" - "`` for names like ``"Jane Smith, RN - CRNA"``. Defaults to ``None`` (disabled).
89
89
* :py:obj:`~nameparser.config.Constants.initials_separator` - string placed between consecutive initials within the same name group (after the delimiter). Defaults to ``" "``, so ``"A. K."``; set to ``""`` for compact ``"A.K."``.
90
90
* :py:obj:`~nameparser.config.Constants.patronymic_name_order` - If set, detects Russian formal-order names (``Surname GivenName Patronymic``) via a trailing East-Slavic patronymic suffix and rotates the parts to Western order (``first=GivenName``, ``middle=Patronymic``, ``last=Surname``). Opt-in; see subsection below.
91
+
* :py:obj:`~nameparser.config.Constants.middle_name_as_last` - If set, folds middle names into the last name (``.last`` becomes what ``.surnames`` already was, ``.middle`` becomes empty). Opt-in; see subsection below.
91
92
92
93
93
94
Russian Formal Name Order
@@ -117,6 +118,29 @@ patronymic-form surnames such as ``"David Michael Abramovich"``. Enable this
117
118
flag only when your data is predominantly Russian formal-order names.
118
119
119
120
121
+
Suppressing Middle Names
122
+
~~~~~~~~~~~~~~~~~~~~~~~~~
123
+
124
+
Some naming systems have no middle-name concept — everything after the given
125
+
name is lineage or family (e.g. Arabic patronymic chaining: given + father +
126
+
grandfather + family). Enable ``middle_name_as_last`` to fold the middle name
127
+
into the last name instead of splitting them::
128
+
129
+
>>> from nameparser import HumanName
130
+
>>> from nameparser.config import Constants
131
+
>>> C = Constants(middle_name_as_last=True)
132
+
>>> hn = HumanName("Mohamad Ahmad Ali Hassan", constants=C)
133
+
>>> hn.first, hn.middle, hn.last
134
+
('Mohamad', '', 'Ahmad Ali Hassan')
135
+
136
+
The fold applies uniformly to comma input too, so both written forms of a name
137
+
converge on the same result::
138
+
139
+
>>> hn2 = HumanName("Hassan, Mohamad Ahmad Ali", constants=C)
- Add ``middle_name_as_last`` flag to ``Constants`` and ``HumanName`` for opt-in folding of middle names into the last name, for naming systems with no middle-name concept (e.g. Arabic patronymic chaining) (#133)
32
33
* 1.2.1 - June 19, 2026
33
34
- Fix ``initials()`` interpolating the literal ``None`` for empty name parts when ``empty_attribute_default = None`` (e.g. ``"J. None D."``); empty parts now render as an empty string and a fully-empty result returns ``empty_attribute_default``
34
35
- Add ``python -m nameparser "Name String"`` command-line helper that prints a parsed name
0 commit comments