""" This examines the errors thrown if any using an .update(args) on dictionary using different arg types This will help determine what checks a data call might need CONCLUSTION: The proported API may only return data congruent with the json or string dictionary object PASS date_rnt6,date_rnt3,date_rnt7,date_rnt8 FAIL date_rnt1,date_rnt2,date_rnt4 """ date_rnt1 = "bob" date_rnt2 = ["bob","for","apples"] date_rnt3 = {"name":"bob"} date_rnt4 = ("I", "am", "bob") date_rnt6 = {'data': ["bob","for","apples"]} date_rnt7 = {'data': {"name":"bob"}} date_rnt8 = {'data': ("I", "am", "bob")} #set our dic object D = {} #update string try: D.update(date_rnt1) print D except ValueError: print " Trying to update a dic with a string results in an Error. " #update List try: D.update(date_rnt2) print D except ValueError: print " Trying to update a dic with a List results in an Error. " #update Dictionary try: D.update(date_rnt3) print D except ValueError: print " Trying to update a dic with a dic results in an Error. " #update Tuple try: D.update(date_rnt4) print D except ValueError: print " Trying to update a tuple with a Tuple results in an Error. " #update Dictionary List try: D.update(date_rnt6) print D except ValueError: print " Trying to update a Dictionary List results in an Error. " #update Dictionary Dictionary try: D.update(date_rnt7) print D except ValueError: print " Trying to update a Dictionary Dictionary results in an Error. " #update Dictionary Tuple try: D.update(date_rnt8) print D except ValueError: print " Trying to update a Dictionary Tuple results in an Error. "
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question