python

sqlalchemy Oracle REF CURSOR

Hi I am using sqlalchemy for connection pooling only (need to call existing procs) and want to return a REF CURSOR which is an out parameter. There seems to be no cursor in sqlalchemy to do this. Any advice greatly appreciated. ...

How do I run two python loops concurrently?

Suppose I have the following in Python # A loop for i in range(10000): Do Task A # B loop for i in range(10000): Do Task B How do I run these loops simultaneously in Python? ...

In django 1.2.1 how can I get something like the old .as_sql?

In past versions of django you could construct a queryset and then do .as_sql() on it to find out the final query. in Django 1.2.1 there is a function ._as_sql() which returns something similar, but not the same. In past versions: qs=Model.objects.all() qs.as_sql() ====> SELECT `model_table.id`, `model_table.name`, `model_table.size`...

Python: traverse tree adding html list (ul)

Hello, I have this python code that will traverse a tree structure. I am trying to add ul and li tags to the function but I am not very succesful. I though I was able to keep the code clean without to many conditionals but now I ain't so sure anymore. def findNodes(nodes): def traverse(ns): for child in ns: tra...

Parse HTML-like metalanguage with Regular Expressions (Python)

Hi! I want to parse html tags manually with Regular Expressions. I see next problems: sting with tags: <h1 title="<this not a tag>">...</h1> - how to parse correct this tag, if in string parameter appear tags? tag can be incorrect like this: <h1 title="not closed string> or this <h1 title=not opened string"> - this tag also should be...

Get a count for a pattern using python

In the following how to count the number of times that __TEXT__ appears in the variable sing python a="This is __TEXT__ message to test __TEXT__ message" ...

Is it possible to combine annotations with defer/only in django 1.2.1?

I have two simple models: Book, and Author Each Book has one Author, linked through a foreignkey. Things work normally until I try to use defer/only on an annotation: authors=Author.objects.all().annotate(bookcount=Count('books')) that works. The query looks like: select table_author.name, table_author.birthday, COUNT(table_book.i...

How do I Handle Database changes and port my data?

Example, for web applications using Turbogears and SQLAlchemy. Every time I update my data model, I need to delete my database and recreate it. Is there an easy way to update the production database? Do I have to write a custom script that transfers all the production data into a new database model? Or is there an easier way to upgra...

Reading a SOAP header to a SOAPpy response?

How can I read s SOAP header from a SOAPpy response? ...

How to get all pieces from regular expression (Python)

Hello! I want get all mathes from this expression: import re def my_handler(matches): return str(matches.groups()) text = "<a href='#' title='Title here'>" print re.sub("<[a-zA-Z]+( [a-zA-Z]+=[\#a-zA-Z0-9_.'\" ]+)*>", my_handler, text) Actual result: (" title='Title here'",) Expected result: ("a", " href='#'", " title=...

Split a string by a delimiter in python

How to split this string ans $$TEXT$$ is the delimiter. 1.MATCHES$$TEXT$$STRING 2.MATCHES $$TEXT$$ STRING ...

A good development environment for python

Possible Duplicate: What IDE to use for Python? I want to start programming in python. Is there a good development environment for python (like eclipse for java?). I guess there's a way to configure eclipse for python. If I somehow do that, will it be as good for python as it is for java? Will I be able to use the interpreter?...

Static variable inheritance in Python

I'm writing Python scripts for Blender for a project, but I'm pretty new to the language. Something I am confused about is the usage of static variables. Here is the piece of code I am currently working on: class panelToggle(bpy.types.Operator): active = False def invoke(self, context, event): self.active = not self.act...

how to return the element tree instance.

I want to generate a xml file. I have written a xml_generator method. When /xxx url hits i call this generator function. how should i return this Because returning instance of generator function creates an error. ...

write a comma in CSV file using python

hi i want to write a text to csv file, in one place I need to write comma, and I don't know how to do it in a way that won't seperate the file to anotehr cell. f.write('1,2,3,45,The Next comma I want to write and not seperate to anoterh cell , so this sentence will bw hole,6,7,8') any sugesstions? ariel ...

Is Zope is dead?

Is Zope is dead? Any opinions are appreciated. If you started new python project with lot of business logic, what priority would have Zope as a development platform? ...

Difference between save() and put() ?

Hello, What is the difference between Mymodel.save() and Mymodel.put() in appengine with python? I know that save is used in django but does is work with appengine models too? ...

append columns of data

Hi there. I have tab delimited data that I am exporting a select few columns into another file. I have: a b c d 1 2 3 4 5 6 7 8 9 10 11 12 and I get: b, d b, d 2, 4 b, d 2, 4 6, 8 b, d 2, 4 6, 8 10, 12 ...... I want: b, d 2, 4 6, 8 10, 12 My code is f=open('data.txt', 'r') f1=open('newdata.txt','w') t=[] for line in f.read...

monitor keyboard events with python in windows 7

Is there any way to monitor keyboard events in windows 7 with python without the python program having focus? I would like to run the python script as a background process that monitors certain keyboard events and does certain things on various keyboard input combinations. ...

C++ methods overload in python

Hi, suppose a C++ class has several constructors which are overloaded according the number and type and sequences of their respective parameters, for example, constructor(int x, int y) and constructor(float x, float y, float z), I think these two are overloaded methods, which one to use depends on the parameters, right? So then in python...