python

How do I programmatically check whether a GIF image is animated?

Here is a link to another question I asked concerning the same project I am working on. I think that bit of background will be helpful. For those that are too lazy to open a new tab to that question, I'll summarize what I'm trying to do here: I've downloaded about 250,000 images from 4scrape and I want to go through the GIFs and find w...

Python Warning control

I would like some kind of warning to be raisen as errors, but only the first occurrence. How to do that? I read http://docs.python.org/library/warnings.html and I dont know how to combine this two types of behaviour. ...

bulkloader: key ordering issue with --dump

After creating a patch to resolve this issue, I am now experiencing this when attempting to dump my data: [ERROR ] [Thread-2] ExportProgressThread: Traceback (most recent call last): File "/Users/matthew/local/opt/google_appengine/google/appengine/tools/bulkloader.py", line 1375, in run self.PerformWork() File "/Users/matthew/...

iTunes COM - How to acess Lyrics

Hi. I have been messing around with iTunes COM from python. However, I haven't been able to access the Lyrics of any track. I have been using python for this. Here is the code: >>> import win32com.client >>> itunes = win32com.client.Dispatch("iTunes.Application") >>> lib = itunes.LibraryPlaylist >>> tracks = lib.Tracks >>> tracks <win...

PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Decimal

This is the error I got today at filmaster.com: PicklingError: Can't pickle : it's not the same object as decimal.Decimal What does that exactly mean? It does not seem to be making a lot of sense... It seems to be connected with django caching. You can see the whole traceback here: Traceback (most recent call last): Fil...

python mysql fetch query

def dispcar ( self, reg ): print ("The car information for '%s' is: "), (reg) numrows = int(self.dbc.rowcount) #get the count of total rows self.dbc.execute("select * from car where reg='%s'") %(reg) for x in range(0, numrows): car_info = self.dbc.fetchone() print row[0], "-->", row[1] the ab...

Sorting by a field of another table referenced by a foreign key in SQLObject

Is it possible to sort results returned by SQLObject by a value of another table? I have two tables: class Foo(SQLObject): bar = ForeignKey('Bar') class Bar(SQLObject): name = StringCol() foos = MultipleJoin('Foo') I'd like to get foos sorted by the name of a bar they are related to. Doing: foos...

Showing an image from console in Python

What is the easiest way to show a .jpg or .gif image from Python console? I've got a Python console program that is checking a data set which contains links to images stored locally. How should I write the script so that it would display images pop-up graphical windows? ...

Python with matplotlib - reusing drawing functions

I have a follow up question to this question. Is it possible to streamline the figure generation by having multiple python scripts that work on different parts of the figure? For example, if I have the following functions: FunctionA: Draw a histogram of something FunctionB: Draw a box with a text in it FunctionC: Draw a plot ...

Python Unicode and MIMEE

Hi Guys, Can someone who is way smarter than I tell me what I'm doing wrong.. Shouldn't this simply process... # encoding: utf-8 from email.MIMEText import MIMEText msg = MIMEText("hi") msg.set_charset('utf-8') print msg.as_string() a = 'Ho\xcc\x82tel Ste\xcc\x81phane ' b = unicode(a, "utf-8") print b msg = MIMEText(b) msg.set_cha...

python serialize string

I am needing to unserialize a string into an array in python just like php and then serialize it back. ...

Expected LP_c_double instance instead of c_double_Array - python ctypes error

Hi all! I have a function in a DLL that I have to wrap with python code. The function is expecting a pointer to an array of doubles. This is the error I'm getting: Traceback (most recent call last): File "C:\....\.FROGmoduleTEST.py", line 243, in <module> FROGPCGPMonitorDLL.ReturnPulse(ptrpulse, ptrtdl, ptrtdP,ptrfdl,ptrfdP) Argu...

Python - Basic pygame structure

Here is how I'm implementing my simple pygames now (I'm following a tutorial): import pygame, sys from pygame.locals import * def run_game(): pygame.init() SIZE = (640, 400) BG_COLOUR = (0, 0, 0) LINE_COLOUR = (255, 255, 255) screen = pygame.display.set_mode(SIZE) clock = pygame.time.Clock() while True: ...

help with python forking child server for doing ajax push, long polling

Alright, I only know some basic python but if I can get help with this then I am considering making it open source. What I am trying to do: - (Done) Ajax send for init content - Python server recv command "init" to send most recent content - (Done) Ajax recv content and then immediately calls back to python server - Python server recv c...

Django not sending emails to admins

According to the documentation, if DEBUG is set to False and something is provided under the ADMINS setting, Django will send an email whenever the code raises a 500 status code. I have the email settings filled out properly (as I can use send_mail fine) but whenever I intentionally put up erroneous code I get my 500.html template but no...

Should I use pgreloaded? Or subversion of pygame?

I'm using pygame with python 2.6 right now, But I want to use python 3.1.1 instead. The normal pygame only works with 2.x, but the subversion ones work with 3.x I think. But what about pgreloaded? Is that useable yet? The normal pygame actually works with 3.1 too, but not for os x (at least there isn't a download). Does anyone actually u...

Local functions in Python

In the following Python code, I get an UnboundLocalError. As I understand it, local functions share the local variables of the containing function, but this hardly seems to be the case here. I recognise that a is an immutable value in this context, but that should not be a problem. def outer(): a = 0 def inner(): a += 1 ...

Python recursive program to prime factorize a number

I wrote the following program to prime factorize a number: import math def prime_factorize(x,li=[]): until = int(math.sqrt(x))+1 for i in xrange(2,until): if not x%i: li.append(i) break else: #This else belongs to for li.append(x) print li #First print state...

PyObjC development with Xcode 3.2

Xcode 3.2 has removed the default templates for the scripting languages (Ruby, Python etc). How do I find these templates to use in Xcode 3.2? Would I need to add anything else to Xcode to support working with and 'building' PyObjC programs? Additionally, is there any documentation and/or resources that would help me get into PyObjC (an...

Prompt on exit in PyQt application

Hi. Is there any way to promt user to exit the gui-program written in Python? Something like "Are you sure you want to exit the program?" I'm using PyQt. ...