Hi,
I need to retrieve a document with MIME type "application/json". I'm using twill to log in to a site and when I attempt to go to the URL pointing to the JSON document and show it, I get this message:
'The HTTP header field "Accept" with value "text/html; */*" could not be parsed.'
I have tried changing the "Accept" field to "app...
Hi all,
i've just downloaded the Yahoo BOSS Mashup framework from http://developer.yahoo.com/search/boss/mashup.html, and I have a problem:
I'm receiving the following error for all examples. For instance, for example.ex3.py:
File "ex3.py", line 33
tb = db.group(by=["ynews$title"], key="dg$diggs", reducer=lambda d1, d2: d1 + d2, a...
I have a Django application with two configured databases first_DB and second_DB
The configurations seems as following
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME' : 'emonitor', # Or path ...
I have a numpy matrix that contains mostly nonzero values, but that occasionally will contain a zero value. I need to be able to:
1.) count the non-zero values in each row, and put that count into a variable that I can use in subsequent operations, perhaps by iterating through row indices and performing the calculations during the itera...
Hi
Level: Beginner
In the following code my 'samePoint' function returns False where i am expecting True. Any hints?
import math
class cPoint:
def __init__(self,x,y):
self.x = x
self.y = y
self.radius = math.sqrt(self.x*self.x + self.y*self.y)
self.angle = math.atan2(self.y,self.x)
def cartesia...
From what I've read about cpython it seems like it does reference counting + something extra to detect/free objects pointing to each other.(Correct me if I'm wrong). Could someone explain the something extra? Also does this guarantee* no cycle leaking? If not is there any research into an algorithm proven to add to reference counting to ...
Sometimes using mixin with multiple inheritance can help us improve reusability of our code.
For example, the following design
class FollowableMixin(object):
def get_followers(self):
...
...
class User(FollowableMixin):
...
may be better reused than simply adding get_followers to User:
class User(object):
de...
I m doing this
def power_two(n, base = -1):
result = 2 ** base
if result < n:
base += 1
power_two(n, base)
else:
if result == n:
print base
else:
print base - 1
what is the pythonic way to find largest power of two less than X number?
EDIT
example: power_two(100) ret...
I want to split a sentence into a list of words.
For English and European languages this is easy, just use split()
>>> "This is a sentence.".split()
['This', 'is', 'a', 'sentence.']
But I also need to deal with sentences in languages such as Chinese that don't use whitespace as word separator.
>>> u"这是一个句子".split()
[u'\u8fd9\u662f\u...
http://pastebin.com/Aa5rJxv8
i have django problem above, i tried to explain
i need to show ratings given by current user to books in user shelves
thanks
...
I'm using pyODBS to connect to Oracle database. Connection and executing SELECT query works fine. The only problem is error on UPDATE query executing. I have table:
CREATE TABLE stud
(num NUMBER(6) NOT NULL,
fname NVARCHAR2(70),
year NUMBER(4),
bday DATE,
plata NUMBER(1) DEFAULT 0 CHECK(plata IN (0,1)),
mb NUMBER...
For the openers, opener = urllib2.build_opener(), if I try to add an header:
request.add_header('if-modified-since',request.headers.get('last-nodified'))
I get the error code:
Traceback (most recent call last):
File "<pyshell#19>", line 1, in <module>
feeddata = opener.open(request)
File "C:\Python27\lib\urllib2.py", line 391,...
I'm building some Python code to read and manipulate deeply nested dicts (ultimately for interacting with JSON services, however it would be great to have for other purposes) I'm looking for a way to easily read/set/update values deep within the dict, without needing a lot of code.
@see also http://stackoverflow.com/questions/3031219...
I have a long-running Python script that I run from the command-line. The script writes progress messages and results to the standard output. I want to capture everything the script write to the standard output in a file, but also see it on the command line. Alternatively, I want the output to go to the file immediately, so I can use tai...
how do i run a python program that is received by a client from server without writing it into a new python file?
...
I am using mechanize and I am trying to select a button from a radio button list. This list has 5 items. How can I select the first item? Docs didn't help me.
>>> br.form
<ClientForm.HTMLForm instance at 0x9ac0d4c>
>>> print(br.form)
<form1 POST http://www.example.com application/x-www-form-urlencoded
<HiddenControl(DD=17010200) (readon...
Hi
Level: Beginner
I'm doing my first steps in Object Oriented programming. The code is aimed at showing how methods are passed up the chain. So when i call UG.say(person, 'but i like') the method say is instructed to call class MITPerson. Given that MITPerson does not contain a say method it will pass it up to class Person. I think t...
Hi I'm new to Python so forgive me if this seems a little obvious but I can't see that it's been asked before.
I'm writing something to 'clean' a URL. In this case all I'm trying to do is return a faked scheme as urlopen won't work without one. However, if I test this with 'www.python.org' It'll return http:///www.python.org. Does anyon...
Hi,
I have a set of png images that I would like to process with Python and associated tools. Each image represents a physical object with known dimensions.
In each image there is a specific feature of the object at a certain pixel/physical location. The location is different for each image.
I would like to impose a polar coordinate s...
Hi,
I have a bunch of frames (generated by a function) that I want to write to a MP3 file using Python. I tried using pymedia but I always get a Segmentation fault.
Doe anyone know an extension to write MP3 files using Python?
Thanks!
...