I am trying to design tables to buildout a follower relationship.
Say I have a stream of 140char records that have user, hashtag and other text.
Users follow other users, and can also follow hashtags.
I am outlining the way I've designed this below, but there are two limitaions in my design. I was wondering if others had smarter ways...
Hello guys,
I am trying to do some kind of image collection for some research i am currently working on, what i want to do is to have a quicker way to extract the part of interest from thousands of images in an efficient and fast way, my view of the program is that to open continually images and i select the part of interest( as a rectan...
I have two models, Order and UserProfile. Each Order has a ForeignKey to UserProfile, to associate it with that user.
On the django admin page for each Order, I'd like to display the UserProfile associated with it, for easy processing of information.
I have tried inlines:
class UserInline(admin.TabularInline):
model = UserProfile...
Hi folks,
I have been looking through ths hashlib documentation but haven't found anything talking about using salt when hashing data.
Help would be great.
...
I have the simplest problem to implement, but so far I have not been able to get my head around a solution in Python.
I have built a table that looks similar to this one:
501 - ASIA
1262 - EUROPE
3389 - LATAM
5409 - US
I will test a certain value to see if it falls within these ranges, 389 -> ASIA, 1300 -> LATAM, 5400 -> US. A value ...
I am starting use Memcached to make my website faster.
For constant data in my database I use this:
from django.core.cache import cache
cache_key = 'regions'
regions = cache.get(cache_key)
if result is None:
"""Not Found in Cache"""
regions = Regions.objects.all()
cache.set(cache_key, regions, 2592000) #(25...
I am developing an application on the Google App Engine using Python (and Django, if that matters).
Which mock object framework should I help to assist with unit tests? I see there are a number of standalone projects (i.e. http://python-mock.sourceforge.net), but I'm not sure if there's something built-in that I can use.
Any ideas?
...
Hi everyone.
I am trying to print a XML file using lxml and Python.
Here is the code:
>>> from lxml import etree
>>> root = etree.Element('root')
>>> child = etree.SubElement(root, 'child')
>>> print etree.tostring(root, pretty_print = True, xml_declaration = True, encoding = None)
Output:
<?xml version='1.0' encoding='ASCII'?>
<r...
Possible Duplicate:
least astonishment in python: the mutable default argument
Can you help me understand of the behaviour and implications of the python __init__ constructor. It seems like when there is an optional parameter and you try and set an existing object to a new object the optional value of the existing object is p...
There doesn't seem to be any great instructions for setting this up. Does anyone have any good instructions? I am a linux noob so be gentle. I did see another post that is similar, but no real answer.
I have a couple of problems.
FreeTDS doesn't "seem" to be working. I am trying to connect and I get the following message using t...
Here's the code I'm running:
import re
FIND_TERM = r'C:\\Program Files\\Microsoft SQL Server\\90\\DTS\\Binn\\DTExec\.exe'
rfind_term = re.compile(FIND_TERM,re.I)
REPLACE_TERM = 'C:\\Program Files\\Microsoft SQL Server\\100\\DTS\\Binn\\DTExec.exe'
test = r'something C:\Program Files\Microsoft SQL Server\90\DTS\Binn\DTExec.exe somethin...
Hello,
is it possible to use python to create flash like browser games? (Actually I want to use it for an economic simulation, but it amounts to the same as a browser game)
Davoud
...
Suppose from index.py, i have post file #####.fasta to display file. I want to change ####.fasta file extension to ####.aln in display file. How can i do it?
I am working right now on python cgi.
Thanks for listening
...
In Django 1.1 I was able to produce the SQL used by a QuerySet with this notation:
QuerySet.query.as_sql()
In Django 1.2, this raises as AttributeError.
Anyone know the Django 1.2 equivalent of that method?
Thanks
...
Hey Guys,
So I have 2 variables that I want to enter into my scoring function
but each variable has its own list of integers that I would like to
test.
I want my variable x to be an integer from this list:
[34,40,45,73,52,64,55,60,65,61,62,63,41,42,43,44]
and I want my variable y to be an integer from this list [100,200,300]
I ...
I have a list of integers and I need to count how many of them are > 0.
I'm currently doing it with a list comprehension that looks like this:
sum([1 for x in frequencies if x > 0])
It seems like a decent comprehension but I don't really like the "1"; it seems like a bit of a magic number. Is there a more Pythonish way to do this?
...
Hi all,
I have difficulty especially in installing MySQLdb module (MySQL-python-1.2.3c1), to connect to the MySQL in MAMP stack.
I've done a number of things such as copying the mysql include directory and library (including plugin) from a fresh installation of mysql (version 5.1.47) to the one inside MAMP (version 5.1.37).
Now, the M...
I'm using Python to read and write SAS datasets, using pyodbc and the SAS ODBC drivers. I can load the data perfectly well, but when I save the data, using something like:
cursor.execute('insert into dataset.test VALUES (?)', u'testing')
... I get a pyodbc.Error: ('HY004', '[HY004] [Microsoft][ODBC Driver Manager] SQL data type out o...
I tried to use mlab.path(path,'/my/path') but failed. Got NameError: name 'path' is not defined in python. Anyone has an idea?
...
OK this is a 2 part question, I've seen and searched for several methods to get a list of unique values for a class and haven't been practically happy with any method so far.
So anyone have a simple example code of getting unique values for instance for this code. Here is my super slow example.
class LinkRating2(db.Model):
user = d...