@@ -80,16 +80,16 @@ def value_to_string(
80
80
>>> value_to_string("invalid", mapping={"mean": "a", "mad": "d", "full": "g"})
81
81
'invalid'
82
82
"""
83
- # None or False means the parameter is not specified, returns None .
83
+ # Return None if the value is None or False .
84
84
if value is None or value is False :
85
85
return None
86
- # True means the parameter is specified, returns an empty string with the optional
87
- # prefix. We don't have to check 'prefix' since it defaults to an empty string!
86
+ # Return an empty string if the value is True. We don't have to check 'prefix' since
87
+ # it defaults to an empty string!
88
88
if value is True :
89
89
return f"{ prefix } "
90
90
91
91
# Convert any value to a string or a sequence of strings.
92
- if is_nonstr_iter (value ): # Is a sequence
92
+ if is_nonstr_iter (value ): # Is a sequence.
93
93
value = [str (item ) for item in value ] # Convert to a sequence of strings
94
94
if separator is None :
95
95
# A sequence is given but separator is not specified. In this case, return
@@ -99,6 +99,7 @@ def value_to_string(
99
99
value = separator .join (value ) # Join the sequence with the separator.
100
100
elif mapping : # Mapping long-form arguments to short-form arguments.
101
101
value = value [0 ] if mapping is True else mapping .get (value , value )
102
+ # Return the final string with the optional prefix.
102
103
return f"{ prefix } { value } "
103
104
104
105
0 commit comments