python

how to using MySQLdb SELECT with for or while loop

import _mysql as mysql db=mysql.connect('localhost','username','password','database') db.query("""select * from news""") result = db.store_result() print result.num_rows()#two records #how to loop? without cursor print result.fetch_row() ...

Adobe Air2 NativeProcess API with Javascript

Hi, I am trying to launch a python script with the NativeProcess API from Javascript. On the Adobe AIR API Reference for HTML Developers I found a good example for that task, but it does not work. I looked up tons of other examples but still can not find the answer. Here is the example code for the html file: <html> <head> <title...

HTTP Webserver with FCGI written in Python?

For a project i need a python webserver (can use C modules if necessary). The basic http server from the runtime is way to simple - at least i need FCGI compatibility for some legacy modules. Is there any other standalone server which is not totally connected to a certain framework like the Zope Webserver? Performance is not really im...

Getting a listing of Trac projects in Python

Is it possible to do something like using the trac module in Python in order to get a listing of all of the projects in a given directory? If possible it would be nice to get things like the description, too. I can't seem to figure out how to do it. Thanks for any help you can provide. ...

python parsing xml

hi i have xml file whitch i want to parse, it looks something like this <?xml version="1.0" encoding="utf-8"?> <SHOP xmlns="http://www.w3.org/1999/xhtml" xmlns:php="http://php.net/xsl"&gt; <SHOPITEM> <ID>2332</ID> ... </SHOPITEM> <SHOPITEM> <ID>4433</ID> ... </SHOPITEM> </SHOP> my parsin...

Paypal integration with Google application engine-python

Hi all, I have to integrate paypal with my application which is built on app engine patch with python. I searched over the web and found some issues reported in paypal integration with google application engine like here: http://groups.google.com/group/google-appengine/browse_thread/thread/9059b0750c45703b/b1d0611dd4b04273 There is ...

How can I use multiple databases in the same request in Cherrypy and SQLAlchemy?

Hey SO'ers, My app connects to multiple databases using a technique similar to this. It works so long as I don't try to access different databases in the same request. Having looked back to the above script I see they have written a comment to this end: SQLAlchemy integration for CherryPy, such that you can access multiple databases, b...

how to render to response?

I am sending list to a template using render_to_response. I am using django shortcuts. Hoe to do that? How to set context instance with a variable? ...

[python] paramiko's sshclient with sftp

How i can make sftp transport throught SSHClient on the remote server? I have local host and two remote. Remotes hosts are backup server and web server. I need find on backup server necessary backup file and put it on web server over sftp. Plz help me, i dont understand how i can make paramiko's sftp transport throught paramiko's SSHCli...

pygtk - treeview with checkbuttons is not working

I am trying to fill a treeview with data and checkbuttons. When the treeview is displayed, checkbuttons appear but the text doesn't. I get the following error: /home/astrob/programação/pyparty/groups.py:81: GtkWarning: gtk_tree_view_column_cell_layout_add_attribute: assertion `info != NULL' failed username_treeviewcolumn.add_attribu...

Having a field named 'created' within a model - Django

Hi folks, I have a model such as the following: class Item(models.Model): name = models.CharField(max_length=150) created = models.DateTimeField(auto_now_add=True) the admin class is the following: class ItemAdmin(admin.ModelAdmin): list_display = ('name', 'created') the created field does not seem to exist Is there...

to parse chat conversations stored in a file

poem = '''\ me:hello dear me:hyyy asha:edaaaa ''' f=open('poem.txt','r') arr=[] arr1=[] varr=[] darr=[] i=0 j=1 for line in f.read().split('\n'): arr.append(line) i+=1 f.close() #print arr[0] #print arr[1] #print arr[2] text=arr[0].split(':') #print text line=text[0] #print line arr1.append(text[1]) for i in range(1,len(arr)):...

Any good books\tutorial on XML-based APIs, REST, SOAP with using Python ?

Could you all please suggest me a good books\tutorial on XML-based APIs, REST, SOAP with using Python Thanks in advance ...

Are there conventions for Python module comments?

It is my understanding that a module docstring should just provide a general description of what a module does and details such as author and version should only be contained in the module's comments. However, I have seen the following in comments and docstrings: __author__ = "..." __version__ = "..." __date__ = "..." Where is the co...

wait for web page to load completely using python

Hi , Is there any way that I can find out using webbrowser or anyother package in Python if a browser window that I've opened has loaded completely or not? Once it's loaded completely I want to take a screenshot of it and save it. ...

How to install Python 3.1.2 on Mac OS X 10.6.4 ?

Hi there I have downloaded the mac installer here, http://www.python.org/download/releases/3.1.2/ , & installed it. But when I run terminal & type python it says: Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. ...

Multiple simultaneous tcp client connections for performace test

Hi i need to create multiple TCP connections simultaneously to some custom TCP-server application for its performance testing. I know a lot of such for Web (i.e. curl-loader based on libcurl), but I didn't found some general one. Scenario for client is the simplest: create connection, send special data, read the answer and close connecti...

Is this a problem with the Django tutorial or a package problem, or is it me?

I'm using Ubuntu 10, python 2.6.5 I'm following this tutorial: http://www.djangobook.com/en/2.0/chapter02 I followed all of the steps using cut-and-paste. The following directory structure was automatically created: bill@ed-desktop:~/projects$ ls -l mysite total 36 -rw-r--r-- 1 bill bill 0 2010-09-01 08:18 __init__.py -rw-r--...

Strategies for Encryption with Django + Postgres?

I'm going to be storing a few sensitive pieces of information (SSN, Bank Accounts, etc) so they'll obviously need to be encrypted. What strategies do you recommend? Should I do all the encryption/decryption in the web app itself? Should I use something like pgcrypto and have the conversions done on the DB side? Something else entirel...

Read flat list into multidimensional array/matrix in python

I have a list of numbers that represent the flattened output of a matrix or array produced by another program, I know the dimensions of the original array and want to read the numbers back into either a list of lists or a NumPy matrix. There could be more than 2 dimensions in the original array. e.g. data = [0, 2, 7, 6, 3, 1, 4, 5] sha...