python

Why am I encountering an ImportError when I try to 're-import' a module?

I have a series of python modules written which are held in the same directory and I am having trouble with an ImportError. The three modules I am using are draw_menu.py, errors.py and file_operations.py. In errors.py I requires a list of error codes, I am using a custom method defined in file_operations.py to open a file containing th...

how to install python on samsung S5600 halley evo

I would know how can i install python on samsung S5600 Halley evo...i have to do something like a jailbreak? it is possible? and, if yes, how? thaks :) ...

storing the output of a cursor object in csv format

i've accessed a database and have the result in a cursor object. but i couldn't save it :( cur_deviceauth.execute('select * from device_auth') for row in cur_deviceauth: print row writer = csv.writer(open("out.csv", "w")) writer.writerows(cur_deviceauth) i don't get an error msg and i couldn't write it. how do i make it?...

TypeError: list objects are unhashable

totalCost = problem.getCostOfActions(self.actions) ...

Term-Topic Matrix for a huge file

Hi, I have a list of 17 million sentences in a text file. Each sentence contains at max 200 characters. Each sentence is also accompanied by one or more annotation(s) with it. I have a list of unique annotations and a list of unique words obtained from the 17 million sentences. I have to create a sparse matrix with the rows as the uniqu...

Iterating over objects in pyquery

I'm scraping a page with Python's pyquery, and I'm kinda confused by the types it returns, and in particular how to iterate over a list of results. If my HTML looks a bit like this: <div class="formwrap">blah blah <h3>Something interesting</h3></div> <div class="formwrap">more rubbish <h3>Something else interesting</h3></div> How do ...

Is there a direct equivalent in Java for Python's str.join?

Possible Duplicates: Whats the best way to build a string of delimited items in Java? Java: convert List<String> to a join()d string In Java, given a collection, getting the iterator and doing a separate case for the first (or last) element and the rest to get a comma separated string seems quite dull, is there something lik...

How to find if there are any differences between two images using Python?

Possible Duplicate: How can I quantify difference between two images? I've used Imagick's convert function to convert a tif-image to png. Using imagick you can compute a new image based on the two to see any difference. Any difference will show up as red dots on a grey/transparent version of the original image. That's all nice...

Parsing Python HTML POST data from BaseHTTPServer

I'm sending a couple of files from an HTML form to my server which is based on BaseHTTPServer. Within my do_POST I'm getting a string from rfile.read(length) which looks like some sort of multipart MIME string. Google is not being helpful on how I can decode this into something usable. The output looks like this : ------------------...

python range occurrence in other range

How can I do something like this: >>> xrange(4, 10) in xrange(3, 20) TRUE ...

Google app engine: reverse reference lookups.

Hi all, Is reverse referencing possible in Google app engine? I am using app engine patch to develope an application and my model is something like: class Portfolio(db.Model): user = db.ReferenceProperty(User) pic = db.BlobProperty() Now, If I have the user object, is it possible to retrieve the pic associated with the users po...

How to specify python interpreter on Windows

My program has been written on python 3.1 (it was the biggest mistake I've ever made). Now I want to use a few modules that were written on 2.6. I know that it's possible to specify the interpreter in Unix #!/usr/bin/python2.6. But what if I use Windows? Does any way to specify the interpreter exist in Windows? Edit: I want to be able ...

Connect GIMP with PHP or Python

Hi all, is there any way to connect GIMP with python or PHP and use its libraries? It seems that all i can find on the web is pygimp which is not supported anymore. ps. i do my development on mac and i use linux as a production server ...

Inserting utf8 characters in DB using Django

In Django how to use unicode when inserting into DB Example: name =request.POST["name"] //This may be in Chinese or any other lanuages usr = Users(name=name) usr.save() The Python version that is used in Cent os is python 2.4.3 and mod python version is 1.2.1_p2-1 ...

How to check submodules in Python with hasattr

At runtime, the Python code gets the name of a submodule to load, which I don't know before. Now, I want to check, if this submodule exists inside an existing module. Consider this structure, where foo and bar can be specified: master/ | |- __init__.py | |- foo/ | | | |- __init__.py | |- bar/ | |- __init__.py Now, usually I do...

python execute remote program

I'm re-writing a legacy Windows application using Python and running on Linux. Initially, the new application needs to call the legacy application so that we have consistent results between customers still using the legacy application and customers using the new application. So I have a Linux box, sitting right next to a Windows box a...

Python Plugin for XCode

Hi everyone ! I'm searching for a Xcode plugin to develop Python applications on Mac OS X platform. Can you give me some links please ? That will be very kind of you. Cordially, Vynile. ...

Basic SSL Server Using Twisted Not Responding

I am currently trying to pull together a basic SSL server in twisted. I pulled the following example right off their website: from twisted.internet import ssl, reactor from twisted.internet.protocol import Factory, Protocol class Echo(Protocol): def dataReceived(self, data): """As soon as any data is received, write it back...

How to create decorator for lazy initialization of a property

I want to create a decorator that works like a property, only it calls the decorated function only once, and on subsequent calls always return the result of the first call. An example: def SomeClass(object): @LazilyInitializedProperty def foo(self): print "Now initializing" return 5 >>> x = SomeClass() >>> x.foo...

lazy event publish subscribe in python

I need an event messaging system in my google app engine application. and i was referring to following python library. http://pubsub.sourceforge.net/apidocs/concepts.html my question is , is it must that the listener function i want to execute must be imported ( or exist otherwise) somewhere in to the execution path in order to run it...