Howdy - today a weird problem occured to me:
I have a modle class in Django and added a custom property to it that shall not be saved into the database and therefore is not represent in the models structure:
class Category(models.Model):
groups = models.ManyToManyField(Group)
title = defaultdict()
Now, when I'm within the she...
In Django you can use the exclude to create SQL similar to not equal. An example could be.
Model.objects.exclude(status='deleted')
Now this works great and exclude is very flexible. Since I'm a bit lazy, I would like to get that functionality when using get_object_or_404, but I haven't found a way to do this, since you cannot use excl...
The following matches in Idle, but does not match when run in a method in a module file:
import re
re.search('\\bשלום\\b','שלום עולם',re.UNICODE)
while the following matches in both cases:
import re
re.search('שלום','שלום עולם',re.UNICODE)
(Notice that stackoverflow erroneously switches the first and second items in the line above ...
i want to find the square root of a number without using the math module,as i need to call the function some 20k times and dont want to slow down the execution by linking to the math module each time the function is called
is there any faster and easier way for finding square root??
...
Lets say I have an application with a structure such as:
System
set date
set name
set something
Other
set death ray target
calibrate
and I want to have "back" and "next" buttons on a page. The catch is, if you're going in via the "wizard", I want the nav path to be something like "set name" -> "set death ray target" -> "set ...
I'm doing some queries in Python on a large database to get some stats out of the database. I want these stats to be in-memory so other programs can use them without going to a database.
I was thinking of how to structure them, and after trying to set up some complicated nested dictionaries, I realized that a good representation would ...
Hi Guys,
I am trying to build lxml for Python 27 on windows 64 bit machine. I couldn't find lxml egg for Python27 version. So I am compiling it from sources. I am following instructions on this site
http://codespeak.net/lxml/build.html
under static linking section. I am getting error
C:\Documents and Settings\Administrator\Desktop\l...
So I have a Django app that processes test results, and I'm trying to find the median score for a certain assessment. I would think that this would work:
e = Exam.objects.all()
total = e.count()
median = int(round(total / 2))
median_exam = Exam.objects.filter(assessment=assessment.id).order_by('score')[median:1]
median_score = median_ex...
How do I force a GTK window object to stay the same size, even when a table inside of it tries to expand?
I've tried using gtk.SHRINK when attaching children to the table, but the TextViews within the table still keep expanding to way beyond an acceptable width and expanding the window along with it.
...
def start(fileName):
fileReader = open(fileName)
for row in fileReader:
print row,
if __name__ == "__main__":
import sys
if len(sys.argv) <= 1:
print "usage quine /path/to/file"
sys.exit(-1)
fileName = sys.argv[0]
start(fileName)
python quine.py foo
...
I have a model form that I use to update a model.
class Turtle(models.Model):
name = models.CharField(max_length=50, blank=False)
description = models.TextField(blank=True)
class TurtleForm(forms.ModelForm):
class Meta:
model = Turtle
Sometimes I don't need to update the entire model, but only want to update one o...
is opening a large file once reading it completely once to list faster (or) opening smaller files whose total sum of size is equal to large file and loading smaller file into list manupalating one by one faster?
which is faster?? is the difference is time large enough to impact my program??
total time difference of lesser then of 30 se...
$ easy_install-2.6 -d /home/user/lib/python2.6 MySQLdb
Searching for MySQLdb
Reading http://pypi.python.org/simple/MySQLdb/
Couldn't find index page for 'MySQLdb' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
No local packages or download links found for MySQLdb
error: C...
We're using Twisted extensively for apps requiring a great deal of asynchronous io. There are some cases where stuff is cpu bound instead and for that we spawn a pool of processes to do the work and have a system for managing these across multiple servers as well - all done in Twisted. Works great. The problem is that it's hard to bring...
I'm having a attribute on my model to allow the user to order the objects. I have to update the element's order depending on a list, that contains the object's ids in the new order; right now I'm iterating over the whole queryset and set one objects after the other. What would be the easiest/fastest way to do the same with the whole quer...
Many job sites have broken searches that don't let you narrow down jobs by experience level. Even when they do, it's usually wrong. This requires you to wade through hundreds of postings that you can't apply for before finding a relevant one, quite tedious. Since I'd rather focus on writing cover letters etc., I want to write a program t...
I need to compare two strings, containing HTML text. The test should return true if the html strings are equivalent, i.e. differ only in whitespace and comments.
Is there any module that can be used for this task?
...
Can someone make me an example or explain to me how can I paste something to the active window with Python?
I've edited because I didn't know that paste to the clipboard doesnt paste to the active window...
...
I cant seem to list all derived classes using the __subclasses__() method. Here's my directory layout:
import.py
backends
__init__.py
--digger
__init__.py
base.py
test.py
--plugins
plugina_plugin.py
From import.py i'm calling test.py. test.py in turn iterates over all the f...
Hi All,
I've recently been developing on the django platform and have stumbled upon Django Forms (forms.Form/forms.ModelForm) as ways of creating <form> html.
Now, this is brilliant for quick stuff but what I'm trying to do is a little bit more complicated. Consider a DateField - my current form has fields for day, month and year and c...