Last active
September 8, 2015 18:33
-
-
Save reece/c9d380ef6926ee1d9d83 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
global_conf_defaults = { | |
'order': 'FL', | |
} | |
global_conf = copy.deepcopy(global_conf_defaults) | |
class Name(object): | |
""" | |
""" | |
def __init__(self, first, last): | |
self.first = first | |
self.last = last | |
def format(self, conf=None): | |
conf = conf or global_conf | |
if conf['order'] == 'FL': | |
return "{self.first} {self.last}".format(self=self) | |
elif conf['order'] == 'LF': | |
return "{self.last}, {self.first}".format(self=self) | |
else: | |
raise RuntimeError("Bogus name order {conf.order}".format(conf=conf)) | |
__str__ = format | |
if __name__ == "__main__": | |
#import doctest | |
#doctest.testmod() | |
me = Name('Reece', 'Hart') | |
print(me) | |
print(me.format(global_conf)) | |
global_conf['order'] = 'LF' | |
print(me.format(global_conf)) | |
print(me) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment