Monday 3 December 2018

python - Use of isinstance() can overwrite type

Use of isinstance() changed the class type of dict
Why is this happening? I know using builtins would prevent but I want to understand better why this is happening.




250     def printPretty(records,num,title='Summary:'):
251 import pdb; pdb.set_trace()
252 if isinstance(records, list):
253 print ("\n{}\n{}".format(title.center(120),"="*120))
254 table = list()
255 for i in records:
...
263 elif isinstance(records, dict):
264 -> for key in records:

265 if isinstance(records[key], Param):
266 for i in records[key]:
267 print (i)
268 print ("")
269
(Pdb) type(records)

(Pdb) type(dict)

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...