python

How can I programmatically send events to Qt's webkit?

I would like to create a specialized browser that can enter certain information semi-automatically into pages that are browsed. I am using for this Qt Webkit (in particular the python bindings). How can I do this? ...

How can I make simple TABLE in ReportLab? Pythono! PDF!

How can I make simple TABLE in ReportLab? I need to make simple table 2x20 and put i avery table some data. Can someone point me on example? ...

Python XML and XPath to sort things out

Let's say I have an XML as follows. <a> <b> <c>A</c> </b> <bb> <c>B</c> </bb> <c> X </c> </a> I need to parse this XML into dictionary X for a/b/c and a/b'/c, but dictionary Y for a/c. dictionary X X[a_b_c] = A X[a_bb_c] = B dictionary T T[a_c] = X Q : I'd like to make a mapping file for this in XML file using XPath. ...

Is there a JGraph alternative for Python?

Which library can I use to develop an application for visual modeling with graphs? Is there a library for Python like JGraph for Java? Thank you! ...

Form generation/validation libraries in Python

I'm a developer in Python coming from a PHP background. In PHP most frameworks included a decent form generation/validation API (Zend and CakePHP come to mind). At my new company we try to stay away from Django and use Werkzeug extensively. I've looked at FormEncode and Formular. Formular seems better to me, but there must be stuff...

modifying a python callable so it calls before() , actual function then after()

Hello I am not sure if this is the best way to have before and after functions be called around a function f1(). class ba(object): def __init__(self, call, before, after): self.call = call self.before = before self.after = after def __call__(self, *args): self.before() r = self.call(*arg...

Set Colorbar Range in matplotlib

I have the following code: import matplotlib.pyplot as plt cdict = { 'red' : ( (0.0, 0.25, .25), (0.02, .59, .59), (1., 1., 1.)), 'green': ( (0.0, 0.0, 0.0), (0.02, .45, .45), (1., .97, .97)), 'blue' : ( (0.0, 1.0, 1.0), (0.02, .75, .75), (1., 0.45, 0.45)) } cm = m.colors.LinearSegmentedColormap('my_colormap', cdict, 1024) ...

python subprocess calling "internal" process

Out of curiosity and trying to understand the subprocess module: Is it possible to do something like: import subprocess def myfun(arg): # do stuff arg = something; p = subprocess.Popen(["myfun","arg"]) without putting "myfun" in a file of its own? It seems like this would in general be a scary thing to do if you are not careful ...

Global Variable Not Defined

I'm calling two separate functions to determine what "P01" equals. The first one selects a random number, and discards random numbers already picked. The second one takes the result of the random number and picks a variable to make 'position' equal. I then say that 'P01' equals 'position.' I've made 'position' a global variable, but I k...

how do you include modified 3rd party modules when writing setup.py files?

I wrote a standalone script depends on a few modified modules. the directory structure looks like this: client setup.py tsclient __init__.py tsup utils.py mutagen __init__.py blah.py blah.py ... colorama __init__.py blah.py blah.py ... currently, if I just symlink...

Building a compiler or interpreter using Python

Right now I'm writing my PhD proposal to build a language processor for a new specification language for Java (cf. JML, or Spec# for C#) and need to nail down an implementation tool to start development. The research aspects of the language (syntax, semantics, theoretical results) are orthogonal to my choice of implementation, so I'd lik...

wrapping python script and the running environment in a single sis file

Hi, I have python script running on my nokia N97, using python running environment. is there a way to create a single file with the script and the running environment so that someone wouldn't have to install the running environment separately? ...

compiling vim with python support

I'm trying to compile vim 7.2 with python 2.5.1 support, but I'm having some trouble. 1) I run configure which seems like it is working as expected ./configure --with-features=huge --enable-pythoninterp --prefix=/home/username/vimpy I can see that changes to --with-features works as I expect (the final compiled version has new features...

Python and Excel: Overwriting an existing file always prompts, despite XlSaveConflictResolution value

I'm using the Excel.Application COM object from a Python program to open a CSV file and save it as an Excel workbook. If the target file already exists, then I am prompted with this message: "A file named '...' already exists in this location. Do you want to replace it?" That message comes up despite the fact that I have set the XlSav...

split a file name

Hello How do i write a python script to split a file name eg LN0001_07272010_3.dat and to rename the file to LN0001_JY_07272010? also how do i place a '|' and the end of each line in this file(contents) each line is a record? ...

Disable verify_exists on models.URLField at runtime?

How can I temporarily turn off verify_exists on a models.URLField at runtime? I would like to skip the check on certain URLs (they block EC2 IPs from their firewall). I'm interfacing with the model through the ModelForm right now. ...

How to get rid of spacing in SimpleDocTemplate(). Python. ReportLab

Do someone know if it possible to delete default spancing when i'm making PDF document with SimpleDocTemplate(). I want it to print from corner to corner. response = HttpResponse(mimetype='application/pdf') response['Content-Disposition'] = 'attachment; filename=somefilename.pdf' # Our container for 'Flowable' objects ...

Python to recognize UNC path on cygwin

All machines are on Windows Server 2003. If I only install cygwin on one of the machine and run my python script on it to manipulate files from all remote hosts. How can I access to those files via UNC path? ...

How to os.walk deep defaultdict for values?

I have a very large defaultdict(dict) that looks something like this: data['w']['x']['y']['z']={'a':5,'b':10} I'm trying to do produce a report that lists the hierarchy of all keys navigated for a particular final dictionary. In other words, I am looking for its "full pathname" as if the last dictionary were the file and the parent p...

How do I track a blob using OpenCV and Python

I've gotten OpenCV working with Python and I can even detect a face through my webcam. What I really want to do though, is see movement and find the point in the middle of the blob of movement. The camshift sample is close to what I want, but I don't want to have to select which portion of the video to track. Bonus points for being able ...