-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.py
88 lines (74 loc) · 2.67 KB
/
functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import sys
import config
def build_full_name1(first_name, middle_name, last_name):
string_one_space = " "
name = (first_name, middle_name, last_name)
full_name = string_one_space.join(name)
return full_name
def build_full_name2(first_name, middle_name, last_name):
string_one_space = " "
try:
name = (first_name, middle_name, last_name)
full_name = string_one_space.join(name)
except Exception as e:
print("An error occurred. {}".format(str(e)))
finally:
pass
return full_name
def build_full_name3(first_name, middle_name, last_name):
string_one_space = " "
try:
name = (first_name, middle_name, last_name)
full_name = string_one_space.join(name)
except:
exception_message = sys.exc_info()[0]
print("An error occurred. {}".format(exception_message))
return full_name
def build_full_name4(first_name, middle_name, last_name):
string_one_space = " "
exception_message = None
try:
name = (first_name, middle_name, last_name)
full_name = string_one_space.join(name)
except:
exception_message = sys.exc_info()[0]
return full_name, exception_message
def build_full_name5(first_name, middle_name, last_name):
'''
build person full time
:param first_name: person first name
:param middle_name: person middle name
:param last_name: person last name
:return person full name
'''
exception_message = None
try:
name = (first_name, middle_name, last_name)
full_name = config.STRING_ONE_SPACE.join(name)
except:
exception_message = sys.exc_info()[0]
return full_name, exception_message
def main():
# constants
string_one_space = " "
STRING_ONE_SPACE = " "
# first_name = "John"
# middle_name = "B"
# last_name = "Smith"
first_name, middle_name, last_name= "John", "B", "Smith"
# full_name = first_name + " " + middle_name + " " + last_name
# print(full_name)
# string_one_space = " "
# name = (first_name, middle_name, last_name)
# full_name = string_one_space.join(name)
# print(full_name)
# name = (first_name, middle_name, last_name)
# full_name = STRING_ONE_SPACE.join(name)
# print("Full Name: {}".format(full_name))
# full_name = build_full_name3(first_name, middle_name, last_name)
# print("Full Name: {}".format(full_name))
full_name, exception_message = build_full_name5(first_name, middle_name, last_name)
if exception_message is None:
print("Full Name: {}".format(full_name))
if __name__ == '__main__':
main()