I'm using Django 1.2 trunk with South 0.7 and an AutoOneToOneField copied from django-annoying. South complained that the field does not have rules defined and the new version of South no longer has an automatic field type parser. So I read the South documentation and wrote the following definition (basically an exact copy of the OneToOn...
I have a thread that updates some data periodically. I want do visualize the data with matplotlib. When the thread updates the data, the plot should be updated as well. I tried embedding a matplotlib.FigureCanvas(see following snippet) in a QWidget...
class MplSubPlotCanvas(FigureCanvas):
def __init__(self, parent=None):
se...
I'd like to have these lines of code executed on server startup (both development and production):
from django.core import management
management.call_command('syncdb', interactive=False)
Putting it in settings.py doesn't work, as it requires the settings to be loaded already.
Putting them in a view and accessing that view externally ...
This problem is probably embarrassingly simple.
I'm trying to give python a spin. I thought a good way to start doing that would be to create a simple cgi script to process some form data and do some magic. My python script is executed properly by apache using mod_python, and will print out whatever I want it to print out.
My only pro...
I have a Multidimensional array in Python.
How do I go about sorting the second array, by the first - all the while keeping it in the same order?
...
im trying to convert from sqlalchemy (sqlite) to using mongodb. i would like schema vertification. im looking at mongokit, but i want something with similar to mappers, so that it would save from the object's property, and not a dict.
i would like a mapper so that i can use existing objects without modifying them.
...
Please see the following code:
def good():
foo[0] = 9 # why this foo isn't local variable who hides the global one
def bad():
foo = [9, 2, 3] # foo is local, who hides the global one
for func in [good, bad]:
foo = [1,2,3]
print('Before "{}": {}'.format(func.__name__, foo))
func()
print('After "{}": {}'.format(...
I'm trying to find the name of the class that contains method code.
In the example underneath I use self.__class__.__name__, but of course this returns the name of the class of which self is an instance and not class that contains the test() method code. b.test() will print 'B' while I would like to get 'A'.
I looked into the inspect m...
For a Python/Django/Celery based deployment tool, we have the following setup:
We currently use the default Celery setup. (One queue+exchange called "celery".)
Each Task on the queue represents a deployment operation.
Each task for an environment ends with a synchronisation phase that potentially takes (very) long.
The following spec...
Has anyone used Dabo lately? How does it rate vs Boa Constructor, etc? I'm writing a new Python database app and Dabo looks promising, but what's the real-world scoop on it?
Is it used by many developers? It's not talked about very much here on SO, or anywhere, as far as I can tell. I'm just a little concerned that the support community...
I'm using Python 2.6.5 and when I run the following in the Python shell, I get:
>>> print u'Andr\xc3\xa9'
André
>>> print 'Andr\xc3\xa9'
André
>>>
What's the explanation for the above? Given u'Andr\xc3\xa9', how can I display the above value properly in an html page so that it shows André instead of André?
...
I found HTMLParser for sax and xml.minidom for xml. I have a pretty well formed html so I don't need a too strong parser - any suggestions?
...
Hello!
I'm using google appengine and Django. I'm using de djangoforms module and wanted to specify the form instance with the information that comes from the query below.
userquery = db.GqlQuery("SELECT * FROM User WHERE googleaccount = :1", users.get_current_user())
form = forms.AccountForm(data=request.POST or None,instance...
what is the most lightweight way to create a random string of 30 characters like this ? :
ufhy3skj5nca0d2dfh9hwd2tbk9sw1
and an hexadecimal number of 30 digits like this ?:
8c6f78ac23b4a7b8c0182d7a89e9b1
...
I want to remove the first characters from a string. Is there a function that works like this?
>>> a = "BarackObama"
>>> print myfunction(4,a)
ckObama
>>> b = "The world is mine"
>>> print myfunction(6,b)
rld is mine
...
Assume you define a class, which has a method which does some complicated processing:
class A(object):
def my_method(self):
# Some complicated processing is done here
return self
And now you want to use that method on some object from another class entirely. Like, you want to do A.my_method(7).
This is what you'd ...
Hello all!
I am experiencing an error running django unit tests, I've not experienced this before, and have been googling it all afternoon.
I am getting this error in terminal after running django manage.py test:
Error: Database test_unconvention couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured...
I know this has been answered before, but it seems that executing the script directly "python filename.py" does not work. I have Python 2.6.2 on SuSE Linux.
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from multiprocessing import Pool
p = Pool(1)
def f(x):
return x*x
p.map(f, [1, 2, 3])
Command line:
> python example.py
Proce...
Hi,
I am working with geodjango and I want to breakup a 2D Rectangular Polygon into smaller ones.
My input is a big rectangle and I want to subdivide it in smaller rectangles. The sum of the smaller rectangles must be the original rectangle.
All subrectangles should be equal size.
How can I do that?
Thank you.
...
The following unicode and string can exist on their own if defined explicitly:
>>> value_str='Andr\xc3\xa9'
>>> value_uni=u'Andr\xc3\xa9'
If I only have u'Andr\xc3\xa9' assigned to a variable like above, how do I convert it to 'Andr\xc3\xa9' in Python 2.5 or 2.6?
EDIT:
I did the following:
>>> value_uni.encode('latin-1')
'Andr\xc3\...