Tuesday, 11 March 2014

Praise Isinstance

Isinstance is ridiculously useful. Despite being somewhat awkward to type (isisntnance?), I find this built-in function to form the backbone of many assignments. Recently, I discovered that isinstance worked with inheritance, allowing a child class to be identified as its parent. This was rather useful in sifting out exceptions and bad inputs for the regex assignment as well as determining whether the inputs were regexes or not. After getting to know how isinstance worked, list comprehensions also became more intuitive as it is one isinstance's natural habitats.
Still need to learn how any() and all() works in recursive structures and how to return multiple values from a list comprehension.

No comments:

Post a Comment