python

consuming COM evens in python

I am trying to do a sample app in python which uses some COM objects. I've read the famous chapter 12 from Python Programing on Win32 but regarding this issue it only states: All event handling is done using normal IConnectionPoint interfaces, and although beyond the scope of this book, is fully supported by the standard Pyth...

Disable console output from subprocess.Popen in Python

I run Python 2.5 on Windows, and somewhere in the code I have subprocess.Popen("taskkill /PID " + str(p.pid)) to kill IE window by pid. The problem is that without setting up piping in Popen I still get output to console - SUCCESS: The process with PID 2068 has been terminated. I debugged it to CreateProcess in subprocess.py, but can'...

Help me understand this traceback from the twisted.words msn sample

I'm running the twisted.words msn protocol example from the twisted documentation located here: http://twistedmatrix.com/projects/words/documentation/examples/msn_example.py I am aware there is another question about this sample .py on stackoverflow, but this is an entirely different problem. When I run the example, it behaves as expect...

How to write a setup.py for a program that depends on packages outside pypi

For instance, what if PIL, python-rsvg and libev3 are dependencies of the program? These dependencies are not in pypi index, the latter two are Debian package names. ...

curses-like library for cross-platform console app in python

hi there, i'm looking into developing a console-app in python which should be able to run under windows as well as linux. for this, i'd really like to use a high-level console library like curses. however, as far as i know, curses is not available on windows. what other options do i have? unfortunately, using cygwin under windows is not...

Run Python script without opening Pythonwin

I have a python script which I can run from pythonwin on which I give the arguments. Is it possible to automate this so that when I just click on the *.py file, I don't see the script and it asks for the path in a dos window? ...

Handling lines with quotes using python's readline

I've written a simple shell-like program that uses readline in order to provide smart completion of arguments. I would like the mechanism to support arguments that have spaces and are quoted to signify as one argument (as with providing the shell with such). I've seen that shlex.split() knows how to parse quoted arguments, but in case ...

Python library for converting files to MP3 and setting their quality

Hello, I'm trying to find a Python library that would take an audio file (e.g. .ogg, .wav) and convert it into mp3 for playback on a webpage. Also, any thoughts on setting its quality for playback would be great. Thank you. ...

Python/mySQL on an Embedded ARM9 Device?

I have an application where a small embedded ARM9 device (running Linux) must gather information from sensors and then connect to a remote mySQL database and INSERT the data. I have Python 2.5 running on the ARM9 device fine. I have developed a prototype application in Python 2.5 running on x86 Windows and it connects with mySQL and INSE...

convert string to dict using list comprehension in python

I have came across this problem a few times and can't seem to figure out a simple solution. Say I have a string string = "a=0 b=1 c=3" I want to convert that into a dictionary with a, b and c being the key and 0, 1, and 3 being their respective values (converted to int). Obviously I can do this: list = string.split() dic ...

Getting the position of the gtk.StatusIcon on Windows

I am assisting with Windows support for a PyGTK app that appears as a system tray applet, but am not so strong on the GTK+ gooey stuff... We have it so when you left-click the systray icon, the window appears right by your tray icon no matter where your system tray is--and on Linux this works great, using the results of gtk.StatusIcon.g...

How can I process this text file and parse what I need?

I'm trying to parse ouput from the Python doctest module and store it in an HTML file. I've got output similar to this: ********************************************************************** File "example.py", line 16, in __main__.factorial Failed example: [factorial(n) for n in range(6)] Expected: [0, 1, 2, 6, 24, 120] Got: ...

[Django] Can I use more than a single filter on a variable in template?

For example: {{test|linebreaksbr|safe}} ...

Recursive? looping to n levels in Python

Working in python I want to extract a dataset with the following structure: Each item has a unique ID and the unique ID of its parent. Each parent can have one or more children, each of which can have one or more children of its own, to n levels i.e. the data has an upturned tree-like structure. While it has the potential to go on for i...

how to include % sign in docutils html template

I want to generate HTML pages with rst2html, using my own templates. these templates include many % signs, like in <TABLE border="0" cellpadding="0" cellspacing="0" width="100%"> now, when I call rst2html using the command rst2html --template=layout2.tpl rst/index.rst > index.html i get the error ValueError: unsupported format ...

Python List Comprehension Vs. Map

Is there a reason to prefer using map() over list comprehension or vice versa? Is one generally more effecient or generally considered more pythonic than the other? ...

django extreme slowness

I have a slowness problem with Django and I can't find the source .. I'm not sure what I'm doing wrong, but at least twice while working on projects Django became really slow. Requests takes age to complete (~15 seconds) and Validating model when starting the development server is also very slow (12+ seconds on a quad core..) I've trie...

Finding the domain name of a site that is hotlinking in Google app engine using web2py

Let's say we have an image in the Google App Engine and sites are hotlinking it. How can I find the domain names of the sites? My first thought was: request.client and then do a reverse lookup but that it's not possible in GAE and would take a lot of time. I am pretty sure that there is a property that allows me to get the url of ...

Web Service require Python List as argument. Need to invoke from C#.

Hi. I need to consume a webservice over XML-RPC. The webservice is written in Python, and one of the arguments is a Python list. I'm using XML-RPC.NET to invoke all the methods and it works fine, except for those that require a Python list argument. What would be the corresponding structure in C# which, if I pass as the argument, woul...

Python - printing out all references to a specific instance

I am investigating garbage collection issues in a Python app. What would be the best readable option to print out all variables referencing a specific instance? ...