python

Python Image Directories

Using PIL in python one must put the full directory for an image, so that the program runs properly. Is there any way to make that directory variable? So that it gets the programs current directory then looks for the images in that same folder? This is in Windows 7 BTW. ...

Two Tkinter Images...

I have written a simple GUI in Python using the Tkinter library. This GUI has to display 2 images, one on top and one on the bottom. When I place the two images on the window, there seems to be a white line between the two. How to I place them so this doesn't show up? I am programming on Windows 7 with Python 2.6 ...

how do i generate a valid upc?

does anyone know if it is possible to generate a valid upc? if so, how? is it possible to do it in excel / python / .net? the platform does not matter to me ...

My implementation of Bresenham's algorithm fails for lines at certain angles.

I've written an implementation of Bresenham's algorithm in Python (following the Wikipedia article), and it works correctly except for lines at certain angles. All lines that should extend between 45 and 90 degrees, or between 135 and 270 degrees, will instead extend along the line y = x. Here's my code: def bresenham(origin, dest):...

Handling file reading and multiple values to a key in dictionary

How can I code to read the first line from a file and put it as a key value of a dictionary and keep reading next values in a iterative manner and put them as the values to the particular key they fall into in the file. Like example: Item Quality Cost Place Ball 1 $12 TX Umbrella 5 $35 NY sweater 89 ...

What to use for Python string.find?

The documentation for Python 2.7 lists string.find as a deprecated function but does not (unlike atoi and atol) provide an alternative. I'm coding in 2.7 at the moment so I'm happy to use it but I would like to know: what is it going to be replaced with? is that usable in 2.7 (if so, I'll use it now so as to avoid recoding later)? ...

Packaging python applications with PyQt and PyQwt (for linux only)

This is a follow on from my question here, I think I will have to look at a different method. I'm wanting to package my python program with some of it's dependencies. I'm aware of tools like cx freeze or bb freeze, but as you can see in the linked question they have issues for my situation. I don't want my users to have to install my ...

can a django application be run using paster?

can a django application be run using paster? Or is it pylons specific? ...

Do I have to manually create the combined folder when using Python's Minimatic module?

Hi, I'm using the Python library Minimatic found at this site: Minimatic What this essentially does is it minifies and combines all your css and js files into one file. When deploying my Pylons web application on the server, does this mean I have to manually create the combined folders? So if I have the the directory as such: /publ...

Python Torrent Library

Does anyone know of an existing python library that I can use for working with / downloading torrent files? I am working with a project where I need to download torrent files, and I would like to not have to implement the specification myself if there is something out there that would make it easier. ...

Python, trying to instantiate class imported using __import__, getting ''module' object is not callable'

I've been researching how to do this and I can't figure out what I am doing wrong, I want to use import to import a class and then instantiate it and am doing it as so: the class, from a file called "action_1", I have already imported / appended the path to this) class Action_1 (): def __init__ (self): pass how I am tryin...

Python: safe to read values from an object in a thread?

I have a Python/wxPython program where the GUI is the main thread and I use another thread to load data from a file. Sometimes the files are big and slow to load so I use a wxPulse dialog to indicate progress. As I load the file, I count the number of lines that have been read in the counting thread, and I display this count in the wxP...

best way to setup a webhook to restart apache for a django server

I first tried to use django and then django-webhooks to call a shell script that restarts the server. This didn't work, because the webpage hangs when the server restart is called, as django is reloaded. Then I used fastcgi and python alone to create a URL that calls the shell script. I know the python script works when I run it on the...

Google app engine or query (python)

Can anyone share your approach for doing a 'or' query in app-engine? Let say I have class A_db_model(db.Model): valueA = db.ListProperty(basestring) in valueA I have aaa aaa, bbb bbb ccc I would like to return result of if the valueA match 'aaa' or 'bbb' and return not duplicated result. ...

Is there a way to compare two list of dicts in python?

I have a 2 list of dictionaries. The first list contains sphere definitions in terms of x, y, z, radius. The second list contains various points in space as x, y, z. These lists are both very long, so iterating over each list and compare against all values is inefficient. I've been trying the map and reduce terms, but both of them take...

Is it possible to code images into a python script?

Instead of using directories to reference an image, is it possible to code an image into the program directly? ...

wxPython: Assigning text labels to ticks on a slider

Hi, A wxPython program that I'm writing uses two sliders as part of the GUI. These sliders represent a three state switch with the states "On Full", "On Medium" and "Off". I'd like to be able to assign these labels to the ticks on the slider. Is there a way of doing this without having to subclass or position separate static text contro...

openid in pylons (not using authkit)

Hey all, So I'm trying to authenticate users on a Pylons web application using openid. I don't want to use authkit, seeing as it is no longer maintained. I'm currently trying to use python-openid (available from git at http://github.com/openid/python-openid) and having a hard time with it. The pylons framework isn't making it easy for ...

Is there a limitation on the number of tables a PostgreSQL database can have?

I have created a database in PostgreSQL, let's call it testdb. I have a generic set of tables inside this database, xxx_table_one, xxx_table_two and xxx_table_three. Now, I have Python code where I want to dynamically create and remove "sets" of these 3 tables to my database with a unique identifier in the table name distinguishing dif...

Encoding an image file with base64

I want to encode an image into a string using the base64 module. I've ran into a problem though. How do I specify the image I want to be encoded? I tried using the directory to the image, but that simply leads to the directory being encoded. I want the actual image file to be encoded. EDIT I tired this snippet: with open("C:\Python...