python

how to fetch reference property in django template

I am using aep on google app engine class Link(): bag = db.Referencepropery(Bag) #bag have name, id and other property name = db.Stringpropery object_query = Link.all(); p = paginator( object_query) object_list = p.page(1); prefetch_references( object_list.object_list, 'bag') render_to_response(...,{'object_list':object_li...

Using UTM with geodjango

I'm looking into using the UTM coordinate system with geodjango. And I can't figure out how to get the data in properly. I've been browsing the documentation and it seems that the "GEOSGeometry(geo_input, srid=None)" or "OGRGeometry" could be used with an EWKT, but I can't figure out how to format the data. It looks like the UTM SRID i...

Python multiprocessing for bulk file/conversion operation on Windows

I have written a python script which watches a directory for new subdirectories, and then acts on each subdirectory in a loop. We have an external process which creates these subdirectories. Inside each subdirectory is a text file and a number of images. There is one record (line) in the text file for each image. For each subdirector...

How to determine whether java is installed on a system through python?

Hi, i needed to run a jar file from python code,but before running that file i want to know whether java is installed on the system or not, using the python code itself.Please help thanks ...

Overloading failUnlessEqual in unittest.TestCase

Hi, I want to overload failUnlessEqual in unittest.TestCase so I created a new TestCase class: import unittest class MyTestCase(unittest.TestCase): def failUnlessEqual(self, first, second, msg=None): if msg: msg += ' Expected: %r - Received %r' % (first, second) unittest.TestCase.failUnlessEqual(self, f...

How can I access the iphone / ipod clipboard using python?

Hello, I want to modify a python application written for the ipod/iphone. It should copy a string into the clipboard so that I can use it in another application. Is it possible to access the iphone clipboard using python? Thanks in advance. UPDATE: Thanks for replying. A bit of background: The python program is a vocabulary program ru...

How to remotely restart a service on a password protected machine using Python?

Hi, I decided to tackle Python as a new language to learn. The first thing I want to do is code a script that will allow me to remotely restart services on other machines from my local machine. How would I accomplish this when the remote machine requires a username and password to log on? I don't need a full solution to be given to me b...

Renaming a HTML file with Python

A bit of background: When I save a web page from e.g. IE8 as "webpage, complete", the images and such that the page contains are placed in a subfolder with the postfix "_files". This convention allows Windows to synchronize the .htm file and the accompanying folder. Now, in order to keep the synchronization intact, when I rename the HTM...

Any libraries/modules for file management in python?

Hi All, Trying to find out if there any good modules which allow constant monitoring of a directory and as soon as a new file is in there, a number of functions are intiated? Also actions should not be done on partly transfered files which are coming in via FTP. ...

Tick Python instances from Python

I am interrested in doing a programming game using python, and I would like to do it in the style of GunTactyx (http://apocalyx.sourceforge.net/guntactyx/index.php). Only much simpler, as I am primarily interrested in the parallel execution of python scripts from python. Gun Tactyx challenges the player to write a program that controls ...

Problem passing bash output to a python script

I'm fairly new to programming and I searched the internet for a way to pass bash output to a Python script. I came up with this in bash. XAS_SVN=`svn info` ssh hudson@test "python/runtests.py $XAS_SVN" And this in python. import sys print sys.argv[1] When I echo $SVN_INFO I get the result. Path: . URL: //svn/rnd-projects/te...

Python Critique

Hi, I'm using Python now for about two months, and to be honest, it really made me love programming again. After programming in C, Java, and worst of all, C++, Python is incredibly fun. Thinking that I approach such language with all positive bias, I would love to hear some critique of Python language. Beside its extremely rich library,...

Python: Set with only existance check?

I have a set of lots of big long strings that I want to do existence lookups for. I don't need the whole string ever to be saved. As far as i can tell, the set() actually stored the string which is eating up a lot of my memory. Does such a data structure exist? done = hash_only_set() while len(queue) > 0 : item = queue.pop() if i...

Delete None values from Python dict

Newbie to Python, so this may seem silly. I have two dict: default = {'a': 'alpha', 'b': 'beta', 'g': 'Gamma'} user = {'a': 'NewAlpha', 'b': None} I need to update my defaults with the values that exist in user. But only for those that have a value not equal to None. So I need to get back a new dict: result = {'a': 'NewAlpha', 'b'...

Python design patterns, cross importing

I am using Python for automating a complex procedure that has few options. I want to have the following structure in python. - One "flow-class" containing the flow - One helper class that contains a lot of "black boxes" (functions that do not often get changed). 99% of the time, I modify things in the flow-class so I only want code ther...

How can I mass-assign SA ORM object attributes?

Hello there, I have an ORM mapped object, that I want to update. I have all attributes validated and secured in a dictionary (keyword arguments). Now I would like to update all object attributes as in the dictionary. for k,v in kw.items(): setattr(myobject, k, v) doesnt work (AttributeError Exception), thrown from SQLAlchemy. my...

How to change baseclass

I have a class which is derived from a base class, and have many many lines of code e.g. class AutoComplete(TextCtrl): ..... What I want to do is change the baseclass so that it works like class AutoComplete(PriceCtrl): ..... I have use for both type of AutoCompletes and may be would like to add more base classes, so how c...

Aggregate photos from various services into one Stream

Helllo All, I'm looking to aggregate photos from various streams into one stream in a similar manner as to friend feed. I'd like to be able to watch flickr and picasa and other sites with RSS feeds of my choosing and then create a timeline of top photos. For example, assume that X's below are photos: Event Name -- March 15th X ...

AttributeError: 'NoneType' object has no attribute 'GetDataStore'

I guys, I developing a utility in python and i have 2 object the main class and an database helper for get sqlserver data. database.py import _mssql class sqlserver(object): global _host, _userid, _pwd, _db def __new__ (self, host, userid, pwd, database): _host = host _userid = userid _pwd = pwd ...

percentage difference between two text files

I know that I can use cmp, diff, etc to compare two files, but what I am looking for is a utility that gives me percentage difference between two files. if there is no such utility, any algorithm would do fine too. I have read about fuzzy programming, but I have not quite understand it. ...