d3 = dict(d1, **d2)
I understand that this merges the dictionary. But, is it unique? What if d1 has the same key as d2 but different value? I would like d1 and d2 to be merged, but d1 has priority if there is duplicate key.
...
I've been playing with google visualization annotated timeline and so far I'm comfortable displaying the data and adding annotations, but I'm fairly confused about how to implement getting additional data when the user zooms the chart using either the zoom links at the top of the chart or the timeline below.
A great example of the imple...
I have a QuerySet that I wish to pass to a generic view for pagination:
links = Link.objects.annotate(votes=Count('vote')).order_by('-created')[:300]
This is my "hot" page which lists my 300 latest submissions (10 pages of 30 links each). I want to now sort this QuerySet by an algorithm that HackerNews uses:
(p - 1) / (t + 2)^1.5
p ...
I'm working on a simple Python script that can use subprocess and/or os to execute some commands, which is working fine.
However, when the script exits I'd like to cd the actual Terminal (in this case OS X) so on exit, the new files are ready to use in the directory where the have been created. All the following (subprocess.Popen, os.sy...
In Rubular, I have created a regular expression:
(Prerequisite|Recommended): (\w|-| )*
It matches the bolded:
Recommended: good comfort level with computers and some of the arts.
Summer. 2 credits. Prerequisite:
pre-freshman standing or permission of
instructor. Credit may not be applied
toward engineering degree. S-U
...
I packaged my Python app with py2exe. My app is a wxPython GUI, in which there is an interactive Python shell.
I noticed that I can't do help(whatever) in the shell. I investigated a bit and discovered that after the py2exe process, 3 items were missing from __builtin__. These are help, license, and another one I haven't discovered.
Wh...
Is it possible to perform multi-variate regression in Python using NumPy?
The documentation here suggests that it is, but I cannot find any more details on the topic.
...
is this code going to give me correct values for RSA keys (assuming that the other functions are correct)? im having trouble getting my program to decrypt properly, as in certain blocks are not decrypting properly
this is in python:
import random
def keygen(bits):
p = q = 3
while p == q:
p = random.randint(2**(bits/2-2)...
How can I do this with Firefox or Google Chrome?
ie = win32com.client.Dispatch('InternetExplorer.Application')
ie.visible = 1
ie.navigate('http://google.com')
Is there a way to do it?
ps: I need to use the ReadyState with it... for example while (ie.ReadyState != 4):, or in other words, I need some command that wait until the page lo...
I am building a high school team application using Django.
Here is my working models file:
class Directory(models.Model):
school = models.CharField(max_length=60)
website = models.URLField()
district = models.SmallIntegerField()
conference = models.ForeignKey(Conference)
class Conference(models.Model):
conference_na...
Hi! I've just started using Google's search API to find addresses and the distances between those addresses. I used geopy for this, but, I often had the problem of not getting the correct addresses for my queries. I decided to experiment, therefore, with Google's "Local Search" (http://code.google.com/apis/ajaxsearch/local.html).
Anywa...
I'd like to send a message to a RabbitMQ server and then wait for a reply message (on a "reply-to" queue). Of course, I don't want to wait forever in case the application processing these messages is down - there needs to be a timeout. It sounds like a very basic task, yet I can't find a way to do this. I've now run into this problem wit...
I have a fairly simple PyQt application in which I'm placing instances of a QGraphicsWidget in a QGraphicsGridLayout and want to connect the widgets with lines drawn with a QGraphicsPath. Unfortunately, no matter what I try, I always get (0, 0) back as the position for both the start and end widgets.
I'm constructing the graph with a re...
Basically, I want to take a
Dictionary like { "a":"bar", "b":"blah", "c":"abc", "d":"nada" }
and use it to set variables (in an Object) which have the same name as a key in the dictionary.
class Foo(Object)
{
self.a = ""
self.b = ""
self.c = ""
}
So in the the end self.a = "bar", self.b = "blah", etc... (and key "d" is ...
Possible Duplicate:
Choosing Java vs Python on Google App Engine
We are going to use Google Appengine platform for our next big web project.But we are not sure which flavour to use: Java or Python.
Could you please, advise on cons and pros of each approach? Which is the best way in order to build more scalable and efficient ...
I get an ImportError when running my unittests using Nose and I don't when I just run it standalone. All files referred to here may be seen at http://gist.github.com/395541# .
If I run the test script, importTest-Test.py, directly I get this output:
C:\usr\x\data\src\Python\mmm>python importTest-Test.py
In mmdb
In BusinessLogic
[]
.
-...
I'm writing to many files in a threaded app and I'm creating one handler per file. I have HandlerFactory class that manages the distribution of these handlers. What I'd like to do is that
thread A requests and gets foo.txt's file handle from the HandlerFactory class
thread B requests foo.txt's file handler
handler class recognizes tha...
I'd like to be able to add a restriction to the query if user_id != None ... for example:
"AND user_id = 5"
but I am not sure how to add this into the below function?
Thank you.
def get(id, user_id=None):
query = """SELECT *
FROM USERS
WHERE text LIKE %s AND
id = %s
...
in opened applications?
I want to automate firefox in some web page and I don't have a way to "know" if the page already load completely or if it still loading...
I was thinking about making an OCR to check the status bar... it's difficult ?
For example, when the word DONE appears at the status bar, the program continues to the next ...
This is a simple structure in my project:
MyAPP---
note---
__init__.py
views.py
urls.py
test.py
models.py
auth--
...
template---
auth---
login.html
regist...