python

Function parameters hint Eclipse with PyDev

Seems like newbie's question, but I just can't find the answer. Can I somehow see function parameters hint like in Visual Studio by pressing Ctrl+Shift+Space when cursor is in function call like this: someObj.doSomething("Test", "hello, wold", 4|) where | is my cursor position. Ctrl+Spase shows me that information when I start typing ...

Can I automatically change my PYTHONPATH when activating/deactivating a virtualenv?

I would like to have a different PYTHONPATH from my usual in a particular virtualenv. How do I set this up automatically? I realize that it's possible to hack the bin/activate file, is there a better/more standard way? ...

Joining a set of ordered-integer yielding Python iterators.

Here is a seemingly simple problem: given a list of iterators that yield sequences of integers in ascending order, write a concise generator that yields only the integers that appear in every sequence. After reading a few papers last night, I decided to hack up a completely minimal full text indexer in Python, as seen here (though that ...

automatic keystroke to stay logged in

I have a web based email application that logs me out after 10 minutes of inactivity ("For security reasons"). I would like to write something that either a) imitates a keystroke b) pings an ip or c) some other option every 9 minutes so that I stay logged in. I am on my personal laptop in an office with a door, so I'm not too worried abo...

users module errors in Google App Engine (solved)

UPDATE: It works now! but I didnt change anything actually, seems like Google need time to update its database for app engine. like 20 mins. I want to use user service of my domain in google App, but... Is it possible to solve this problem by my side? Traceback (most recent call last): File "/base/python_lib/versions/1/google/appengi...

Subclassing list

Hello! I want create a DataSet class which is basically a list of samples. But I need to override each insertion operation to the DataSet. Is there any simple way to do this without writing my own append, extend, iadd etc. ? UPDATE: I want to add a backpointer to each sample, holding index of the sample in the DataSet. This is needed ...

What is the most state-of-the-art, pure python, XML parser available?

Considering that I want to write python code that would run on Google App Engine and also inside jython, C-extensions are not an option. Amara was a nice library, but due to its C-extensions, I can't use it for either of these platforms. ...

How to strip color codes used by mIRC users?

I'm writing a IRC bot in Python using irclib and I'm trying to log the messages on certain channels. The issue is that some mIRC users and some Bots write using color codes. Any idea on how i could strip those parts and leave only the clear ascii text message? ...

Is a file on the same filesystem as another file in python?

Is there a simple way of finding out if a file is on the same filesystem as another file? The following command: import shutil shutil.move('filepatha', 'filepathb') will try and rename the file (if it's on the same filesystem), otherwise it will copy it, then unlink. I want to find out before calling this command whether it will pre...

Threads in Java and Python

Hi all, i have few questions about threads in Python and Java... Is it possible to give priorities to Python threads, as it is in Java? How can I kill, stop, suspend and interrupt thread in Python? Thread groups - what are they really for? Does Python support them too? Synchronization - in Java we use simply keyword synchorinized for a...

Testing for mysterious load errors in python/django

This is related to this http://stackoverflow.com/questions/926579/configure-apache-to-recover-from-modpython-errors, although I've since stopped assuming that this has anything to do with mod_python. Essentially, I have a problem that I wasn't able to reproduce consistently and I wanted some feedback on whether the proposed solution see...

Python and reading lines

When i run an .exe file it prints stuff out to the screen. I don't know the specific line of where i want printed out but is there a way I can get python to print the next line after one that says "Summary" ? I know that is in there when it prints and I need the info right after. Thanks! ...

Have csv.reader tell when it is on the last line

Apparently some csv output implementation somewhere truncates field separators from the right on the last row and only the last row in the file when the fields are null. Example input csv, fields 'c' and 'd' are nullable: a|b|c|d 1|2|| 1|2|3|4 3|4|| 2|3 In something like the script below, how can I tell whether I am on the last line ...

gql does not work for get paramters for keys

I am trying to compare the key to filter results in gql in python but the direct comparision nor typecasting to int works. There fore I am forced to make a work around as mentioned in uncommented lines below. Any clues. row = self.request.get("selectedrow") #mydbobject = DbModel.gql("WHERE key=:1", row).fetch(1) #mydbobject = DbModel.gq...

cx_Oracle And User Defined Types

Does anyone know an easier way to work with user defined types in Oracle using cx_Oracle? For example, if I have these two types: CREATE type my_type as object( component varchar2(30) ,key varchar2(100) ,value varchar2(4000)) / CREATE type my_type_tab as table of my_type / And then a procedure in package my_package as follows:...

Opencv sort sequences in python

I'm using the Python OpenCV bindings to find the contours in an Image. I'm know looking for the possibility to sort this sequence. It seems the usual python ways for list sorting don't apply here because of the linked list structure generated from OpenCV. Do you know a good way to sort the Contours by Size (Area/BoundingRectangle) i...

Interfacing web crawler with Django front end

I'm trying to do three things. One: crawl and archive, at least daily, a predefined set of sites. Two: run overnight batch python scripts on this data (text classification). Three: expose a Django based front end to users to let them search the crawled data. I've been playing with Apache Nutch/Lucene but getting it to play nice with ...

Iterating through a multidimensional array in Python

I have created a multidimensional array in Python like this: self.cells = np.empty((r,c),dtype=np.object) Now I want to iterate through all elements of my twodimensional array, and I do not care about the order. How do I achieve this? ...

Django conditional aggregation

Does anyone know of how I would, through the django ORM, produce a query that conditionally aggregated related models? Let's say, for example, that you run a site that sells stuff, and you want to know how much each employee has sold in the last seven days. It's simple enough to do this over all sales: q = Employee.objects.filter(type...

Caching values in Python list comprehensions

I'm using the following list comprehension: resources = [obj.get("file") for obj in iterator if obj.get("file") != None] Is there a way to "cache" the value of obj.get("file") when it's checked in the if statement so that it doesn't have to call get again on obj when it generates the return list? ...