How to install pip for Python 3 on Mac OS X?

UPDATE: This is no longer necessary with Python3.4. It installs pip3 as part of the stock install. I ended up posting this same question on the python mailing list, and got the following answer: # download and install setuptools curl -O https://bootstrap.pypa.io/ez_setup.py python3 ez_setup.py # download and install pip curl -O https://bootstrap.pypa.io/get-pip.py python3 get-pip.py Which … Read more

Why does xml package modify my xml file in Python3?

Note that “xml package” and “the xml library” are ambiguous. There are several XML-related modules in the standard library: https://docs.python.org/3/library/xml.html. Why is it modified? ElementTree moves namespace declarations to the root element, and namespaces that aren’t actually used in the document are removed. Why does ElementTree do this? I don’t know, but perhaps it is … Read more

Why is exponentiation applied right to left?

The ** operator follows normal mathematical conventions; it is right-associative: In the usual computer science jargon, exponentiation in mathematics is right-associative, which means that xyz should be read as x(yz), not (xy)z. In expositions of the BODMAS rules that are careful enough to address this question, the rule is to evaluate the top exponent first. … Read more

Is it possible to change sprite colours in Pygame?

If the image is a “mask” image, with a transparent background and a white (255, 255, 255) mask, then you can “tint” the image with ease. Load the image: image = pygame.image.load(imageName) Generate a uniform colored image with an alpha channel and the same size: colorImage = pygame.Surface(image.get_size()).convert_alpha() colorImage.fill(color) Blend the image with maskImage, by … Read more