python

gtk: set cellrenderertext foreground color when a row is highlighted

When I have a gtk.CellRendererText, I can associate its foreground color with one of the tree store's columns, and set the foreground-set attribute to True, to change the color of the text in that column. However, when the row with the colored column is selected, its color disappears, and is the same as any selected cell's color. How do ...

Runtime Crash For A Very Basic Python Program

I work on a windows XP PC with a Python 2.6 install and I was trying to solve a Project Euler problem, but whenever I execute the code the interpreter hangs. I've debugged it through PyScripter, IDLE and MonkeyStudio, but it still doesn't work even for trivial values like 15. I simply don't understand why. Can you please help me out? H...

Python newbie: "if X == Y and Z" syntax

Does this if key == "name" and item: mean this? if key == "name" and if key == "item": If so, I'm totally confused about example 5.14 in Dive Into Python. How can key be equal to both "name" and item? On the other hand, does "and item" simply ask whether or not item exists as a variable? Thanks. ...

Python Cheetah - Specify name/value pairs for templating

I am trying to template-ize my Apache httpd configuration for deployment to different environments and I would like to use the Python language Cheetah application to do so. However, I am having difficulty with the command line cheetah program and I believe its a combination of my misunderstanding Cheetah along with a lack of documentatio...

Ordering a Many-To-Many field in Django Admin

Here's my setup: from django.contrib.auth.models import User class Product(models.Model): ... email_users = models.ManyToManyField(User, null=True, blank=True) ... [elsewhere] class ProductAdmin(admin.ModelAdmin): list_display = ('name','platform') admin.site.register(Product, ProductAdmin) My main problem is, when I'...

CookieJarLib wont save cookies back to File?

I am working off of the example code given by Anthony Briggs. However it doesn't seem to save the cookies back into the defined cookie file. My modified code. I switched to using LWPCookieJar because its supposedly fully compatible and also removed the login code into a separate function so that I can first test if I am login, and then ...

Python error codes.

I have a python script which uses subprocess.Popen to run multiple instances of another python script, each operating on a different file. I have a collection of 300 files which I run through this process for testing purposes. every run, a random number of files fails, always different files, so there is nothing wrong with the files th...

Iterate over Dictionary: Get 'NoneType" object is not iterable error

The function class: def play_best_hand(hand, wordDict): tempHand = hand.copy() points = 0 for word in wordDict: for letter in word: if letter in hand: tempHand[letter] = tempHand[letter] - 1 if tempHand[letter] < 0: return False if wordDict[word] > points: ...

Simple way to storing data from multiple processes

I have a Python script that does something along the line of: def MyScript(input_filename1, input_filename2): return val; i.e. for every pair of input, I calculate some float value. Note that val is a simple double/float. Since this computation is very intensive, I will be running them across different processes (might be on the s...

Tkinter Global Binding

Is it possible to bind all widgets to one command, with a single line? It would be nice if I could type in one line as opposed to doing each widget individually. ...

Scheduling events in a WSGI framework

I've written a Python app that reads a database of tasks, and schedule.enter()s those tasks at various intervals. Each task reschedules itself as it executes. I'd like to integrate this app with a WSGI framework, so that tasks can be added or deleted in response to HTTP requests. I assume I could use XML-RPC to communicate between the...

logging remove / inspect / modify handlers configured by fileConfig()

How can I remove / inspect / modify handlers configured for my loggers using the fileConfig() function? For removing there is Logger.removeHandler(hdlr) method, but how do I get the handler in first place if it was configured from file? ...

Django / Python, getting field name from database get object?

Sorry if I'm missing something obvious here as my search isn't turning up anything relevant. I am doing a Django database get query and would like to get each field name during a for loop so that I can do evaluations of it ( if fieldname = "blah") and so on, but I can't seem to figure this out, any advice is appreciated db_get_data = Mo...

Pyqt tabs like in Google Chrome

I would like to have my pyqt aplication have tabs in the menu bar like Google Chrome :) Any suggestions or a simple example on how to do it? I did find these relevant link: - http://ivan.fomentgroup.org/blog/2009/03/29/instant-chrome/ ...

Determining the Bazaar version number from Python without calling bzr

I have a django (Python) project that needs to know what version its code is on in Bazaar for deployment purposes. This is a web application, so I don't want to do this because it fires off a new subprocess and that's not going to scale. import subprocess subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)...

repeating multiple characters regex

Is there a way using a regex to match a repeating set of characters? For example: ABCABCABCABCABC ABC{5} I know that's wrong. But is there anything to match that effect? Update: Can you use nested capture groups? So Something like (?<cap>(ABC){5}) ? ...

Why can't I change the system default python the way Apple says I can?

On this help page http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/python.1.html Apple says: CHANGING THE DEFAULT PYTHON Using % defaults write com.apple.versioner.python Version 2.5 will make version 2.5 the user default when running the both the python and pythonw commands (...

change timestamp in bind logfile

i need to change the timestamps in a bind logfile because half of them are incorrect now that i have updated the system time... every line in the file follows this format: 04-Aug-2010 07:32:31.416 client 10.0.0.1#00000: query: google.com IN A + (10.0.0.1) all the time stamps are out by 8 hours. this is what i have so far: #!/usr/bin...

how to do a zoom in/out with wxpython

how to do a zoom in/out with wxpython? what are the very basics for this purpose? I googled this, but could not find much, thanks!! ...

Changing $PATH in OS X to run most recent version of Python

So I changed $PATH to have Python2.5 work with Django back when it didn't support 2.6. Now I can't install much of anything through Python because I screwed up a lot of the internals. $PATH is now unnecessarily long because I didn't know what I was doing when I was adding to it. .profile doesn't contain any of the paths that I added usin...