python

Formatted output in OOffice/Word with python

I am working on a project(in python) that needs formatted, editable output. Since the end-user isn't going to be technically proficient, the output needs to be in a word processor editable format. The formatting is complex(bullet points, paragraphs, bold face, etc), I'm wondering if there is a way to generate such a report using python. ...

How to use classes derived from Python's list class

This is a followup to question 912526 - http://stackoverflow.com/questions/912526/how-do-i-pass-lots-of-variables-to-and-from-a-function-in-python. There are lots of variables that need to get passed around in the program I'm writing, and from my previous question I understand that I should put these variables into classes, and then pas...

Retrieving Cookies python

hello, i've figured out how to save cookies in python, but how do i read them back?.. ...

Learning parser in python

I recall I have read about a parser which you just have to feed some sample lines, for it to know how to parse some text. It just determines the difference between two lines to know what the variable parts are. I thought it was written in python, but i'm not sure. Does anyone know what library that was? ...

Python and Qt - function reloading

Hello, i have an application class inherited from QtGui.QDialog. I have to reload show-function but save functionality. I take this idea from C#. There i could do something like this: static void show() { // My code... base.show(); } I want to do something like that but with python and qt (PyQt). Can i do that? ...

How to make mechanize not fail with forms on this page?

import mechanize url = 'http://steamcommunity.com' br=mechanize.Browser(factory=mechanize.RobustFactory()) br.open(url) print br.request print br.form for each in br.forms(): print each print The above code results in: Traceback (most recent call last): File "./mech_test.py", line 12, in <module> for each in br.forms(...

Which process was responsible for an event signalled by inotify?

I am using pyinotify to detect access, changes, etc. on files in a given directory. Is there an easier way to find out which process was responsible for that - without having to patch inotify? ...

Exporting a zope folder with python

We have two zope servers running our company's internal site. One is the live site and one is the dev site. I'm working on writing a python script that moves everything from the dev server to the live server. Right now the process involves a bunch of steps that are done in the zope management interface. I need to make all that automa...

How do I deactivate an egg?

I've installed cx_Oracle (repeatedly) and I just can't get it to work on my Intel Mac. How do I deactivate/uninstall it? ...

Is it possible to launch a Paster shell with some modules pre-imported?

Is it possible to run "paster shell blah.ini" (or a variant thereof) and have it automatically load certain libraries? I hate having to always type "from foo.bar import mystuff" as the first command in every paster shell, and would like the computer to do it for me. ...

How to mark a global as deprecated in Python?

I've seen decorators that let you mark a function a deprecated so that a warning is given whenever that function is used. I'd like to do the same thing but for a global variable, but I can't think of a way to detect global variable accesses. I know about the globals() function, and I could check its contents, but that would just tell me ...

Unicode problems in PyObjC

I am trying to figure out PyObjC on Mac OS X, and I have written a simple program to print out the names in my Address Book. However, I am having some trouble with the encoding of the output. #! /usr/bin/env python # -*- coding: UTF-8 -*- from AddressBook import * ab = ABAddressBook.sharedAddressBook() people = ab.people() for person...

Installing/configuring gdbm Python module for cvs2svn?

I am trying to install cvs2svn on a Solaris 10 machine. It has Python 2.4.4 on it. I don't have root access. When I downloaded cvs2svn and tried to run it, it said ERROR: cvs2svn uses the anydbm package, which depends on lower level dbm libraries. Your system has dbm, with which cvs2svn is known to have problems. To use cvs2svn, you mus...

Syntax Highlight for Mako in Eclipse or TextMate?

Hi, does anyone know of a syntax highlight for mako templates for eclipse or for textmate? I know that there is a .mako syntax highlighter for the default text editor in ubuntu. Thanks a lot. Claudio. ...

Check if input is a list/tuple of strings or a single string

I've a method that I want to be able to accept either a single string (a path, but not necessarily one that exists on the machine running the code) or a list/tuple of strings. Given that strings act as lists of characters, how do I tell which the method has received? I'd like to be able to accept either standard or unicode strings for ...

Writing a kernel mode profiler for processes in python.

I would like seek some guidance in writing a "process profiler" which runs in kernel mode. I am asking for a kernel mode profiler is because I run loads of applications and I do not want my profiler to be swapped out. When I said "process profiler" I mean to something that would monitor resource usage by the process. including usage of ...

SPNEGO (kerberos token generation/validation) for SSO using Python

I'm attempting to implement a simple Single Sign On scenario where some of the participating servers will be windows (IIS) boxes. It looks like SPNEGO is a reasonable path for this. Here's the scenario: User logs in to my SSO service using his username and password. I authenticate him using some mechanism. At some later time the user ...

NameError using execfile in python

My application has a button to execute a python script dynamically using execfile. If I define a function inside the script (eg. spam()) and try to use that function inside another function (eg. eggs()), I get this error: NameError: global name 'spam' is not defined What is the correct way to call the spam() function from within eggs...

How can I capture the stdout output of a child process?

I'm trying to write a program in Python and I'm told to run an .exe file. When this .exe file is run it spits out a lot of data and I need a certain line printed out to the screen. I'm pretty sure I need to use subprocess.popen or something similar but I'm new to subprocess and have no clue. Anyone have an easy way for me to get this don...

Creating lists of lists in a pythonic way

I'm using a list of lists to store a matrix in python. I tried to initialise a 2x3 Zero matrix as follows. mat=[[0]*2]*3 However, when I change the value of one of the items in the matrix, it changes the value of that entry in every row, since the id of each row in mat is the same. For example, after assigning mat[0][0]=1 mat is [[...