python

Parse large XML file w/ script or use BioPython API ?

Hey guys this is my first question on here. I'm trying to make a local copy of the UniprotKB in SQL. The UniprotKB is 2.1GB, and it comes in XML and a special text format used by SwissProt Here are my options: 1) Use a SAX parser (XML) - I chose Ruby, and Nokogiri. I started writing the parser, but my initial reaction: how would I map...

PIP: how do I install a python package into a different directory?

I know the obvious answer is to use virtualenv and virtualenvwrapper, but for various reasons I can't/don't want to do that. So how do I modify this command: pip install package_name to make pip install the package somewhere other than the default site-packages? ...

Python FTP grabbing and saving images issue

EDIT: I got it working it just won't download anything... So here is my code simplified now: notions_ftp = ftplib.FTP(ftp_host, ftp_user, ftp_passwd) folder = "Leisure Arts - Images" notions_ftp.cwd(folder) image = open("015693PR-com.jpg","wb") notions_ftp.retrlines("RETR 015693PR-com.jpg", image.write) send_image = open("015693PR-com....

django multiprocess problem

I have django application, running under lighttpd via fastcgi. FCGI running script looks like: python manage.py runfcgi socket=<path>/main.socket method=prefork \ pidfile=<path>/server.pid \ ...

Python - drag file into .exe to run script

Hi, I have a Python script that takes the directory path of a text file and converts it into an excel file. Currently I have it running as a console application (compiled with py2exe) and prompts the user for the directory path through raw_input(). How do i make it such that I can drag & drop my text file directly into the .exe of the...

Track window/control resize in PyQt?

I have a window with 2 QTableWidgets, having their scrolling synchronized. The 1st one usually has horizontal scroll, while the 2nd usually (automatically) not. In order for them to show consistent data (row against row) I make the 2nd have the scroll (through property HorizontalScrollBar -> AlwaysOn). But sometimes the 1st table doesn'...

Distributing a Python library (single file)

Hello. For my project I would be using the argparse library. My question is, how do I distribute it with my project. I am asking this because of the technicalities and legalities involved. Do I just: Put the argparse.py file along with my project. That is, in the tar file for my project. Create a package for it for my distro? Tell t...

What is the Pythonic way to implement a simple FSM?

Yesterday I had to parse a very simple binary data file - the rule is, look for two bytes in a row that are both 0xAA, then the next byte will be a length byte, then skip 9 bytes and output the given amount of data from there. Repeat to the end of the file. My solution did work, and was very quick to put together (even though I am a C p...

don't show on panel

I am trying to write a simple aplication (a continuously changing label on a window on the upper left side of the screen) and I don't want it to be seen on panel but only on system tray.Because it will run for a long time. How can I do that? Thanks. PS: I am using python and pyqt on Linux. I tried SplashScreen but when I clicked on the ...

Python doctest error

Hi I recently started experimenting with python currently reading "Think like a computer scientist: Learning python v2nd edition" I have been having some trouble with doctest. I use a windows 7 machine and Eclipse IDE with pydev. My question is when i run the script below i get the error below. Said script is below the the error messag...

How to import * with __import__

What's the best approach to execute the following using __import__ so that I may dynamically specify the module? from module import * ...

SMTP through Exchange using Integrated Windows Authentication (NTLM) using Python

I want to use the credentials of the logged-in Windows user to authenticate an SMTP connection to an Exchange server using NTLM. I'm aware of the python-ntlm module and the two patches that enable NTLM authentication for SMTP, however I want to use the current user's security token and not have to supply a username and password. Very s...

Using Babel: How to protect translator comments (and old translations) in GNU gettext PO files?

We're using the Python based Babel gettext utilities. Is there any technique we can use to make sure that translator comments and old ("obsolete") translations (marked with #~) in PO files are preserved across PO file updates? Thank you, Malcolm ...

How do I sort a list of python Django objects?

In Django, I have a model object in a list. [object, object, object] Each object has ".name" which is the title of the thing. How do I sort alphabetically by this title? This doesn't work: catlist.sort(key=lambda x.name: x.name.lower()) ...

Self-contained python installation with executable tools included (pip, orbited, etc)

I'm trying deploy a Python application on Windows as a folder that includes a full python 2.6 folder. I don't need/want a fancy solution like py2exe, I'm just trying to automate deployment of a web application. So long as I include python26.dll and set the PYTHONHOME correctly, things seem to work if I just include the Python26 folder i...

Friendly URLs in Google App Engine

I'm trying to build a Friendly URL lookup method in GAE and Python. Have anyone done this? I've got it working but it feels VERY shaky. How it works is that it takes the path (let's say /foo/bar/) and splits it to a list. Takes the last element in the list and query the database for a match. Now comes some headaches. If there is more ...

Framework Similar to Pylons for Ruby

I've been using Python for most of my web projects lately, and have come to really love the Pylons MVC framework. I like the incredible transparency (lack of magic), the built-in components they selected (sqlalchemy, formencode, routes), and the ability to easily change things up (use a different ORM or templating engine). Moving forwa...

Running a batch file with parameters in python OR F#

I searched the site but didn't see anything quite matching what I was looking for. I created a stand alone application that uses a web service I created. To run the client I use: c:/scriptsdirecotry> "run-client.bat" param1 param2 param3 param4 how would I go about coding this in python or F#. seems like it should be pretty simple but ...

How Can I Programmatically Build a Multi-Page TIFF out of Many Single Page TIFFs, Using Python?

I've found, via Google, numerous people asking the same question, but no solutions. The Python Image Library (PIL) has tools for stepping through an already existing multi-page TIFF, but nothing about creating them. Libraries would hopefully be available on Windows, for Python 2.6. If there's some freeware out there which will do the ...

Reason for socket.error

Hi, I am a complete newbie when it comes to python, and programming in general. I've been working on a little webapp for the past few weeks trying to improve my coding chops. A few days ago my laptop was stolen so I went out and got a new MacBook Pro. Thank God I had everything under subversion control. The problem is now that I am ...