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 …
Tag: python
Pausing two Python threads while a third one does stuff (with locks?)
I’m new to concurrent programming. I’d like to execute three tasks repeatedly. The first two should run all the time, the third should run every hour or so. The first two tasks can run in parallel, but I always want to pause them while the third task is running. Here’s the skeleton of what I…
How to maximize a browser window using the Python bindings for Selenium 2-WebDriver?
I wanted to know how to maximize a browser window using the Python bindings for Selenium 2-WebDriver. Answer The trunk version has webdriver.set_window_position(), webdriver.set_window_size() methods:
What scalability issues are associated with NetworkX?
I’m interested in network analysis on large networks with millions of nodes and tens of millions of edges. I want to be able to do things like parse networks from many formats, find connected components, detect communities, and run centrality measures like PageRank. I am attracted to NetworkX because it…
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…
How to add hovering annotations to a plot
I am using matplotlib to make scatter plots. Each point on the scatter plot is associated with a named object. I would like to be able to see the name of an object when I hover my cursor over the point on the scatter plot associated with that object. In particular, it would be nice to be able to quickly
Conditional expressions in sagemath, when defining a symbolic expression
In SageMath, (version 4.7), I do this in the notebook: and this gives no error. However, after that, dens(1, 1) returns 0, dens(1, 0.5) returns 0, and so on! In fact, I found no way to get the answer 2. What am I doing wrong? Answer You’re using the Sage function declaration syntax — f(x,y) = some…
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
How do I disable “missing docstring” warnings at a file-level in Pylint?
Pylint throws errors that some of the files are missing docstrings. I try and add docstrings to each class, method and function, but it seems that Pylint also checks that files should have a docstring at the beginning of them. Can I disable this somehow? I would like to be notified of a docstring is missing i…
Which Python user interface library can I use for 2D games? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 2 years ago. Improve this ques…