@@ -36,7 +36,10 @@ class HumanName(object):
36
36
37
37
Instantiation assigns to ``full_name``, and assignment to
38
38
:py:attr:`full_name` triggers :py:func:`parse_full_name`. After parsing the
39
- name, these instance attributes are available.
39
+ name, these instance attributes are available. Alternatively, you can pass
40
+ any of the instance attributes to the constructor method and skip the parsing
41
+ process. If any of the the instance attributes are passed to the constructor
42
+ as keywords, :py:func:`parse_full_name` will not be performed.
40
43
41
44
**HumanName Instance Attributes**
42
45
@@ -56,6 +59,12 @@ class HumanName(object):
56
59
:param str string_format: python string formatting
57
60
:param str initials_format: python initials string formatting
58
61
:param str initials_delimter: string delimiter for initials
62
+ :param str first: first name
63
+ :param str middle: middle name
64
+ :param str last: last name
65
+ :param str title: The title or prenominal
66
+ :param str suffix: The suffix or postnominal
67
+ :param str nickname: Nicknames
59
68
"""
60
69
61
70
C = CONSTANTS
@@ -77,7 +86,9 @@ class HumanName(object):
77
86
_full_name = ''
78
87
79
88
def __init__ (self , full_name = "" , constants = CONSTANTS , encoding = DEFAULT_ENCODING ,
80
- string_format = None , initials_format = None , initials_delimiter = None ):
89
+ string_format = None , initials_format = None , initials_delimiter = None ,
90
+ first = None , middle = None , last = None , title = None , suffix = None ,
91
+ nickname = None ):
81
92
self .C = constants
82
93
if type (self .C ) is not type (CONSTANTS ):
83
94
self .C = Constants ()
@@ -86,8 +97,17 @@ def __init__(self, full_name="", constants=CONSTANTS, encoding=DEFAULT_ENCODING,
86
97
self .string_format = string_format or self .C .string_format
87
98
self .initials_format = initials_format or self .C .initials_format
88
99
self .initials_delimiter = initials_delimiter or self .C .initials_delimiter
89
- # full_name setter triggers the parse
90
- self .full_name = full_name
100
+ if (first or middle or last or title or suffix or nickname ):
101
+ self .first = first
102
+ self .middle = middle
103
+ self .last = last
104
+ self .title = title
105
+ self .suffix = suffix
106
+ self .nickname = nickname
107
+ self .unparsable = False
108
+ else :
109
+ # full_name setter triggers the parse
110
+ self .full_name = full_name
91
111
92
112
def __iter__ (self ):
93
113
return self
0 commit comments