I'm trying to post a JSON object through a POST. I'm trying to do it as follows:
import json, urllib, urllib2
filename = 'test.json'
race_id = 2530
f = open(filename, 'r')
fdata = json.loads(f.read())
f.close()
prefix = 'localhost:8000'
count = 0
for points in fdata['positions'].iteritems():
print '--' + str(count) + '--------'
...
I am following the tutorial for py2exe from this site http://www.py2exe.org/index.cgi/Tutorial
this is the setup code:
from distutils.core import setup
import py2exe
setup(console=['script.py'])
when I type in cmd:
python setup.py install
I get this:
running install
running build
my script works fine and I even tried it for s...
I am using wxPython to create a taskbar menu. The menu contains some menu items (obviously).
Now I would like to update/change some of these items when a particular item is clicked, while still displaying the menu.
How can I prevent the taskbar menu from disappearing after clicking an item?
The only method I've found that could be us...
Dear Coding Experts,
Edit: Just for clarification I am using python, and would like to do this within python.
I am in the middle of collecting data for a research project at our university. Basically I need to scrape a lot of information from a website that moniters the European Parliament. Here is an example of how the url of one site...
I'm researching software components to use in a future development of a business logic web application. It's gonna be written in Python and we are targeting SQLAlchemy as ORM. The app will be used by other software apps via a REST-like interface over http, possibly using web.py for that part.
For debugging, maintenance, etc we need to d...
I have code that looks something like this:
self.ui.foo.setEnabled(False)
self.ui.bar.setEnabled(False)
self.ui.item.setEnabled(False)
self.ui.item2.setEnabled(False)
self.ui.item3.setEnabled(False)
And I would like to turn it into something like this:
items = [foo,bar,item,item2,item3]
for elm in items:
self.ui.elm.setEnabled(Fa...
I'm trying to match a "#" followed by letters if and only if it's preceded by newline, whitespace or is the first character in a string. The first two I've done, but I'm having a hard time matching if it's the first character in a string. I'm trying to find a use for '\A', but it doesn't work to just add it to the class containing newlin...
I'm currently going through a few tutorials to get myself up and running on Python, but I seem to hit the same problem a few times. The tutorial I'm currently following is Aloha.py in Introduction to Simulation by Norm Matloff.
The problem I'm hitting seems to be in the following code:
import random, sys
class node: # one object of thi...
If I want to detect perspective distorted objects (e.g rectangles) and calculate the correction transformation, what would be a good method?
For example, I have a lot of photos of papers lying on a flat surface (the photos are shot from an angle), and I want to correct the perspective and crop them.
I am thinking of using the OpenCv Py...
In python, I know that looking up a locally scoped variable is significantly faster than looking up a global scoped variable. So:
a = 4
def function()
for x in range(10000):
<do something with 'a'>
Is slower than
def function()
a = 4
for x in range(10000):
<do something with 'a'>
So, when I look at a cla...
I need to strip the character "'" from a string in python. how do I do this? I know there is a simple answer. Really what I am looking for is how to write ' in my code. for example \n = newline.
...
I have a Numpy array that looks like
>>> a
array([[ 3. , 2. , -1. ],
[-1. , 0.1, 3. ],
[-1. , 2. , 3.5]])
I would like to select a value from each row at random, but I would like to exclude the -1 values from the random sampling.
What I do currently is:
x=[]
for i in range(a.shape[0]):
idx=numpy.where(a[i,:]>0...
In Google App Engine, an entity has a Key. A key can be made from a path, in which case str(key) is an opaque hex string. Example:
from google.appengine.ext import db
foo = db.Key.from_path(u'foo', u'bar', _app=u'baz')
print foo
gives
agNiYXpyDAsSA2ZvbyIDYmFyDA
if you set up the right paths to run the code.
So, how can one take ...
Hi everyone.
I'm trying to read a line from a static file and insert it into a template in Google App engine using the Webapp framework. However, the line does not render, not matter what I try. Is there something that I'm overlooking?
main.py:
def get(self):
...
question = randomLine("data/questions.csv")
data = question....
Are there any libraries that provide 3D polyhedra, and support calculating the intersection of two polyhedra?
If it makes a difference, the polyhedra I want to model do not have 'holes' in them.
The focus would be on correctness first and speed a close second!
Ideally this library would:
have existing tidy python bindings
be free-st...
I'm trying to write a shell script that will make several targets into several different paths. I'll pass in a space-separated list of paths and a space-separated list of targets, and the script will make DESTDIR=$path $target for each pair of paths and targets. In Python, my script would look something like this:
for path, target in zi...
I'm trying to use Dumbo/Hadoop to calculate TF-IDF for a bunch of small text
files using this example http://dumbotics.com/2009/05/17/tf-idf-revisited/
To improve efficiency, I've packaged the text files into a sequence
file using Stuart Sierra's tool -- http://stuartsierra.com/2008/04/24/a-million-little-files
The sequence file uses m...
I have to split the file content based on first occurrence of \r\n\r\n
I need flexibility such a way that the lines can just ends with \r\n\r\n or \n\n.
How to split the text?
Example added:
\===================FILE BEGIN==========================================
name: about
title: About
publish: True
order: -1
\r\n
\r\n
examp...
I'm having trouble getting a simple external methods in plone working correctly.
In my extensions folder I have a python script named blast_query.py code below:
def print_query(self, x):
print(x)
my external methods looks like:
Id: run_blast_query
Title:
Module Name: blast_query
Function Name: print_query
My p...
Consider a tier of N-many subscribers, all connected to a direct exchange using identical queue name and routing key values. This creates a load-balanced system where an inbound message is send round-robin to 1 of the subscribers. This works very well for dealing with scale-out issues as more subscribers can be added as load increases ...