python

Redirect command to input of another in Python

I would like to replicate this in python: gvimdiff <(hg cat file.txt) file.txt (hg cat file.txt outputs the most recently committed version of file.txt) I know how to pipe the file to gvimdiff, but it won't accept another file: $ hg cat file.txt | gvimdiff file.txt - Too many edit arguments: "-" Getting to the python part... # hg...

Python ReportLab use of splitfirst/splitlast

I'm trying to use Python with ReportLab 2.2 to create a PDF report. According to the user guide, Special TableStyle Indeces [sic] In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split table, or the f...

Good Python Network Programming Resource

Hi there, i'm begining on a new proyect that need to collect data from some VoIP network equiment, and i thinking to make a python app using some network library and need know some intersting Books or web resources about the netwoking library in python. best regards. ...

Is there a benefit to defining a class inside another class in Python?

So what i'm talking about here are nested classes. So essentially I have two classes that I'm modeling. I have a DownloadManager class and a DownloadThread class. The obvious OOP concept here is composition. However, composition doesn't necessarily mean nesting, right? So I have code that looks something like this: class DownloadThread...

How to check for memory leaks in Guile extension modules?

I develop an extension module for Guile, written in C. This extension module embeds a Python interpreter. Since this extension module invokes the Python interpreter, I need to verify that it properly manages the memory occupied by Python objects. I found that the Python interpreter is well-behaved in its own memory handling, so that...

Testing GUI code: should I use a mocking library?

Recently I've been experimenting with TDD while developing a GUI application in Python. I find it very reassuring to have tests that verify the functionality of my code, but it's been tricky to follow some of the recommened practices of TDD. Namely, writing tests first has been hard. And I'm finding it difficult to make my tests readable...

How do I get started processing email related to website activity?

I am writing a web application that requires user interaction via email. I'm curious if there is a best practice or recommended source for learning about processing email. I am writing my application in Python, but I'm not sure what mail server to use or how to format the message or subject line to account for automated processing. I'...

Unittest causing sys.exit()

No matter what I do sys.exit() is called by unittest, even the most trivial examples. I can't tell if my install is messed up or what is going on. IDLE 1.2.2 ==== No Subprocess ==== >>> import unittest >>> >>> class Test(unittest.TestCase): def testA(self): a = 1 self.assertEqual(a,1) >>> unittest.main(...

How do I convert local time to UTC in Python?

How do I convert a datetime string in local time to a string in UTC time? I'm sure I've done this before, but can't find it and SO will hopefully help me (and others) do that in future. Clarification: For example, if I have "2008-09-17 14:02:00" in my local timezone (+10), I'd like to generate a string with the equivalent UTC time: "2...

How do you design data models for Bigtable/Datastore (GAE) ?

Since the Google App Engine Datastore is based on Bigtable and we know that's not a relational database, how do you design a database schema/data model for applications that use this type of database system? ...

Split a string by spaces -- preserving quoted substrings -- in Python

I have a string which is like this: this is "a test" I'm trying to write something in Python to split it up by space while ignoring spaces within quotes. The result I'm looking for is: ['this','is','a test'] PS. I know you are going to ask "what happens if there are quotes within the quotes, well, in my application, that will never...

Btrieve without Pervasive?

Is there any library available to query Btrieve databases without buying something from Pervasive? I'm looking to code in C# or Python. ...

PubSub lib for c#

Is there a c# library which provides similar functionality to the Python PubSub library? I think it's kind of an Observer Pattern which allows me to subscribe for messages of a given topic instead of using events. ...

Asychronous Programming in Python Twisted

I'm having trouble developing a reverse proxy in Twisted. It works, but it seems overly complex and convoluted. So much of it feels like voodoo... Are there any simple, solid examples of asynchronous program structure on the web or in books? A sort of best practices guide? When I complete my program I'd like to be able to still see the ...

How to skip sys.exitfunc when unhandled exceptions occur

As you can see, even after the program should have died it speaks from the grave. Is there a way to "deregister" the exitfunction in case of exceptions? import atexit def helloworld(): print "Hello World!" atexit.register(helloworld) raise Exception("Good bye cruel world!") ...

PythonWin's python interactive shell calling constructors twice?

While answering http://stackoverflow.com/questions/68645/python-static-variable#81002 I noticed that PythonWin PyWin32 build 209.2 interpreter seems to evaluate twice? PythonWin 2.5 (r25:51908, Mar 9 2007, 17:40:28) [MSC v.1310 32 bit (Intel)] on win32. Portions Copyright 1994-2006 Mark Hammond - see 'Help/About PythonWin' for furthe...

What IDE to use for Python?

Asking as a Python beginner, what IDEs ("GUIs/editors") do others use for Python coding? If you can just give the name (for example, Textpad, Eclipse ..) that will be enough. If it is already mentioned, you can just vote for it. But if you can also give some more comparative information, that will be much appreciated. Update: Result...

PyQT and PyCairo

I know it's possible to place a PyCairo surface inside a Gtk Drawing Area. But I think Qt is a lot better to work with, so I've been wondering if there's anyway to place a PyCairo surface inside some Qt component? ...

Python + DNS : Cannot get RRSIG records: No Answer

I get DNS records from a Python program, using DNS Python I can get various DNSSEC-related records: >>> import dns.resolver >>> myresolver = dns.resolver.Resolver() >>> myresolver.use_edns(1, 0, 1400) >>> print myresolver.query('sources.org', 'DNSKEY') <dns.resolver.Answer object at 0xb78ed78c> >>> print myresolver.query('ripe.net', 'N...

Is there any list of blog engines, written in Django?

Is there any list of blog engines, written in Django? ...