find_unbound_port returns a (pseudo-)random unbound port on localhost. import random import socket # range of ports where available ports can be found PORT_RANGE = [33000,60000] def find_unbound_port(): “”" Returns an unbound port number on 127.0.0.1. “”" port = random.randint(*PORT_RANGE) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: sock.bind((“127.0.0.1″, port)) except socket.error: port = get_port() return port if __name__ [...]
The following snippet in the Boto documentation is used to get a list of EC2 regions: import boto.ec2 regions = boto.ec2.regions() Unfortunately when executed this code raises the following error: Traceback (most recent call last): … regions = boto.ec2.regions() File “…/site-packages/boto/ec2/__init__.py”, line 38, in regions c = EC2Connection(**kw_params) File “…/site-packages/boto/ec2/connection.py”, line 80, in __init__ https_connection_factory, [...]
I used Homebrew to install libjpeg and PIL and got the following error: $ python -c “import _imaging” Traceback (most recent call last): File “”, line 1, in ImportError: dlopen(/usr/local/Cellar/python/2.7.1/ \ lib/python2.7/site-packages/PIL/_imaging.so, 2): Library not loaded: \ /usr/local/Cellar/jpeg/8c/lib/libjpeg.8.dylib Referenced from: /usr/local/Cellar/python/2.7.1/ \ lib/python2.7/site-packages/PIL/_imaging.so Reason: Incompatible library version: _imaging.so requires \ version 12.0.0 or later, but [...]
Today is the start of the Python Bug Weekend. In order to dive into it (when time permits) I am trying to prepare tonight. After reading the Beginners Guide to Python Core Development I checked out the latest version of the 3.2 repository: ~/Workspace $ svn co http://svn.python.org/projects/python/branches/py3k ~/Workspace $ cd py3k I built: py3k [...]
This coming weekend Python-dev are organising a bug weekend. We would like to encourage anyone who feels interested in participating to give it a try. Contributing to Python is much less intimidating than it sounds. You don’t need to have previous experience with modifying the Python source; in fact bug days offer a good opportunity [...]