python

Best way of sharing/managing our internal python library between applications

Our company (xyz) is moving a lot of our Flash code to Python. In Flash, we have a shared library between our Flash apps - package xyz. We can make changes to the package without fear of breaking other apps when they are deployed because Flash compiles their code and includes the contents of the library. We deploy the final SWF via RPM,...

Python logging in Django

I'm developing a Django app, and I'm trying to use Python's logging module for error/trace logging. Ideally I'd like to have different loggers configured for different areas of the site. So far I've got all of this working, but one thing has me scratching my head. I have the root logger going to sys.stderr, and I have configured anoth...

Best way to import version-specific python modules.

Which method makes the most sense for importing a module in python that is version specific? My use case is that I'm writing code that will be deployed into a python 2.3 environment and in a few months be upgraded to python 2.5. This: if sys.version_info[:2] >= (2, 5): from string import Template else: from our.compat.string imp...

Python 2.6 multiprocessing.Queue compatible with threads?

I am experimenting with the new multiprocessing module in Python 2.6. I am creating several processes each with its own multiprocessor.JoinableQueue instance. Each process spawns one or more worker threads (subclasses of threading.Thread) which share the JoinableQueue instance (passed in through each Thread's __init__ method). It seem...

Learning the WIN32 API

I have very little experience building software for windows, and zero experience using the windows API, is there a good (preferably online), free resource to learn how to use the windows API(preferably with python)? ...

Problem regarding 3.0's "hashlib" module

I've been working on getting a 2.5 module ported to 3.0, mostly for my own education, when I've gotten stuck. The class "Builder" has as its init: def __init__(self, **options): self._verifyOptions(options) self._options = options self._initDigest() self._initBuildNames() self._methods = [] But the error occurs a...

What happened to the python bindings for CGAL?

I found the Computational Geometry Algorithms Library in my search for an algorithm to decompose a concave polygon into the minimum number of convex components. Links off the site and numerous google results indicate there are python bindings for it, which would be really handy, but all the links are dead! What happened to it? Where c...

What can Pygame do in terms of graphics that wxPython can't ?

Hello, I want to develop a very simple 2D game in Python. Pygame is the most popular library for game development in Python, but I'm already quite familiar with wxPython and feel comfortable using it. I've even written a Tetris clone in it, and it was pretty smooth. I wonder, what does Pygame offer in terms of graphics (leaving sound a...

How do I work with multiple git branches of a python module?

I want to use git to allow me to work on several features in a module I'm writing concurrently. I'm currently using SVN, with only one workspace, so I just have the workspace on my PYTHONPATH. I'm realizing this is less than ideal, so I was wondering if anyone could suggest a more 'proper' way of doing this. Let me elaborate with a hypo...

How do I submit a form given only the HTML source?

I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly; Uses only standard Python library and Django. Allows para...

How to use InterWiki links in moinmoin?

We use a number of diffrent web services in our company, wiki(moinmoin), bugtracker (internally), requestracker (customer connection), subversion. Is there a way to parse the wikipages so that if I write "... in Bug1234 you could ..." Bug1234 woud be renderd as a link to http://mybugtracker/bug1234 ...

How to convert from UTM to LatLng in python or Javascript

I have a bunch of files with coordinates in UTM form. For each coordinate I have easting, northing and zone. I need to convert this to LatLng for use with Google Map API to show the information in a map. I have found some online calculators that does this, but no actual code or libraries. http://trac.osgeo.org/proj4js/ is a projection l...

Notification Library for Windows

I'm developing a small tray-icon application for Windows and I need to display non-intrusive visual notifications similar to those that appear when you receive a new message in MSN Messenger or any other IM application. I have looked at Snarl, but it seems to be a separate application that I need to install. I want something that could ...

What is the most efficient way of extracting information from a large number of xml files in python?

Hi, I have a directory full (~103, 104) of XML files from which I need to extract the contents of several fields. I've tested different xml parsers, and since I don't need to validate the contents (expensive) I was thinking of simply using xml.parsers.expat (the fastest one) to go through the files, one by one to extract the data. I...

Having problem importing the PIL image library

Hi, i am trying to do something with the PIL Image library in django, but i experience some problems. I do like this: import Image And then I do like this images = map(Image.open, glob.glob(os.path.join(dirpath, '*.thumb.jpg'))) But when i try to run this i get an error and it leeds me to think that its not imported correctly, a...

Looking for input in model design for Django Schools

Today I'm starting a little project to create a Django based school administration program. I'm currently designing the models and their corresponding relationships. Being rather new to Django and relational databases in general, I would like some input. Before I show you the current model layout, you need to have an idea of what the pr...

Python Version for a Newbie

I am extremely new to python, having started to learn it less than a month ago, but experienced with some other programming languages (primarily C# and SQL). But now that Python 3.0 has been released and is not backwards compatible, what would be the advantages and disadvantages of deciding to focus on Python 3.0 or Python 2.6? ...

Why doesn't Python 2.6 have set literals and comprehensions or dict comprehensions?

Python 2.6 was basically a stepping stone to make converting to Python 3 easier. A lot of the features destined for Python 3 were implemented in 2.6 if they didn't break backward compatibility with syntax and the class libs. Why weren't set literals ({1, 2, 3}), set comprehensions ({v for v in l}), or dict comprehensions ({k: v for k, ...

Is this idiom pythonic? (someBool and "True Result" or "False Result")

I just came across this idiom in some open-source Python, and I choked on my drink. Rather than: if isUp: return "Up" else: return "Down" or even: return "Up" if isUp else "Down" the code read: return isUp and "Up" or "Down" I can see this is the same result, but is this a typical idiom in Python? If so, is it some perf...

Refactoring python module configuration to avoid relative imports.

This is related to a previous question of mine. I understand how to store and read configuration files. There are choices such as ConfigParser and ConfigObj. Consider this structure for a hypothetical 'eggs' module: eggs/ common/ __init__.py config.py foo/ __init__.py a.py 'eggs.foo.a' needs some configuration i...