python

Acessing other py file's class

I have two files: a.py b.py How can I access my ABC123 class defined in a.py from b.py? ...

BioPython: extracting sequence IDs from a Blast output file

Hi, I have a BLAST output file in XML format. It is 22 query sequences with 50 hits reported from each sequence. And I want to extract all the 50x22 hits. This is the code I currently have, but it only extracts the 50 hits from the first query. from Bio.Blast import NCBIXM blast_records = NCBIXML.parse(result_handle) blast_record = bl...

python and sll/Exchange 2007: No suitable authentication method found

I'm trying to send emails from a python script with smtplib, and it works with no problems with smtp through Exchange 2003, but with Exchange 2007 shows: SMTPException: No suitable authentication method found. Python code is the same in both cases (except server and login information of course). I'm passing username and password in a...

How to set attributes using property decorators?

This code returns an error: AttributeError: can't set attribute This is really a pity because I would like to use properties instead of calling the methods. Does anyone know why this simple example is not working? #!/usr/bin/python2.6 class Bar( object ): """ ... """ @property def value(): """ ... ...

Debugging the reading of output of a Windows console app using Python

This question is very similar to this one. I want to read output from a console app of mine. The app does not terminate, nor does it take input from stdin. When I modify rix0rrr's solution to execute my app and then run his solution, Python hangs because read(1) does not return. The initial output of the app is "Starting the server.\n"....

Python Tkinter Prompt

I am trying to prompt the user to enter a string of text. Is there available with python tkinter a Javascript like prompt? ...

Color Themes For Eclipse Python Development

I am looking for Eclipse themes that are similar to the following and support Python/xhtml/css/js by default. ...

python popen working directory argument

hi all, I there a way to specify the running directory of command in subprocess.Popen() like Popen('c:\mytool\tool.exe',workingdir='d:\test\local') and my python script locates in c:\programs\python. IS there possible i can run c:\mytool\tool.exe in 'd:\test\local' ? it seems c:\mytool\tool.exe runs in my c:\programs\python as w...

accurately measure time python function takes

Hello, I need to measure the time certain parts of my program take (not for debugging but as a feature in the output). Accuracy is important because the total time will be a fraction of a second. I was going to use the time module when I came across timeit, which claims to avoid a number of common traps for measuring execution times. U...

Transactions behaviour when request times out. [google app engine]

Google app engine has this useful little function in its db class, db.run_in_transaction() Which is suppose to garentee that your method will be rolled back if an exception is raised. "If the function raises an exception, the transaction is rolled back." What happens if my request times out in the middle of its execution? Will it ro...

Why we should perfer to store the serialized data not the raw code to DB?

Hi: If we have some code(a data structure) which should be stored in DB, someone always suggests us to store the serialized data not the raw code string. So I'm not so sure why we should prefer the serialized data. Give a simple instance(in python): we've got a field which will store a dict of python, like { "name" : "BMW", "catego...

Possible to use more than one argument on __getitem__?

I am trying to use __getitem__(self, x, y): on my Matrix class, but it seems to me it doesn't work (I still don't know very well to use python). I'm calling it like this: print matrix[0,0] Is it possible at all to use more than one argument? Thanks. Maybe I can use only one argument but pass it as a tuple? ...

how to write regex for below format using python

I want to validate below data using regex and python. Below is the dump of the data which Can be stored in string variable Start 0 .......... group=..... name=...... number=.... end=(digits) Start 1 .......... group=..... name=...... number=.... end=(digits) Start 2 .......... group=..... name=...... number=.... end=(digits) Start 3...

How to remove extended ascii using python?

In trying to fix up a PML (Palm Markup Language) file, it appears as if my test file has non-ASCII characters which is causing MakeBook to complain. The solution would be to strip out all the non-ASCII chars in the PML. So in attempting to fix this in python, I have import unicodedata, fileinput for line in fileinput.input(): prin...

How do I copy local Google App Engine Python datastore to local Google App Engine Java datastore?

I have around 4000 entities that I need to insert into a Java App Engine datastore. As I understand it, only the Python version of App Engine currently has tools to upload data from a CSV file to a datastore. So, what I have done thus far is follow the instructions at http://code.google.com/appengine/docs/python/tools/uploadingdata.htm...

Auto run unit test cases in Python

We have a python based web application along with its unit test cases. Our need is to automate the process of running unit test cases. They should run either after every checking OR after every fixed time interval. With minimal effort and time what is best tool that we can use to automate this process. We are using Linux as OS and git as...

Embedding Gnash into PyGame?

Is there a way to display flash applications using Gnash renderer (I'm not averse to Adobe's renderer but would prefer not to use it) in a PyGame application? ...

Matrix data structure

A simple 2 dimensional array allows swapping rows (or columns) in a matrix in O(1) time. Is there an efficient data structure that would allow swapping both rows and columns of a matrix in O(1) time? ...

How fast is Python?

I'm a Java programmer and if theres one thing I dislike about it, it would be speed. Java seems really slow, but a lot of the Python scriptsprograms I have written so far seem really fast. So I was just wondering if Python is faster then Java, or C# and how that compares to C/C++ (which I figure it'll be slower than)? ...

Is this possible?

I've got a class Foo that's a running thread, what I'd like to do is limit how much class Bar can access of Foo while still having access to Foo's internals, is that possible? ...