I need to calculate distances between UK postcodes. I don’t want to use a web api. Does a python module/ library exist for this? Or do I have to put together something of my own using data from the OrdnanceSurvey? Thanks, Answer 1/You can use any rest geolocation api eg google maps, that would provide y…
Tag: python
pygame – How to display text with font & color?
Is there a way I can display text on a pygame window using python? I need to display a bunch of live information that updates and would rather not make an image for each character I need. Can I blit text to the screen? Answer Yes. It is possible to draw text in pygame:
How do I determine if current time is within a specified range using Python’s datetime module?
What would be the best way to see if the current time lies between say 10:30 AM and 4:30 PM. I could think of the following, not sure how correct: Please let me know if this the correct approach, can something better be written? Answer My original answer focused very specifically on the question as posed and …
Pytables 2.3.1 with Python 2.5 on Windows: Error – could not find a local hdf5 installation
I’m trying to install PyTables 2.3.1 on Windows XP with Python 2.5. I’m getting the following error: I’m a bit confused by the installation of the HDF5 library. I downloaded the Windows binary called HDF5188-win32-shared.zip from the HDF5 site and ran the .exe file in the zip archive. I now …
Positioning of classes in UML diagram
I’m creating a tool for displaying Python project as an UML diagram (+ displaying some code error detection using GUI). I scan some project using Pyreverse and I have all data I need for drawing UML diagram. The problem is positioning of the class boxes on the canvas. For a start, I decided to use alrea…
How to specify multiple author(s) / email(s) in setup.py
We wrote a small wrapper to a twitter app and published this information to http://pypi.python.org. But setup.py just contained a single field for specifying email / name of the author. How do I specify multiple contributors / email list, to the following fields since we would like this package to be listed u…
Why does python use ‘else’ after for and while loops?
I understand how this construct works: But I don’t understand why else is used as the keyword here, since it suggests the code in question only runs if the for block does not complete, which is the opposite of what it does! No matter how I think about it, my brain can’t progress seamlessly from th…
Delete Characters in Python Printed Line
I’m writing a program where I want the cursor to print letters on the same line, but then delete them as well, as if a person was typing, made a mistake, deleted back to the mistake, and kept typing from there. All I have so far is the ability to write them on the same line: Answer
Why is defaultdict creating an array for my values?
I’m creating a defaultdict from an array of arrays: My expected outcome is: But my outcome is: It is as if defaultdict is trying to keep my values in an array because that is the source list! Anyone know what’s going on here and how I can get my expected outcome? Answer When you call this: It mean…
python numpy split array into unequal subarrays
I am trying to split an array into n parts. Sometimes these parts are of the same size, sometimes they are of a different size. I am trying to use: This works fine when size divides equally into the list, but fails otherwise. Is there a way to do this which will ‘pad’ the final array with the extr…