python

How to implement Django like 'contains' filter query with Google App Engine?

Hi All, Is there some way to implement Django like contains or icontains filters with Google App Engine as well? I am using app engine patch. I have used the below query earlier to match the start of a string but now the requirement is to find a string pattern within Datastore. Employee.all().filter('name >=',value).filter('name <',un...

Python timer countdown

Hi guys, I want to know about timer in Python. Suppose i have a code snippet something like: def abc() print 'Hi' print 'Hello' print 'Hai' And i want to print it every 1 second. Max three times;ie; 1st second i need to check the printf, 2nd second I need to check as well in 3rd second. In my actual code variables value...

how to get final redirected url

i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url. ...

calling class from an external module causes NameError, in IDLE it works fine

i have the following code in a module called code_database.py class Entry(): def enter_data(self): self.title = input('enter a title: ') print('enter the code, press ctrl-d to end: ') self.code = sys.stdin.readlines() self.tags = input('enter tags: ') def save_data(self): with open('entry...

Python Create Byte Array for Web Service Expecting Byte[]

I'm using a SOAP based web service that expects an image element in the form of a 'ByteArray' described in their docs as being of type 'byte[]' - the client I am using is the Python based suds library. Problem is that I am not exactly sure how to represent the ByteArray in for this service - I presume that it should look something like ...

What is best way for interactive debug in python?

I want to utilize introspection capability of python for debugging/development, but cannot find appropriate tool for this. I need to enter into shell (IPython for example) at specific position or at specific event (like exception), with locals and globals of shell being set to the frame's ones. My own quick hack to illustrate it: impo...

pysqlite - how to save images.

Hello, I need to save an image file into sqlite database in python. I could not find a solution. How can I do it? Thanks in advance. ...

Change texture on 3D object and export 2D image

I would like to generate 2D images of 3D books with custom covers on demand. Ideally, I'd like to import a 3D model of a book (created by an artist), change the cover texture to the custom one, and export a bitmap image (jpeg, png, etc...). I'm fairly ignorant about 3D graphics, so I'm not sure if that's possible or feasible, but it des...

Proper use of mutexes in Python

Hello all. I am starting with multi-threads in python(or at least it is possible that my script creates multiple threads). would this algorithm be the right usage of a Mutex? I haven't tested this code yet and it probably won't even work. I just want processData to run in a tread(one at time) and the main while loop to keep running, even...

Using Python with WAMP

I use WAMP for my PHP and MySQL development. I want to start learning Python for use in web development. Is there a way for me to use Python within WAMP? ...

Where and how do I set an environmental variable using mod-wsgi and django?

I'm trying to use this env variable to specify the path for my templates and it will probably be easier to do this using git or svn. ...

Find the field names of inputtable form fields in a PDF document?

Find the field names of inputtable form fields in a PDF document? I have an editable PDF form that I'm trying to automate the entry of form fields into using python. In order to do this I must know the "names" of the form fields in the FDF data to input. See question for background: http://stackoverflow.com/questions/1890570/how-can-i...

Insert binary file in SQLite database with Python

I trying to write a simple Python script that inserts .odt documents into an SQLite database. Here what I have so far, but it doesn't seem to work: f=open('Loremipsum.odt', 'rb') k=f.read() f.close() cursor.execute="INSERT INTO notes (note) VALUES ('%s')" %(sqlite.Binary(k)) cursor.close() conn.close() I don't get any error messages, ...

Remove whitespaces in XML string

How can I remove the whitespaces and line breaks in an XML string in Python 2.6? I tried the following packages: etree: This snippet keeps the original whitespaces: xmlStr = '''<root> <head></head> <content></content> </root>''' xmlElement = xml.etree.ElementTree.XML(xmlStr) xmlStr = xml.etree.ElementTree.tostring(xmlElement, ...

Finding blank regions in image

This question is somewhat language-agnostic, but my tool of choice happens to be a numpy array. What I am doing is taking the difference of two images via PIL: img = ImageChops.difference(img1, img2) And I want to find the rectangular regions that contain changes from one picture to another. Of course there's the built in .getbbox() ...

Sending XHTML over Jabber using xmpppy

I'm trying to send XHTML (a hyperlink) over Jabber (to Google Talk) using xmpppy, but can't find a good working example... I tried with this: http://intertwingly.net/blog/2007/08/09/Sending-XHTML-over-Jabber But didn't work... any ideas?? Thanks in advance! M ...

Determining three in a row in Python 2d array

Hey all- I'm working on a tic-tac-toe game with a M x N board in Python. I'm trying to find an efficient way to determine if a player has won (3 in a row either vertical, horizontal, or diagonal direction.) Most 3x3 implementations of the game just check for all possible winning combinations after each turn. This seems a little extre...

How to add a comma to the end of a list efficiently?

I have a list of horizontal names that is too long to open in excel. It's 90,000 names long. I need to add a comma after each name to put into my program. I tried find/replace but it freezes up my computer and crashes. Is there a clever way I can get a comma at the end of each name? My options to work with are python and excel thanks. ...

Installing a python + django open source project on my server and making it work?

I'm trying to install an open source python + django project: http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone on a server to play with. I'm using mediatemple.net grid-server hosting. I uploaded the files in my html folder but I can't seem to run the program. I'd love to talk this out with someone and figure it out. ...

How to get file the Python logging module is currently logging to?

Is there a way to do this? If logging.config.fileConfig('some.log') is the setter, what's the getter? Just curious if this exists. ...