What is the proper way to set cache control?
Sometimes I see the use of headers[]
self.response.headers["Pragma"]="no-cache"
self.response.headers["Cache-Control"]="no-cache, no-store, must-revalidate, pre-check=0, post-check=0"
self.response.headers["Expires"]="Thu, 01 Dec 1994 16:00:00"
Other times, I see headers.add_header()
self...
Could someone please post a few examples of multi-threaded python? I am searching all over the internet but cannot find a simple, easy-to-replicate tutorial. Simple examples are fine.
I have written a program which takes a few hours to run serially--I am hoping I can bring it's run time down to minutes after multi-threading it.
...
Using the Python Imaging Library, I can call
img.convert("P", palette=Image.ADAPTIVE)
or
img.convert("P", palette=Image.WEB)
but is there a way to convert to an arbitrary palette?
p = []
for i in range(0, 256):
p.append(i, 0, 0)
img.convert("P", palette=p)
where it'll map each pixel to the closest colour found in the image? ...
Hi, this is my first question on StackOverflow, so please tell me how I can improve it in the comments.
I am writing a program to find adapters, and have made a class called 'Adapter'. When I pass in two arguments IDLE gives me an error saying I passed in three! Here is the code and stack trace:
#This is the adapter class for the adapt...
The docs for the python dev server say this about running tasks:
When your app is running in the
development server, task queues are
not processed automatically. Instead,
task queues accrue tasks which you can
examine and execute from the developer
console...
But the release notes for version 1.3.4 of the python sdk (whic...
I'm trying to devise a scheme for validating form fields. I've decided you can pass in a list of validators to each field like,
Field(validators=[email_validator, required_validator])
But then I thought, what if you wanted to or the validators together, rather than anding them? For example, a field that accepts either a Canadian posta...
Is it possible to filter all outgoing connections through a HTTPS or SOCKS proxy? I have a script that users various apis & calls scripts that use mechanize/urllib. I'd like to filter every connection through a proxy, setting the proxy in my 'main' script (the one that calls all the apis). Is this possible?
...
Hi,
I'm trying to write some Python3 to interface with the backend PostgreSQL server on a Raritan Power IQ (http://www.raritan.com/products/power-management/power-iq/) system.
I've used pgAdminIII to connect to the server, and it connects fine with my credentials. I can see the databases, as well as the schemas in each database.
I'm n...
this html is here :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
<div bgcolor="#48486c">
<table width="720" border="0" cellspacing="0" cellpadding="0" align="center" background="http://title.jpg" height="130">
...
hello friends,
i am jaison i like to build an application for land survey process. for that i need to plot points in a canvas for a given gsi file. for example
the points be
a. .b
c. .d .e
these are the 5 points and i need to develop a tool to connect these points by line. while closin...
Hello,
I've got a little problem here.
I'm converting binary to ascii, in order to compress data.
All seems to work fine, but when I convert '11011011' to ascii and try to write it into file, I keep getting error
UnicodeEncodeError: 'charmap' codec can't encode character '\xdb' in position 0: character maps to
Here's my code:
b...
I have little to no formal discrete math training, and have run into a wee bit of an issue. I am trying to write an agent which reads in a human player's (arbitrary) score and scores a point every so often. The agent needs to "lag behind" and "catch up" every so often, so that the human player believes there is some competition going on....
Remember, this is using python.
Well, I was fiddling around with an app I made called Pyline, today. It is a command line-like interface, with some cool features. However, I had an idea while making it: Since its like a "OS", wont it have its own language?
Well, I have seen some articles online on how to make a interpreter, and parser, ...
hi
i need help with python programming:
i need a command which can search all the words between tags from a text file.
for example in the text file has <concept> food </concept>. i need to search all the words between <concept> and </concept> and display them.
can anybody help please.......
...
My list is like
l1 = [ {k1:v1} , {k2:v2}, {v1:k1} ]
Is there any better way to check if any dictionary in the list is having reverse pair?
...
Hi all!
i have installed lxml2.2.2 on windows platform(i m using python version 2.6.5).i tried this simple command:
from lxml.html import parse
p= parse(‘http://www.google.com’).getroot()
but i am getting the following error:
Traceback (most recent call last): File “”, line 1, in p=parse(‘http://www.google.com’).getroot() File “C:...
Possible Duplicate:
Python: Split a string at uppercase letters
I'm trying to figure out how to change TwoWords into Two Words and I can't think of a way to do it. I need to split based on where it's capitalized, that will always be a new word. Does anyone have any suggestions?
In python.
...
Greetings,
By using Django, I want to generate a tar.gz which contains the files below, and render a tar.gz file:
Content from an Ubuntu server:
/home/user/myfolder
/home/user/image.jpg
an xml file from www.mysite.com/foo.xml (which is a dynamicly generated xml file.
Rendered tar.gz file
myfolder/
content/
.....
...
I'm new to python . I want to make a basic auth in a web project , is there any way get HTTP authentication variables like the '$_SERVER['php_auth_user']' in php ?
I'm using the FF's torando server.
...
f = open('boo.txt')
line = f.readline()
print line
f.close()
How can I make it read a different line or a random line everytime I open the script, instead of just printing out the first line eveytime.
...