I've been a PHP developer for quite awhile, and I've heard good things about using Python for web scripting. After a bit of research, I found mod_python, which integrates with Apache to allow Python Server Pages, which seem very similar to the PHP pages I'm used to. I also found a mod_wsgi which looks similar.
I was wondering which impl...
Does Python's unittest module always report errors in strict correspondence to the execution order of the lines in the code tested? Do errors create the possibility of unexpected changes into the code's variables?
I was baffled by a KeyError reported by unittest. The line itself looks okay. On the last line before execution halted, d...
For example, if this code were contained in a module called some_module
class C:
class C2:
def g(self):
@printNamespaceAbove
def f():
pass
then printNamespaceAbove would be defined so that this code would output something like
[some_module,C,C2,g]
...
When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class?
...
I am trying to design a script for the automation of a very tedious configuration process we had been doing by hand. The configuration process mostly consists of copying files from various ClearCase views, editing their contents in a predictable way, and putting them into a new local tree of directories.
There's also some Protege and ...
I have a CheckLabelTool in a wx.ToolBar and I want a menu to popup directly beneath it on mouse click. I'm trying to get the location of the tool so I can set the position of the menu, but everything I've tried (GetEventObject, GetPosition, etc) gives me the position of the toolbar, so consequently the menu pops under the toolbar, but v...
I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.
For example: The server it connects to could be on any port, and I want to be able to test t...
Hi,
I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one.
First, some context: I have a page that spits out reports of sales data. The data can be filter...
Let's say I have the following classes set up:
class Foo:
def __init__(self, frob, frotz):
self.frobnicate = frob
self.frotz = frotz
class Bar:
def __init__(self, frob, frizzle):
self.frobnicate = frob
self.frotz = 34
self.frazzle = frizzle
How can I (if I can at all) use sup...
How can I cache a Reference Property in Google App Engine?
For example, let's say I have the following models:
class Many(db.Model):
few = db.ReferenceProperty(Few)
class Few(db.Model):
year = db.IntegerProperty()
Then I create many Many's that point to only one Few:
one_few = Few.get_or_insert(year=2009)
Many.get_or_inser...
Currently, django.contrib.comments sends the user to the preview page if there is any error on the form.
I am using comments in the context of a blog and I would much rather that the user stayed on the page they were on if something went wrong with the submission. As far as I can tell though, this is hard-coded in django.contrib.commen...
My data
466.67
465.56
464.44
463.33
462.22
461.11
460.00
458.89
...
I run in Python
sum(/tmp/1,0)
I get an error.
How can you calculate the sum of the values by Python?
...
I have an array of lists of numbers, e.g.:
[0] (0.01, 0.01, 0.02, 0.04, 0.03)
[1] (0.00, 0.02, 0.02, 0.03, 0.02)
[2] (0.01, 0.02, 0.02, 0.03, 0.02)
...
[n] (0.01, 0.00, 0.01, 0.05, 0.03)
What I would like to do is efficiently calculate the mean and standard deviation at each index of a list, across all array elements.
To do the ...
class MainPage(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
tasks_query = Task.all()
tasks = tasks_query.fetch(1000)
if user:
url = users.create_logout_url(self.request.uri)
else:
url = users.create_login_url(self.request.uri)
template_values = {
'tasks': tasks,
...
I'm trying to code a very rudimentary GTD app for myself, not only to get organized, but to get better at coding and get better at Python. I'm having a bit of trouble with the classes however.
Here are the classes I have so far:
class Project:
def __init__(self, name, actions=[]):
self.name = name
self.actions = ...
Example:
>>> convert('CamelCase')
camel_case
...
I'm looking for a web charting library for use with python that has drill-down/clickthrough support for a django project. (Clicking on a portion of the chart, triggers an event/refresh to display new data based on the data point clicked).
Something like what is seen here:
http://blogs.adobe.com/flexdoc/2007/03/chart_data_drill_down_exa...
First the code:
class myClass(object):
def __cmp__(self, other):
return cmp(type(self), type(other)) or cmp(self.__something, other.__something)
Does this produce the same ordering as for other types in python? Is there a correct idiom
for this?
Related question:
A bit of looking around on google I found some pertinent...
I have a list of tuples, each containing a find/replace value that I would like to apply to a string. What would be the most efficient way to do so? I will be applying this iteratively, so performance is my biggest concern.
More concretely, what would the innards of processThis() look like?
x = 'find1, find2, find3'
y = [('find1', 'rep...
I am writing an application in Pylons that relies on the output of some system commands such as traceroute. I would like to display the output of the command as it is generated rather than wait for it to complete and then display all at once.
I found how to access the output of the command in Python with the answer to this question:
H...