Skip to content

Tag: python

Python Module for Distance between UK postcodes

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…

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:

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…

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…