How do I read an image file using Python?
How do I read an image file and decode it using Python? ...
How do I read an image file and decode it using Python? ...
hello. firstly, let me quote a bit an essay from "Expert Python Programming" book: In the following example, a C class that calls its base classes using the _init_ method will make B class be called twice! class A(object): def __init__(self): print "A" super(A, self).__init__() class B(object): def __ini...
I'm debugging a really weird problem with a mod_wsgi-deployed application resulting in Django/Apache (not yet known which) giving status 500 errors to some users instead of the correct 404. I want to exclude Apache from the debugging environment to determine which part of the setup is at fault and send my requests manually to the WSGI ha...
dict1=({"EMP$$1":1,"EMP$$2":2,"EMP$$3":3}) How to check if EMP exists in the dictionary using python dict1.get("EMP##") ?? ...
Hi, I have a string like this "yJdz:jkj8h:jkhd::hjkjh" I want to split it using colon as a separator, but not a double colon. Desired result: ("yJdz", "jkj8h", "jkhd::hjkjh") I'm trying with: re.split(":{1}", "yJdz:jkj8h:jkhd::hjkjh") but I got a wrong result. In the meanwhile I'm escaping "::", with string.replace("::", "$$") ...
How to use any SQL database eg. mysql, pgsql or other except the ones Python has built-in support for? def example(): con= Mysql("root", blablabla) con->query("SELECT * bla bla bla") .... ...
We are using trac. In our setup we have a problem that is solved in repository. So I got the fixed file commit_update.py from the repository and I need to place it into Trac-0.12-py2.6.egg. As egg is just a ziped filed I just unziped it, changed the file and ziped again. After restarting trac, I've got a an error message: ExtractionErr...
Django 1.1.2 & Python 2.6.5 I keep getting this error when executing a seemingly innocent queryset. Looks exactly like the issue described in http://code.djangoproject.com/ticket/7204 However, I'm running Django 1.1.2, which is supposed to have the fix for this bug. Has anybody dealt with something similar before? Here's the code that...
Is there a way to tell pylint that it must show warning message when it see user-defined deprecation warning? I've tried warnings.warn, DeprecationWarning - but pylint ignores them. ...
One of the modules I import into my python project triggers lots of warnings under Pychecker. Fixing up this external module isn't really an option, so I want to tell Pychecker to ignore it. Does anyone know how to do this? I'm sure it's possible, and probably quite simple, but after trawling Google for a while I've not found any docume...
How to config a cron job to run every 5 minutes between 9:00am~20:00pm, but every 10 minutes in other time of the day. ...
Is it possible that CherryPy, in its default configuration, is caching the responses to one or more of my request handlers? And, if so, how do I turn that off? ...
Given an object A, which contains a callable object B, is there a way to determine "A" from inside B.__call__()? This is for use in test injection, where A.B is originally a method. The code is something like this: # Class to be tested. class Outer(object): def __init__(self, arg): self.arg = arg def func(self, *args, **kwargs...
I am using Fabric to run commands on a remote server. The user with which I connect on that server has some sudo privileges, and does not require a password to use these privileges. When SSH'ing into the server, I can run sudo blah and the command executes without prompting for a password. When I try to run the same command via Fabric's ...
I would like to have a GtkTextView in my (Python) program which shows text with the system monospace font. I found many ways which use an expicit font family name and size. However, I would like to use the system specified monospace font (e.g. from the ubuntu font preferences panel). My program should be able to run on Windows as well a...
Hello Guys, I have a form with a ModelMultipleChoiceField to list of categories. I would like to group categories using the Category.group field. I thought that by changing the field.choices in the init function it will make the trick class CategoriesField(forms.ModelMultipleChoiceField): def __init__(self, queryset, **kwargs): ...
I am using Cherrypy in a RESTful web service and server returns XML as a result (lxml is being used to create XML). Some of those XMLs are quite large. I have noticed that memory is not being released after such request (that return large XML) has been processed. So, I have isolated a problem and created this one very short dummy examp...
I am using Eclipse as a Python IDE. Is there anyway for me to Debug my program and break to an interactive prompt. I am interested in exploring the existing data and running/testing commands. I believe there has to be a way, but I am so used to compiling languages that I have not been able to find where the options are. Any ideas? ...
Hi, I have the following "consumer" code: .... while 1: time.sleep(self.sleeptime) cond.acquire() #acquire the lock print currentThread(), "lock acquired" while itemq.isEmpty(): cond.wait() itemq.consume() print currentThread(),"Consumed One Item" cond.rel...
I'm using the xmpppy library to write an XMPP client that can chat with users. It has its own XMPP user account and needs to know if a given user is online. However, the documentation is a bit sparse on how to do this. What would you recommend? The only solution I've seen thus far is to start up a daemon before the XMPP server starts an...