python

Set Django model field with a method.

I'm trying to set title_for_url but it shows up in my database as "<property object at 0x027427E0>". What am I doing wrong? from django.db import models class Entry(models.Model): def _get_title_for_url(self): title = "%s" % self.get_title_in_url_format() return title AUTHOR_CHOICES = (('001', 'John Doe'),) ...

Help with Python UnboundLocalError: local variable referenced before assignment

Hi,I have post the similar question before,however,I think I may have misinterpreted my question,so may I just post my origin code here,and looking for someone can help me,I am really stuck now..thanks alot. from numpy import * import math as M #initial condition All in SI unit G=6.673*10**-11 #Gravitational constant ms=1.9889*10**3...

How do I use the quartz scheduler with Python?

Is there a guide or tutorial on how to use the quartz Scheduler with Python. Is there an existing API for Python? ...

Python message oriented middleware (i.e. JMS for Python)

What message oriented middle ware with a Python API are out there? What ones did you use and recommend (or not)? ...

Quitting matplotlib.pyplot animation gracefully

I have a script that plots data of some photometry apertures, and I want to plot them in an xy plot. I am using matplotlib.pyplot with python 2.5. The input data is stored in around 500 files and read. I am aware that this is not the most efficient way of inputting the data but that's another issue... Example code: import matplotlib.p...

passing value to other module python

hello, i have two script name is A.py and B.py i want to know how to send value from A.py to B.py. for more detail,when run finished A.py script at the end of script ,A.py call B.py. my question is i have to send some value from A.py to B.py. anybody some help me how to send value A.py to B.py,so i can use some value in B.py. "Do...

Class-level read-only properties in Python

Is there some way to make a class-level read-only property in Python? For instance, if I have a class Foo, I want to say: x = Foo.CLASS_PROPERTY but prevent anyone from saying: Foo.CLASS_PROPERTY = y EDIT: I like the simplicity of Alex Martelli's solution, but not the syntax that it requires. Both his and ~unutbu's answers inspir...

oneliner scramble program

It's that time of year again that programmers want to shuffle a list such that no element resides on its original position (at least in the Netherlands, we celebrate Sinterklaas and pick straws for deciding who writes who a poem). Does anyone have a nice Python single statement for that? So, input example: range(10) Output example: [2,...

Using pyparsing to parse a word escape-split over multiple lines

I'm trying to parse words which can be broken up over multiple lines with a backslash-newline combination ("\\n") using pyparsing. Here's what I have done: from pyparsing import * continued_ending = Literal('\\') + lineEnd word = Word(alphas) split_word = word + Suppress(continued_ending) multi_line_word = Forward() multi_line_word << ...

I set a proxy server on urllib2, and then I can't change it.

Like the title says, my code basically does this: set proxy, test proxy, do some cool stuff But after the proxy is set the first time, it sticks that way, never changing. This is the failing code: # Pick proxy r = random.randint(0, len(proxies) - 1) proxy = proxies[r] print proxy # Setup proxy l_proxy_support ...

Debugging a pyQT4 app?

I have a fairly simple app built with pyqt4. I wanted to debug one of the functions connected to one of the buttons in my app. However, when I do the following python -m pdb app.pyw > break app.pyw:55 # This is where the signal handling function starts. things don't quite work like I'd hope. Instead of breaking in the function where ...

computer algebra soft to minimize the number of operations in a set of polynomials

hello I have systems of polynomials, fairly simple polynomial expressions but rather long to optimize my hand. Expressions are grouped in sets, and in a given set there are common terms in several variables. I would like to know if there is a computer algebra system, such as Mathematica, Matlab, or sympy, which can optimize multiple p...

Python: data vs. text?

Guido van Rossum's presentation about Python 3000 mentions several things to make a transition from Python 2 to Python 3 easier eventually. He is specifically talking about text handling since the move to Unicode as the only representation of strings in Python 3 is one of the major changes. As far as text handling goes, one slide (#14) ...

Python binary diff

I'm trying to use bsdiff (or any binary diff implementation you come up with) to compute and apply diff onto random binary data. I would like to use it on data from a database, so it would be better not to have to write those onto disk and pass them to bsdiff.exe. Is there any wrapper library or way in python to do that? ...

Using Windows 7 taskbar features in PyQt

Hi all. I am looking for information on the integration of some of the new Windows 7 taskbar features into my PyQt applications. Specifically if there already exists the possibility to use the new progress indicator (see here) and the quick links (www.petri.co.il/wp-content/uploads/new_win7_taskbar_features_8.gif). If anyone could pro...

Read version info from .ABR file (Photoshop brush set)

Is it possible to detect which Photoshop version a brush set (.abr) file is compatible with from its binary data? There is a open source C# programm called ABRViewer but it doesn't read version info. Sample brushes: http://mark-s.deviantart.com/art/Fractal-Brushes-Set-20484978 http://redheadstock.deviantart.com/art/Arcane-Circles-Sym...

Native Python Editor for Mac?

I'm currently using IDLE, its decent, but I'd like to know if there're better lightweight IDEs built especially for Mac — free or commercial. ...

Programatically saving an image to a Django ImageField is creating an infinite loop of images

I've got a save method on a model that looks like so: def save(self, force_insert=False, force_update=False): img_url = "http://example.com/%s.jpg" % (self.title) name = urlparse(img_url).path.split('/')[-1] content = urllib.urlretrieve(img_url) self.image.save(name, File(open(content[0])), save=True) super(Test, sel...

How to bundle tkinter?

I am distributing an app that uses the Python/C API. I have all standard python modules in python31.zip which is basically an archive of the Lib folder in the python install directory. Here is the problem - most common modules like sys and io work fine. BUT tkinter does not. I get an error "cannot find module _tkinter". I really need tki...

Tree view GUI widget/gui library that can do multiple icons?

Screenshot I'm looking to recreate this in Python; I can't find a library that seems to have what I need. Are there any GUI libraries that might possibly have this? - I have scoured wxWidgets (which is my preferred gui library) but they have nothing similar. I have a script already that uses a standard wxTreeCtrl but it has no provisi...