python

Find the largest image dimensions from list of images

I have a list (the paths) of images saved locally. How can I find the largest image from these? I'm not referring to the file size but the dimensions. All the images are in common web-compatible formats — JPG, GIF, PNG, etc. Thank you. ...

Issue with Django Inline form

I have attached TestInline in the FoobarAdmin, this thing works well but i want logged in user to be pre-populated for the added_by field from django.contrib import admin from django.contrib.auth.models import User class Test(models.Model): description = models.TextField() added_on = models.DateTimeField(auto_now_add=True) ...

python Ctype : problem with callback in making python custom library

The whole scenario is like this: there is a function setmessagelistener(a_structure,function_pointer) in my c library. i am writing a python library which is a wrapper on above mentioned c library using Ctypes. so what i did is something like this: def setlistener(a_structure,function_pointer) listenerDeclaration = CFUNCTYPE(c_void...

How to generate unique 64 bits integers from Python?

I need to generate unique 64 bits integers from Python. I've checked out the UUID module. But the UUID it generates are 128 bits integers. So that wouldn't work. Do you know of any way to generate 64 bits unique integers within Python? Thanks. ...

Python Dbus : SystemBus and SesssionBus mainloops

Hello, I need to run SystemBus and SessionBus mainloops in my python application. So I would like to ask what is the best way to do this ? To run SystemBus mainloop in application's main thread and SessionBus mainloop in another ? Regards, Levon ...

Multi processing subprocess

i am new to subprocess module of python, currently my implementation is not multi processed. import subprocess,shlex def forcedParsing(fname): cmd = 'strings "%s"' % (fname) #print cmd args= shlex.split(cmd) try: sp = subprocess.Popen( args, shell = False, stdout = subprocess.PIPE, stderr...

how to maintain mail conversion (reply / forward / reply to all like gmail) of email using python pop/imap lib?

I've develop webmail client for any mail server, I want to implement message conversion for it, for example same emails fwd/reply/reply2all should be shown together like gmail does... my question is whats the key to find those emails which are either reply/fwd or related to the original mail.... ...

Sorted quantile mean via Rpy

The real goal here is to find the quantile means (or sums, or median, etc.) in Python. Since I'm not a power user of Python but have used R for a while, my chosen route is via Rpy. However, I ran into the problem that the returned list of means are not correspondent to the order of the quantiles. In particular, I have the followings in R...

Plotting a list of Complex nos on Z-plane in python

I tried: plot(z) where z is a list of complex numbers, which plots abs(z) versus index. plot( z.real, z.imag ) doesn't work, it says list doesn't have attribute real. ...

Python auth_handler not working for me

I've been reading about Python's urllib2's ability to open and read directories that are password protected, but even after looking at examples in the docs, and here on StackOverflow, I can't get my script to work. import urllib2 # Create an OpenerDirector with support for Basic HTTP Authentication... auth_handler = urllib2.HTTPBasicAut...

Retrive multiple urls at once/in parallel

I have a python script that download web page, parse it and return some value from the page. I need to scrape a few such pages for getting the final result. Every page retrieve takes long time (5-10s) and I'd prefer to make requests in parallel to decrease wait time. The question is - which mechanism will do it quick, correctly and with ...

Upload data to BlobStore using remote api

Is it possible to upload blob to blobstore using remote API (not the standard upload scheme)? I want to write backup/restore script for my application and blobstore is the only thing that doesn't work. ...

Python dictionary reference to neighbor dictionary element

Hello! I'm trying to create something following: dictionary = { 'key1': ['val1','val2'], 'key2': @key1 } where @key1 is reference to dictionary['key1']. Thank You in advance. ...

How to refer to "\" sign in python string

I have problem with refering to special symbol in string: I have: path='C:\dir\dir1\dir2\filename.doc' and I want filename. When I try: filename=path[path.rfind("\"):-4] then interpreter says it's an error line right from "\" since is treated as a comment. ...

Suds Performance - client.factory.create() takes more than 2 minutes

I'm using Suds to send/receive SOAP messages in Python. It is taking an insanely long time to create an object to send via the soap envelope. client = Client(wsdldict['Contact'], faults=True, headers=session) #takes ~5 seconds lq1=client.factory.create("ns1:ListOfContactQuery") #takes ~130 seconds The WSDL file is fairly large (1MB) ...

Most optimal way to reverse search list of similar strings

I have a list of data that includes both command strings as well as the alphabet, upper and lowercase, totaling to 512+ (including sub-lists) strings. I want to parse the input data, but i cant think of any way to do it properly other than starting from the largest possible command size and cutting it down until i find a command that is ...

Python: Unpack from hex to double

Python: Unpack from hex to double This is the value value = ['\x7f', '\x15', '\xb7', '\xdb', '5', '\x03', '\xc0', '@'] I tried unpack('d', value) but he needs a string for unpacking. It is a list now. But when I change it to a string, the length will change from 8 to 58. But a double needs a value of the length 8. ...

What’s a good Python profanity filter library?

Like http://stackoverflow.com/questions/1521646/best-profanity-filter, but for Python — and I’m looking for libraries I can run and control myself locally, as opposed to web services. (And whilst it’s always great to hear your fundamental objections of principle to profanity filtering, I’m not specifically looking for them here. I know ...

Which Dynamic Internationalisation system to use in Django projects?

Hey, I am developing a new project from scratch with Django. I see that there are many apps for handling translation of dynamic content. Django-multilingual Django-pluggable-model-i18n Django-modeltranslation Transdb Django-multilingual-model- Django-transmeta to name few. Transdb, transmeta and multilingual sounded fair, but I wa...

SelfReferenceProperty question

I am trying to use google appengine. I have this model: def Human(db.Model): name = db.StringProperty() friends = db.SelfReferenceProperty() This Human has more than one friend. So, how to handle this with google appengine? ...