Skip to content

Tag: python

isinstance() and issubclass() return conflicting results

How do you explain isinstance(Hello,object) returns True whilst issubclass(Hello,object) returns False? and Answer It’s because you are using old-style classes so it doesn’t derive from object. Try this instead: Old-style classes are deprecated and you shouldn’t use them any more. In Python …

How can I set the aspect ratio in matplotlib?

I’m trying to make a square plot (using imshow), i.e. aspect ratio of 1:1, but I can’t. None of these work: It seems like the calls are just being ignored (a problem I often seem to have with matplotlib). Answer Third times the charm. My guess is that this is a bug and Zhenya’s answer sugges…

python: how to check if a line is an empty line

Trying to figure out how to write an if cycle to check if a line is empty. The file has many strings, and one of these is a blank line to separate from the other statements (not a “”; is a carriage return followed by another carriage return I think) Since I am using the file input module, is there