python

Something similar to ParallelPython for C++?

I need to do some extensive searching and string comparisons and for this I figure that a compiled program is much better than an interpreted ones especially after seeing some comparison studies. I came across ParallelPython which was beautiful. It has autodiscovery for clusters and can pretty much do all the load balancing for me as wel...

How to plot a pie chart with the first wedge on top, in Python? [matplotlib]

How can a pie chart be drawn with Matplotlib with a first wedge that starts at noon (i.e. on the top of the pie)? The default is for pyplot.pie() to place the first edge at three o'clock, and it would be great to be able to customize this. ...

Regular expression isn't found in line: execution just hangs.

Hello all! I am new to python (and this site); I am trying to write a script that will use a regular expression to search through a given file to find a name. I have to print out the different ways the name was capitalized and how many times the name was found. My current code will just print out my first flag and then hang. I don't know...

Python: Convert from buffer of Structure object to unsiged integer

Hi all, I'm new to Python, so I was wondering how would I extract buffer to convert the whole buffer into one integer from a Structure object with the code defined below g = 12463 h = 65342 i = 94854731 j = 9000 class Blah(Structure): _fields_ = [ ("a", ctypes.c_int32, 17), ("b", ctypes.c_int32, 19),...

IOError with Celeryd on large data processing

I'm doing some largish scale data processing with nltk. In doing so we iterate through 2-3000 files sitting on the server, reading through them all, making changes, and closing them out. This is all handled via Celery tasks. The only problem is that we often find ourselves encountering this: IOError: [Errno 5] Input/output error A qui...

Why doesn't my Python Selenium test work?

Whenever I try to run a Python test with Selenium RC, it doesn't work. Here's the output I get when I try to run test_default_server.py: $ python test_default_server.py Using selenium server at localhost:4444 E ====================================================================== ERROR: testLinks (__main__.TestDefaultServer) ----------...

Python xml etree DTD from a StringIO source?

I'm adapting the following code (created via advice in this question), that took an XML file and it's DTD and converted them to a different format. For this problem only the loading section is important: xmldoc = open(filename) parser = etree.XMLParser(dtd_validation=True, load_dtd=True) tree = etree.parse(xmldoc, parser) This wo...

Testing for extra_context in django

Hi, I'm trying to test if the extra_context provided by the user was correctly processed in the view. Here is my test approach: # tests.py (of course it's a part of TestCase class) def test_should_use_definied_extra_context(self): response = self.client.get(reverse('contact_question_create'), { 'extra_context': {'foo': 'ba...

Proper way to test Django signals

I'm trying to test sent signal and it's providing_args. Signal triggered inside contact_question_create view just after form submission. My TestCase is something like: def test_form_should_post_proper_data_via_signal(self): form_data = {'name': 'Jan Nowak'} signals.question_posted.send(sender='test', form_data=form_...

Generating SHA-256 hash in Python 2.4 using M2Crypto

Is it possible to generate a SHA-256 hash using M2Crypto? Python 2.4's SHA module doesn't support 256, so I started using PyCrypto, only to find out that PyCrypto doesn't support PKCS#5 (needed elsewhere in my project.) I switched to M2Crypto as a result and now I would like to replace my PyCrypto SHA-256 call with an M2Crypto equivale...

argparse missing in python 3

hi, does somebody know, why the argparse module didn't make it in python 3? it's new in python 2.7, but the 2.x branch is running out with 2.7. it makes no sense to me not to support it in the actual python 3 branch. ...

wxPython - HtmlWindow freezes when loading images

I am writing a chatroom client in wxPython in which there are 3 wx.HtmlWindows for each chatroom on a notebook page: one for the messages, one for the title of the room, and one for the topic of the room (two similar things) The program works fine, loads images when images are in the message's code, etc. But when it suddenly has to load...

syntax for creating a dictionary into another dictionary in python

Possible Duplicate: syntax to insert one list into another list in python How could be the syntax for creating a dictionary into another dictionary in python ...

jmx-term python subprocess poisons shell

#!/usr/bin/env python from subprocess import * p = Popen( args=("java","-jar","jmxterm-1.0-alpha-4-uber.jar"), bufsize=0, stdin=PIPE, stderr=PIPE ) p.stdin.write("open localhost:12345\n") x = p.stderr.readline() This needs a java process listening for a jmx client on port 12345. The script "works": x is correct (when you...

Writing python (or any other SL4A) in android

Can someone point me to a tutorial on using the android scripting enviornment? I've seen plenty of tutorials on how to write python code using the android API especially from http://code.google.com/p/android-scripting/wiki/Tutorials. But none of what I've seen gives a good example of how this all works inside android or how to call you...

Django RSS Feed Authentication

I am looking into adding RSS feeds to one of my Django apps and I would like to be able to have them be authenticated. I want to use the new syndication framework in Django 1.2. I've read the docs on how to do this and have the basic feeds setup. I am new to authenticating feeds, so I am not sure what the best approach to take is o...

Python Ignore Exception and Go Back to Where I Was

I know using below code to ignore a certain exception, but how to let the code go back to where it got exception and keep executing? Say if the exception 'Exception' raises in do_something1, how to make the code ignore it and keep finishing do_something1 and process do_something2? My code just go to finally block after process pass in ex...

How to import function handlers from other file to a Python/GTK Builder program?

I have a Python script which uses a glade file to define its UI, and has a lot of repetitive widgets, each one to adjust a different numerical attribute of a certain active object. Since it is repetitive, I decided to define all the handlers in a separate file for encapsulation and readability. Here are some code excerpts: The main file...

django: can we do loader.get_template('my_template.txt')?

Hi, I want to use django template to process plain text file, and tried this: from django.template import loader, Context t = loader.get_template('my_template.txt') however, it works for this: from django.template import loader, Context t = loader.get_template('my_template.html') Can we load txt files using django template loader? ...

Accessing Yahoo Contacts through OAuth on App Engine (Python)

Hey, yall. I have an existing webapp, running in Python on App Engine, in which users can login through open-id using a Yahoo account. Now, once they're signed in, I'd like them to be able to access their Yahoo contacts, through OAuth. I'm working though the Yahoo Python SDK and am just stuck. I have the consumer key, consumer secret...