python

python multi-processing queue: is putting independent from getting?

Is putting an object in a multi-processing queue independent from getting an object from it? In other words, will putting an object block the process P1 if another process P2 is getting from it? Update: I am assuming an infinite queue. ...

django-registration, fix for a glitch

Hello, I am using django-registration version 0.8 I use the default django-registration and Django auth system without any tweak. I did notice a small glitch, once I log in as a user, if I go to the /accounts/login/ , I still get the login entry form, how can I change that it redirect a logged in user to the main root url / instead of...

Python: Animation with PIL

I want an animated picture. But I need a refresh-function because plt.show() always opens a new window. Does anybody have a hint? Thanks! import numpy as np import scipy from scipy import * import matplotlib.pyplot as plt #array aa = [] for x in range(44): aa.append([]) for z in range(44): aa[x].append(3*sin(x/3.0)+2*co...

Django generic relations practice

Hi! i'm developing a authentication backend with object-based permissions for my django-app.I use generic relations between an object and a permission: class GroupPermission(models.Model): content_t= models.ForeignKey(ContentType,related_name='g_content_t') object_id = models.PositiveIntegerField() content_object = generic.G...

How to graphically edit the graph of a mathematical function (with python)?

Is there already a python package allowing to graphically edit the graph of a function? ...

Grouping related search keywords

I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL. Example data: dog food goo...

What's the advantage of queues over pipes when communicating between processes?

What would be the advantage(s) (if any) of using 2 Queues over a Pipe to communicate between processes? I am planning on using the multiprocessing python module. ...

POP3_SSL Not Found in poplib module

What would cause this strange error when trying to use the poplib.POP3_SSL class. Traceback (most recent call last): File "test.py", line 131, in <module> M = poplib.POP3_SSL('XXXXXXXX', 995) AttributeError: 'module' object has no attribute 'POP3_SSL' My environment is Python 2.6, REHL5 I've never run into this problem before a...

How to change wx.Panel background color on MouseOver?

Hello, this code: import wx app = None class Plugin(wx.Panel): def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.SetBackgroundColour((11, 11, 11)) self.name = "plugin" self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver) self.Bind(wx.EVT_LEAVE_W...

How to get data in a histogram bin.

I want to get a list of the data contained in a histogram bin. I am using numpy, and Matplotlib. I know how to traverse the data and check the bin edges. However, I want to do this for a 2D histogram and the code to do this is rather ugly. Does numpy have any constructs to make this easier? For the 1D case, I can use searchsorted()....

Using multilingual and localeurl in django

Using django-multilingual and localeurl. Small sample of my main page view: def main(request): #View for http://www.mysite.com/ name = Dog.objects.all()[0].full_name #this is a translated field return render_to_response("home.html", {"name" : name}) Entering http://www.mysite.com/ redirects me to http://www.mysite.com/ru/ and...

Program web applications in python without a framework?

I am just starting Python and I was wondering how I would go about programming web applications without the need of a framework. I am an experiance PHP developer but I have an urge to try out Python and I usually like to write from scratch without the restriction of a framework. ...

Python multiprocessing process vs. standalone Python VM

Aside from the ease of use of the multiprocessing module when it comes to hooking up processes with communication resources, are there any other differences between spawning multiple processes using multiprocessing compared to using subprocess to launch separate Python VMs ? ...

Changing default encoding of python ?

I have many "can't encode" and "can't decode" problems with python when I run my applications from console. But in Eclipse Pydev IDE, default character encoding is set to utf-8 and I'm fine. I searched around for setting default encoding, and people say that python deletes the sys.setdefaultencoding function on startup and we can not us...

GIS: When and why to use ArcObjects over GDAL programming to work with ArcGIS rasters and vectors?

Im just starting off with GDAL + python to support operations that cannot be done with ArcGIS python geoprocessing scripting. Mainly I am doing spatial modeling/analysis/editing of raster and vector data. I am a bit confused when ArcObject development is required versus when GDAL can be used? Is there functionality of ArcObjects that GD...

IF in the Django template system

How do I do this: {% if thestring %} {% if thestring.find("1") >= 0 %} {% endif %} {% endif %} I am assuming I need to build a template filter? Will that work? ...

PyScripter Rpyc

Hi, maybe somebody could give me a couple guidelines how to install Rpyc to PyScripter. I use PyScripter 1.9.9.7 with Python 2.6. I have tried to google it and found some instructions, but still have not succeeded... Thanks! ...

Extending a list of lists in Python?

I might be missing something about the intended behavior of list extend, but why does the following happen? x = [[],[]] y = [[]] * 2 print x # [[],[]] print y # [[],[]] print x == y # True x[0].extend([1]) y[0].extend([1]) print x # [[1],[]], which is what I'd expect print y # [[1],[1]], wtf? I would guess that t...

Path of current Python instance?

I need to access the Scripts and tcl sub-directories of the currently executing Python instance's installation directory on Windows. What is the best way to locate these directories? ...

How do I unit test a module that relies on urllib2?

I've got a piece of code that I can't figure out how to unit test! The module pulls content from external XML feeds (twitter, flickr, youtube, etc.) with urllib2. Here's some pseudo-code for it: params = (url, urlencode(data),) if data else (url,) req = Request(*params) response = urlopen(req) #check headers, content-length, etc... #par...