3 ms·
Would this still fail if you used the preferred idiom of isinstance(x, Foo)
by nerdponx 7y ago
Would this still fail if you used the preferred idiom of
isinstance(x, Foo)
- uryga 7y agohad to check to make sure isinstance wasn't doing some magic, but yes. the whole issue is that as far as python is concerned, the pre- and post-reload Foo classes aren't related in any way except by name and module, which aren't checked by either of these methods (aside: i know that `isinstance` is the official way, but i just don't like the way it reads – "x is an instance of y" is an infix construct and looks weird in a prefix position. i don't really use inheritance so `type(x) is y` is good enough, and it reads very naturally)