python

Python 2.4 plistlib on Linux

According to http://docs.python.org/dev/library/plistlib.html, plistlib is available to non-Mac platforms only since 2.6, but I'm wondering if there's a way to get it work on 2.4 on Linux. ...

Best Technology for a medical 3D Planning Software

I am looking to build a new Interactive 3D planning software similar to this one http://www.materialise.com/materialise/view/en/131410-SimPlant.html I was looking for some expert advise about the best technologies to use to build the different components of the software (ie: UI, Image processing, visualization, 3D, etc.. ) The softwar...

Cherrypy server does not accept incoming http request on MS Windows if output (stdout) is not redirected

It is a rather strange 'bug'. I have written a cherrypy based server. If I run it this way: python simple_server.py > out.txt It works as expected. Without the the redirection at the end, however, the server will not accept any connection at all. Anyone has any idea? I am using python 2.4 on a Win XP professional machine. ...

Python Scrapy , how to define a pipeline for an item?

I am using scrapy to craw diferent sites, for each site I have an Item (different information is extracted) Well, for example I have a generic pipeline (most of information is the same) but now I am crawling some google search response and the pipeline must be different. for example GenericItem uses GenericPipeline but the GoogleItem...

Django failing to find apps

I have been working on a django app on my local computer for some time now and i am trying to move it to a mediatemple container and im having a problem when i try to start up django. it gives me this traceback: application failed to start, starting manage.py fastcgi failed:Traceback (most recent call last): File "manage.py", line 11, i...

How to analyze IE activity when opening a specific web page

I'd like to retrieve data from a specific webpage by using urllib library. The problem is that in order to open this page some data should be sent to the server before. If I do it with IE, i need to update first some checkboxes and then press "display data" button, which opens the desired page. Looking into the source code, I see that ...

Python, Django, datetime

In my model, I have 2 datetime properties: start_date end_date I would like to count the end date as a one week after the start_date. How can I accomplish this? ...

Django: How do I access the request object or any other variable in a form's clean() method?

I am trying to request.user for a form's clean method, but how can I access the request object? Can I modify the clean method to allow variables input? Thanks. ...

Loading all modules in a folder in Python

Could someone provide me with a good way of importing a whole directory of modules? I have a structure like this: /Foo bar.py spam.py eggs.py I tried just converting it to a package by adding __init__.py and doing from Foo import * but it didn't work the way I had hoped. ...

How to code a Download/Upload Speed Monitor in PHP,Python, or Java?

Hi everybody. I have to code a up/download speed monitor. It will obtain the current download and upload transfer speed of the computer which it has been installed and post it to another server periodically. c But I don't have an idea about how to catch instant transfer rates of a computer. As you know some of network monitoring program...

Django/Python: How do i transfer a class's attributes to another via a for loop? (Form->Model Instance)

I wish to update a model instance from a form I have. The form is a ModelForm, so it has the same attributes as the model instance, how do I transfer the attributes from the form instance to the model instance instead of doing this: modelinstance.name = form.name . . . . A for loop perhaps? :) Thanks! ...

How to do windows API calls in Python 3.1?

Has anyone found a version of pywin32 for python 3.x? The latest available appears to be for 2.6. Alternatively, how would I "roll my own" windows API calls in Python 3.1? ...

Python: how to call a data member of the base class if it is being overwritten as a property in the derived class?

This question is similar to this other one, with the difference that the data member in the base class is not wrapped by the descriptor protocol. In other words, how can I access a member of the base class if I am overriding its name with a property in the derived class? class Base(object): def __init__(self): self.foo = 5 cl...

Using pipes to communicate data between two anonymous python scripts

Consider this at the windows commandline. scriptA.py | scriptB.py I want to send a dictionary object from scriptA.py to scriptB.py by pickle:ing it and sending it over a pipe. But I don't know how to accomplish this. I've read some posts about this subject here, but usually there's answers along these line: Popen( "scriptA.py"´, ......

Bad pipe filedescriptor when reading from stdin in python

Duplicate of this question. Vote to close. Consider this at the windows commandline. scriptA.py | scriptB.py In scriptA.py: sys.stdout.write( "hello" ) In scriptB.py: print sys.stdin.read() This generates the following error: c:\> scriptA.py | scriptB.py close failed: [Errno 22] Invalid argument Traceback (most recent call las...

Using Python to replace MATLAB: how to import data?

I want to use some Python libraries to replace MATLAB. I'd like to know how could I import excel data in Python (for example using numpy) to use them. I don't know if Python is a credible alternative to MATLAB, but I want to try it. If you have any tutorial I'd be glad to read it! Thanks a lot! ...

python+encryption: Encrypting session key using public key

I want to encrypt the session key using the public key. How does the PGP software do this? Can somebody specify the procedure or function of encryption in Python? ...

python __import__ problem

I have a messages folder(package) with __init__.py file and another module messages_en.py inside it. In __init__.py if I import messages_en it works, but __import__ fails with "ImportError: No module named messages_en" import messages_en # it works messages = __import__('messages_en') # it doesn't ? I used to think 'import x' is just ...

Importing methods for a Python class

I wonder if it's possible to keep methods for a Python class in a different file from the class definition, something like this: main_module.py: class Instrument(Object): # Some import statement? def __init__(self): self.flag = True def direct_method(self,arg1): self.external_method(arg1, arg2) to_import_f...

Execute a prepared statement in sqlalchemy

I have to run 40K requests against a username: SELECT * from user WHERE login = :login It's slow, so I figured I would just use a prepared statement. So I do e = sqlalchemy.create_engine(...) c = e.connect() c.execute("PREPARE userinfo(text) AS SELECT * from user WHERE login = $1") r = c.execute("EXECUTE userinfo('bob')") for x in r...