This file contains hidden or 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
def accepts_two_types(v): | |
if type(v) == type(1): | |
print "%s is an integer" % (v) | |
elif type(v) == type(''): | |
print "%s is assumed to be a string" % (v) | |
else: | |
raise TypeError, "not a string or int!" | |
if __name__ == "__main__": | |
accepts_two_types(42) |
This file contains hidden or 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
class FListImmutableError(Exception): | |
def __init__(self, msg='Can\'t modify FList members'): | |
self.message = msg | |
def __str__(self): | |
return self.message | |
def f_tl(l): |
This file contains hidden or 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
DATA = {u'makesCount': 39, u'makes': [{u'models': [{u'years': [{u'id': 200471908, u'year': 2014}], u'id': u'Acura_ILX', u'niceName': u'ilx', u'name': u'ILX'}, {u'years': [{u'id': 200493809, u'year': 2014}], u'id': u'Acura_ILX_Hybrid', u'niceName': u'ilx-hybrid', u'name': u'ILX Hybrid'}, {u'years': [{u'id': 200465929, u'year': 2014}], u'id': u'Acura_MDX', u'niceName': u'mdx', u'name': u'MDX'}, {u'years': [{u'id': 200467168, u'year': 2014}], u'id': u'Acura_RDX', u'niceName': u'rdx', u'name': u'RDX'}, {u'years': [{u'id': 100539511, u'year': 2014}], u'id': u'Acura_RLX', u'niceName': u'rlx', u'name': u'RLX'}, {u'years': [{u'id': 200488448, u'year': 2014}], u'id': u'Acura_TL', u'niceName': u'tl', u'name': u'TL'}, {u'years': [{u'id': 200490517, u'year': 2014}], u'id': u'Acura_TSX', u'niceName': u'tsx', u'name': u'TSX'}, {u'years': [{u'id': 200673755, u'year': 2014}], u'id': u'Acura_TSX_Sport_Wagon', u'niceName': u'tsx-sport-wagon', u'name': u'TSX Sport Wagon'}], u'id': 200002038, u'niceName': u'acura', u'name': u'Ac |