Monday, December 3, 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

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...