python

Windows Command Line Python Change Version

Hi All, New to Python and programming in general. I want to "install" a module from the command line for v 2.6, but it looks like my default Python is 2.5. (python --version returns 2.5.4) How can I run my python setup.py build/install on 2.6 instead? Many thanks in advance, Brock ...

twisted: one client, many servers

I'm trying to use twisted to create a cluster of computers that run one program on a piece of a larger dataset. My "servers" receive a chunk of data from the client and run command x on it. My "client" connects to multiple servers giving them each a chunk of data and telling them what parameters to run command x with. My question is: ...

Python .xlsx (Office OpenXML) reader as simple as csv module?

I know some Python xlsx readers are emerging, but from what I've seen they don't seem nearly as intuitive as the built-in csv module. What I want is a module that can do something like this: reader = xlsx.reader(open('/path/to/file')) for sheet in reader: print 'In %s we have the following employees:' % (sheet.name) for row in...

parse xml file and create a list of files

there is an info.xml file under every /var/packs/{many folders}/info.xml where are different directories but with the dirs's info in info.xml I need to parse through every {many folders} and create a list of the filepath which is inside the Path tags if the file type is "config" which can be found by checking if "config" is the type in...

Streaming 1GB File in Python

How long should it take to stream a 1GB file in python on say a 2Ghz Intel Core 2 Duo machine? fp = open('publisher_feed_8663.xml') for line in fp: a = line.split('<') I suppose I wasn't specific enough. This process takes 20+ minutes which is abnormally long. Based on empirical data, what is a reasonable time? ...

Failure loading py2exe'd program when including pysvn

I am attempting to run a py2exe'd program (package.py) that includes pysvn. It is failing to run with the following error: Traceback (most recent call last): File "package.py", line 27, in <module> File "zipextimporter.pyc", line 82, in load_module File "pysvn\__init__.pyc", line 99, in <module> File "zipextimporter....

Insert inline image into Lotus Notes message

I've been able to send emails using Lotus Notes and VBA and Python using the COM API like this: http://stackoverflow.com/questions/1027400/can-i-use-lotus-notes-to-send-mail My question is how can I insert an image inline with the body text (not as an attachment) in a programmatic way (equivalent to the Edit | Paste Special)? I haven't...

I am attempting to use google app engine (python) to save a url with # character

My class looks like this: class Post(db.Model): link = db.LinkProperty() I am getting the url parameter and populating the class like this: newpost = Post( link = cgi.escape(self.request.get('link'))) newpost.put() If I send a regular link it works fine. If I send a link like this (with a hash): http://www.url.com#paragraph...

python - recursive call

Hello, I have a class model designed for a person class in python. where a person is a student and can have 0,1 or many advisors.A person can also have other attributes like name,school,year of graduation,classification he worked on,degree he obtained and so on. I have set and get methods for each of these attributes in the class. Ex. ...

TCP Socket file transfer

Hello, I'm trying to write a secure transfer file program using Python and AES and i've got a problem i don't totally understand. I send my file by parsing it with 1024 bytes chunks and sending them over but the server side who receive the data crashes ( I use AES CBC therefore my data length must be a multiple of 16 bytes ) and the e...

What are the pros and cons in Python of using a c library vs a native python one

Are there any downsides in Python to using a library that is just a binding to a C library? Does that hurt the portability of your application? Anything else I should look out for? ...

Python: how to print range a-z?

1. Print a-n: a b c d e f g h i j k l m n 2. Every second in a-n: a c e g i k m 3. Append a-n to index of urls{hello.com/, hej.com/, ..., hallo.com/}: hello.com/a hej.com/b ... hallo.com/n ...

How to show list of deleted files in windows file system

Hello, I am wondering if it is possible to compile a list of deleted files on a windows file system, FAT or NTFS. I do not need to actually recover the files, only have access to their name and any other accessible time (time deleted, created etc). Even if I can run a cmd line tool to achieve this it would be acceptable. The applicati...

Pylint equivalent for Py3k

Pylint doesn't yet support Py3k, so am looking for an alternative. [note] An immature branch off some VCS would be sufficient enough for me to try out. ...

Python - Call a function in a module dynamically

I'm pretty new to Python and I have a situation where I have a variable representing a function inside of a module and I'm wondering how to call it dynamically. I have filters.py: def scale(image, width, height): pass And then in another script I have something like: import filters def process_images(method='scale', options): ...

Writing a connection manager for OpenVPN in python

Hi I'm having trouble trying to write a connection manager for OpenVPN in python. My needs are to have a script that listens on port 1195 UDP and when a connections is established, it should forward all the packages to the server instance of OpenVPN. The reason I need to do this is that I will have 4 instances of OpenVPN running in the s...

How to select rows from an SQL model for a QListView connected to it

I am trying the following in PyQt4, using SQLAlchemy as the backend for a model for a QListView. My first version looked like this: class Model(QAbstractListModel): def __init__(self, parent=None, *args): super(Model, self).__init__(parent, *args) def data(self, index, role): if not index.isValid(): ...

nonlocal keyword in Python 2.x

I'm trying to implement a closure in Python 2.6 and I need to access a nonlocal variable but it seems like this keyword is not available in python 2.x. How should one access nonlocal variables in closures in these versions of python? ...

Ordered ManyToManyField that can be used in fieldsets

Hey all, I've been working through an ordered ManyToManyField widget, and have the front-end aspect of it working nicely: Unfortunately, I'm having a great deal of trouble getting the backend working. The obvious way to hook up the backend is to use a through table keyed off a model with ForeignKeys to both sides of the relationship ...

Running a Python Script on a server (Does it have to be in /cgi-bin/)?

Right now I have a script thats http://www.example.com/cgi-bin/foo?var1=A&amp;var2=B Is there a way that I can have it run outside of the cgi-bin directory? Like could I have http://www.example.com/foo/?var1=A&amp;var2=B Thanks! ...