title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
listlengths
1
5
How best to draw in the console?
106,850
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
5
2008-09-20T02:45:45Z
106,860
<p>This <a href="http://stackoverflow.com/questions/43267/good-resources-for-writing-console-style-applications-for-windows">previous StackOverflow question</a> should give you some more useful information.</p>
0
2008-09-20T02:51:49Z
[ "python", "console", "stdout" ]
How best to draw in the console?
106,850
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
5
2008-09-20T02:45:45Z
107,700
<p>You can use curses.</p> <p>It has a <a href="http://adamv.com/dev/python/curses/" rel="nofollow" title="WCurses">Windows Port</a> and <a href="https://docs.python.org/library/curses.html" rel="nofollow" title="Unix Curses">Unix Port</a>, and plenty of <a href="https://docs.python.org/howto/curses.html" rel="nofollo...
1
2008-09-20T09:15:16Z
[ "python", "console", "stdout" ]
How best to draw in the console?
106,850
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
5
2008-09-20T02:45:45Z
287,791
<p>There are actually <strong>two</strong> libraries that solve this, the older <a href="https://docs.python.org/library/curses.html" rel="nofollow">curses</a> and the newer <a href="http://www.jedsoft.org/slang/" rel="nofollow">S-Lang</a>. Curses has a tendency to make buggy line art, especially on Windows and on unic...
3
2008-11-13T18:30:52Z
[ "python", "console", "stdout" ]
How best to draw in the console?
106,850
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
5
2008-09-20T02:45:45Z
1,176,195
<p>Try <a href="http://urwid.org/" rel="nofollow">urwid</a>. One of the examples bundled with urwid is <a href="https://github.com/wardi/urwid/blob/master/examples/graph.py" rel="nofollow">a simulator for animated bar graphs</a>. The bar graphs clear the screen well, without leaving artifacts of the old "frame".</p>
1
2009-07-24T07:16:41Z
[ "python", "console", "stdout" ]
How best to draw in the console?
106,850
<p>I'm trying to write a console (as in terminal, not gaming console) pong game in python and I'm having trouble figuring how best to (re)draw the game.</p> <p>I was thinking of having an 2d array as a sort of bitmap, editing the array to reflect the ball/paddles new positions and then casting each row to a string and...
5
2008-09-20T02:45:45Z
30,834,903
<p>I have recently been developing an ASCII animation package (<a href="https://github.com/peterbrittain/asciimatics" rel="nofollow">https://github.com/peterbrittain/asciimatics</a>) which faced similar issues. While it doesn't have everything you need to write a game, it should give you most of what you want.</p> <p...
0
2015-06-14T21:48:08Z
[ "python", "console", "stdout" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
107,427
<p><strong>edit</strong>: This answer works, but nowadays you should just use the <a href="http://docs.python-requests.org/en/latest/index.html" rel="nofollow">requests</a> library as mentioned by other answers below.</p> <hr> <p>Use <a href="https://docs.python.org/2/library/httplib.html" rel="nofollow">httplib</a>....
94
2008-09-20T06:45:45Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
358,075
<p>Probably easier: use urllib or urllib2.</p> <pre><code>&gt;&gt;&gt; import urllib &gt;&gt;&gt; f = urllib.urlopen('http://google.com') &gt;&gt;&gt; f.info().gettype() 'text/html' </code></pre> <p>f.info() is a dictionary-like object, so you can do f.info()['content-type'], etc.</p> <p><a href="http://docs.python....
-4
2008-12-11T00:11:48Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
779,985
<p>As an aside, when using the httplib (at least on 2.5.2), trying to read the response of a HEAD request will block (on readline) and subsequently fail. If you do not issue read on the response, you are unable to send another request on the connection, you will need to open a new one. Or accept a long delay between ...
1
2009-04-23T01:39:05Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
2,070,916
<p><a href="https://docs.python.org/2/library/urllib2.html" rel="nofollow">urllib2</a> can be used to perform a HEAD request. This is a little nicer than using httplib since urllib2 parses the URL for you instead of requiring you to split the URL into host name and path.</p> <pre><code>&gt;&gt;&gt; import urllib2 &gt...
99
2010-01-15T10:50:52Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
2,630,687
<p>I have found that httplib is slightly faster than urllib2. I timed two programs - one using httplib and the other using urllib2 - sending HEAD requests to 10,000 URL's. The httplib one was faster by several minutes. <strong>httplib</strong>'s total stats were: real 6m21.334s ...
1
2010-04-13T15:10:00Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
4,421,712
<p>Just:</p> <pre><code>import urllib2 request = urllib2.Request('http://localhost:8080') request.get_method = lambda : 'HEAD' response = urllib2.urlopen(request) response.info().gettype() </code></pre> <p>Edit: I've just came to realize there is httplib2 :D</p> <pre><code>import httplib2 h = httplib2.Http() resp =...
15
2010-12-12T12:45:54Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
7,387,509
<p>I believe the <a href="http://docs.python-requests.org/en/latest/index.html">Requests</a> library should be mentioned as well.</p>
33
2011-09-12T12:02:47Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
9,227,931
<pre><code>import httplib import urlparse def unshorten_url(url): parsed = urlparse.urlparse(url) h = httplib.HTTPConnection(parsed.netloc) h.request('HEAD', parsed.path) response = h.getresponse() if response.status/100 == 3 and response.getheader('Location'): return response.getheader('Lo...
2
2012-02-10T12:39:59Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
12,997,216
<p>Obligatory <a href="http://docs.python-requests.org/en/latest/"><code>Requests</code></a> way:</p> <pre><code>import requests resp = requests.head("http://www.google.com") print resp.status_code, resp.text, resp.headers </code></pre>
38
2012-10-21T11:00:49Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
15,420,705
<p>For completeness to have a Python3 answer equivalent to the accepted answer using <em>httplib</em>.</p> <p>It is basically the same code just that the library isn't called <em>httplib</em> anymore but <em>http.client</em></p> <pre><code>from http.client import HTTPConnection conn = HTTPConnection('www.google.com'...
6
2013-03-14T21:38:44Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
How do you send a HEAD HTTP request in Python 2?
107,405
<p>What I'm trying to do here is get the headers of a given URL so I can determine the MIME type. I want to be able to see if <code>http://somedomain/foo/</code> will return an HTML document or a JPEG image for example. Thus, I need to figure out how to send a HEAD request so that I can read the MIME type without havin...
97
2008-09-20T06:38:38Z
16,960,321
<p>And yet another approach (similar to Pawel answer):</p> <pre><code>import urllib2 import types request = urllib2.Request('http://localhost:8080') request.get_method = types.MethodType(lambda self: 'HEAD', request, request.__class__) </code></pre> <p>Just to avoid having unbounded methods at instance level.</p>
0
2013-06-06T10:55:31Z
[ "python", "python-2.7", "http", "http-headers", "content-type" ]
XML-RPC: best way to handle 64-bit values?
107,616
<p>So the official XML-RPC standard doesn't support 64-bit values. But in these modern times, 64-bit values are increasingly common.</p> <p>How do you handle these? What XML-RPC extensions are the most common? What language bindings are there? I'm especially interested in Python and C++, but all information is app...
3
2008-09-20T08:27:11Z
107,637
<p>I don't know anything about how XMLRPC could be extended but I did find <a href="http://mail.python.org/pipermail/python-list/2006-May/381032.html" rel="nofollow">this mail</a> about the subject:</p> <blockquote> <p>In XML-RPC, everything is transmitted as a string, so I don't think that choice is really that...
0
2008-09-20T08:35:45Z
[ "c++", "python", "64bit", "xml-rpc" ]
XML-RPC: best way to handle 64-bit values?
107,616
<p>So the official XML-RPC standard doesn't support 64-bit values. But in these modern times, 64-bit values are increasingly common.</p> <p>How do you handle these? What XML-RPC extensions are the most common? What language bindings are there? I'm especially interested in Python and C++, but all information is app...
3
2008-09-20T08:27:11Z
108,032
<p>Some libraries support 64 bits extensions, indeed, but there doesn't seem to be a standard. <a href="http://xmlrpc-c.sourceforge.net/" rel="nofollow">xmlrpc-c</a>, for example, has a so called i8 but it doesn't work with python (at least not by default).</p> <p>I would recommend to either:</p> <ul> <li>Convert the...
7
2008-09-20T12:29:16Z
[ "c++", "python", "64bit", "xml-rpc" ]
XML-RPC: best way to handle 64-bit values?
107,616
<p>So the official XML-RPC standard doesn't support 64-bit values. But in these modern times, 64-bit values are increasingly common.</p> <p>How do you handle these? What XML-RPC extensions are the most common? What language bindings are there? I'm especially interested in Python and C++, but all information is app...
3
2008-09-20T08:27:11Z
113,493
<p>The use of "i8" as a data-type is becoming more and more common. I recently added this to my Perl XML-RPC module (<a href="http://metacpan.org/pod/RPC::XML" rel="nofollow">http://metacpan.org/pod/RPC::XML</a>) in response to a request from a large group that needed it in order to work with a server written in Java. ...
1
2008-09-22T06:42:22Z
[ "c++", "python", "64bit", "xml-rpc" ]
XML-RPC: best way to handle 64-bit values?
107,616
<p>So the official XML-RPC standard doesn't support 64-bit values. But in these modern times, 64-bit values are increasingly common.</p> <p>How do you handle these? What XML-RPC extensions are the most common? What language bindings are there? I'm especially interested in Python and C++, but all information is app...
3
2008-09-20T08:27:11Z
5,447,801
<p><a href="http://www.xml-rpc.net/" rel="nofollow">XML-RPC.NET</a> has supported &lt;i8&gt; since release 2.5.0 (5th September 2010).</p>
0
2011-03-27T07:20:40Z
[ "c++", "python", "64bit", "xml-rpc" ]
How can I unit test responses from the webapp WSGI application in Google App Engine?
107,675
<p>I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using <a href="http://code.google.com/p/gaeunit">GAEUnit</a>. How can I do this? </p> <p>I'd like to use the webapp framework and GAEUnit, which runs wit...
10
2008-09-20T08:56:59Z
107,753
<p>Actually WebTest does work within the sandbox, as long as you comment out </p> <pre><code>import webbrowser </code></pre> <p>in webtest/__init__.py </p>
1
2008-09-20T09:44:18Z
[ "python", "unit-testing", "google-app-engine" ]
How can I unit test responses from the webapp WSGI application in Google App Engine?
107,675
<p>I'd like to unit test responses from the Google App Engine webapp.WSGIApplication, for example request the url '/' and test that the responses status code is 200, using <a href="http://code.google.com/p/gaeunit">GAEUnit</a>. How can I do this? </p> <p>I'd like to use the webapp framework and GAEUnit, which runs wit...
10
2008-09-20T08:56:59Z
114,449
<p>I have added a <a href="http://code.google.com/p/gaeunit/source/browse/#svn/trunk/sample_app">sample application</a> to the GAEUnit project which demonstrates how to write and execute a web test using GAEUnit. The sample includes a slightly modified version of the '<a href="http://pythonpaste.org/webtest/index.html...
10
2008-09-22T12:02:08Z
[ "python", "unit-testing", "google-app-engine" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
107,717
<p>From <a href="http://mail.python.org/pipermail/tutor/2003-November/026645.html">Magnus Lycka answer on a mailing list</a>:</p> <blockquote> <p>You can skip buffering for a whole python process using "python -u" (or#!/usr/bin/env python -u etc) or by setting the environment variable PYTHONUNBUFFERED.</p> ...
251
2008-09-20T09:24:31Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
107,720
<p>Yes, it is.</p> <p>You can disable it on the commandline with the "-u" switch.</p> <p>Alternatively, you could call .flush() on sys.stdout on every write (or wrap it with an object that does this automatically)</p>
24
2008-09-20T09:25:36Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
107,721
<p>Yes, it is enabled by default. You can disable it by using the -u option on the command line when calling python.</p>
5
2008-09-20T09:26:19Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
107,746
<p>One way to get unbuffered output would be to use <code>sys.stderr</code> instead of <code>sys.stdout</code> or to simply call <code>sys.stdout.flush()</code> to explicitly force a write to occur.</p> <p>You could easily redirect everything printed by doing:</p> <pre><code>import sys; sys.stdout = sys.stderr print ...
4
2008-09-20T09:40:13Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
107,854
<p>You can create an unbuffered file and assign this file to sys.stdout.</p> <pre><code>import sys myFile= open( "a.log", "w", 0 ) sys.stdout= myFile </code></pre> <p>You can't magically change the system-supplied stdout; since it's supplied to your python program by the OS.</p>
2
2008-09-20T10:39:09Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
181,654
<pre><code># reopen stdout file descriptor with write mode # and 0 as the buffer size (unbuffered) sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) </code></pre> <p>Credits: "Sebastian", somewhere on the Python mailing list.</p>
58
2008-10-08T07:23:10Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
1,736,047
<p>You can also use fcntl to change the file flags in-fly.</p> <pre><code>fl = fcntl.fcntl(fd.fileno(), fcntl.F_GETFL) fl |= os.O_SYNC # or os.O_DSYNC (if you don't care the file timestamp updates) fcntl.fcntl(fd.fileno(), fcntl.F_SETFL, fl) </code></pre>
5
2009-11-15T00:01:01Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
3,678,114
<pre><code>def disable_stdout_buffering(): # Appending to gc.garbage is a way to stop an object from being # destroyed. If the old sys.stdout is ever collected, it will # close() stdout, which is not good. gc.garbage.append(sys.stdout) sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) # Then thi...
10
2010-09-09T15:37:53Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
11,276,965
<p>Variant that works without crashing (at least on win32; python 2.7, ipython 0.12) then called subsequently (multiple times):</p> <pre><code>def DisOutBuffering(): if sys.stdout.name == '&lt;stdout&gt;': sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) if sys.stderr.name == '&lt;stderr&gt;': ...
4
2012-06-30T19:20:08Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
14,729,823
<p>I would rather put my answer in <a href="http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print">How to flush output of Python print?</a> or in <a href="http://stackoverflow.com/questions/3895481/pythons-print-function-that-flushes-the-buffer-when-its-called">Python&#39;s print function that f...
31
2013-02-06T13:05:23Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
17,047,064
<p>(I've posted a comment, but it got lost somehow. So, again:)</p> <ol> <li><p>As I noticed, CPython (at least on Linux) behaves differently depending on where the output goes. If it goes to a tty, then the output is flushed after each '<code>\n'</code> <br/>If it goes to a pipe/process, then it is buffered and you c...
3
2013-06-11T14:47:38Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
23,034,580
<p>The following works in Python 2.6, 2.7, and 3.2:</p> <pre><code>import os import sys buf_arg = 0 if sys.version_info[0] == 3: os.environ['PYTHONUNBUFFERED'] = '1' buf_arg = 1 sys.stdout = os.fdopen(sys.stdout.fileno(), 'a+', buf_arg) sys.stderr = os.fdopen(sys.stderr.fileno(), 'a+', buf_arg) </code></pre>
6
2014-04-12T18:43:28Z
[ "python", "stdout", "buffered" ]
Disable output buffering
107,705
<p>Is output buffering enabled by default in Python's interpreter for <code>sys.stdout</code>?</p> <p>If the answer is positive, what are all the ways to disable it?</p> <p>Suggestions so far:</p> <ol> <li>Use the <code>-u</code> command line switch</li> <li>Wrap <code>sys.stdout</code> in an object that flushes aft...
285
2008-09-20T09:17:20Z
31,170,728
<p>You can also run Python with <a href="https://www.gnu.org/software/coreutils/manual/html_node/stdbuf-invocation.html" rel="nofollow" title="stdbuf">stdbuf</a> utility:</p> <p><code>stdbuf -oL python &lt;script&gt;</code></p>
3
2015-07-01T20:09:53Z
[ "python", "stdout", "buffered" ]
PLY: Token shifting problem in C parser
108,009
<p>I'm writing a C parser using PLY, and recently ran into a problem. This code:</p> <pre><code>typedef int my_type; my_type x; </code></pre> <p>Is correct C code, because my_type is defined as a type previously to being used as such. I handle it by filling a type symbol table in the parser that gets used by the lexe...
3
2008-09-20T12:14:41Z
108,033
<p>I think you need to move the check for whether an ID is a TYPEID from c_lexer.py to c_parser.py.</p> <p>As you said, since the parser is looking ahead 1 token, you can't make that decision in the lexer.</p> <p>Instead, alter your parser to check ID's to see if they are TYPEID's in declarations, and, if they aren't...
1
2008-09-20T12:31:30Z
[ "python", "parsing", "yacc", "ply" ]
PLY: Token shifting problem in C parser
108,009
<p>I'm writing a C parser using PLY, and recently ran into a problem. This code:</p> <pre><code>typedef int my_type; my_type x; </code></pre> <p>Is correct C code, because my_type is defined as a type previously to being used as such. I handle it by filling a type symbol table in the parser that gets used by the lexe...
3
2008-09-20T12:14:41Z
108,054
<p>Not sure why you're doing that level of analysis in your lexer.</p> <p>Lexical analysis should probably be used to separate the input stream into lexical tokens (number, line-change, keyword and so on). It's the parsing phase that should be doing that level of analysis, including table lookups for typedefs and suc...
3
2008-09-20T12:47:23Z
[ "python", "parsing", "yacc", "ply" ]
PLY: Token shifting problem in C parser
108,009
<p>I'm writing a C parser using PLY, and recently ran into a problem. This code:</p> <pre><code>typedef int my_type; my_type x; </code></pre> <p>Is correct C code, because my_type is defined as a type previously to being used as such. I handle it by filling a type symbol table in the parser that gets used by the lexe...
3
2008-09-20T12:14:41Z
108,482
<p>With <a href="http://groups.google.com/group/ply-hack/tree/browse_frm/thread/cf31e8334801eabd/b9cdf4a6682635c1?rnum=1&amp;_done=%2Fgroup%2Fply-hack%2Fbrowse_frm%2Fthread%2Fcf31e8334801eabd%3F#doc_5c415da045e77a6e" rel="nofollow">some help</a> from Dave Beazley (PLY's creator), my problem was solved.</p> <p>The idea...
2
2008-09-20T15:28:02Z
[ "python", "parsing", "yacc", "ply" ]
How to apply bold style to a specific word in Excel file using Python?
108,134
<p>I am using <code>pyexcelerator</code> Python module to generate Excel files. I want to apply bold style to part of cell text, but not to the whole cell. How to do it?</p>
3
2008-09-20T13:20:50Z
108,204
<p>This is an example from Excel documentation:</p> <pre><code>With Worksheets("Sheet1").Range("B1") .Value = "New Title" .Characters(5, 5).Font.Bold = True End With </code></pre> <p>So the Characters property of the cell you want to manipulate is the answer to your question. It's used as Characters(<em>start...
1
2008-09-20T13:54:04Z
[ "python", "excel", "xlwt", "pyexcelerator" ]
How to apply bold style to a specific word in Excel file using Python?
108,134
<p>I am using <code>pyexcelerator</code> Python module to generate Excel files. I want to apply bold style to part of cell text, but not to the whole cell. How to do it?</p>
3
2008-09-20T13:20:50Z
109,724
<p>Found example here: <a href="http://www.answermysearches.com/generate-an-excel-formatted-file-right-in-python/122/" rel="nofollow">Generate an Excel Formatted File Right in Python</a></p> <p>Notice that you make a font object and then give it to a style object, and then provide that style object when writing to the...
2
2008-09-20T23:10:13Z
[ "python", "excel", "xlwt", "pyexcelerator" ]
Union and Intersect in Django
108,193
<pre><code>class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) </code></pre> <p>Simple models just to ask my question.</p> <p>I wonder how can i query blogs using tags in two different ways.</p> <u...
30
2008-09-20T13:46:52Z
108,404
<p>You could use Q objects for #1:</p> <pre><code># Blogs who have either hockey or django tags. from django.db.models import Q Blog.objects.filter( Q(tags__name__iexact='hockey') | Q(tags__name__iexact='django') ) </code></pre> <p>Unions and intersections, I believe, are a bit outside the scope of the Django ORM...
19
2008-09-20T15:01:12Z
[ "python", "django", "django-models", "django-views", "tagging" ]
Union and Intersect in Django
108,193
<pre><code>class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) </code></pre> <p>Simple models just to ask my question.</p> <p>I wonder how can i query blogs using tags in two different ways.</p> <u...
30
2008-09-20T13:46:52Z
108,500
<p>I've tested these out with Django 1.0:</p> <p>The "or" queries:</p> <pre><code>Blog.objects.filter(tags__name__in=['tag1', 'tag2']).distinct() </code></pre> <p>or you could use the Q class:</p> <pre><code>Blog.objects.filter(Q(tags__name='tag1') | Q(tags__name='tag2')).distinct() </code></pre> <p>The "and" quer...
15
2008-09-20T15:33:55Z
[ "python", "django", "django-models", "django-views", "tagging" ]
Union and Intersect in Django
108,193
<pre><code>class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) </code></pre> <p>Simple models just to ask my question.</p> <p>I wonder how can i query blogs using tags in two different ways.</p> <u...
30
2008-09-20T13:46:52Z
110,437
<p>Please don't reinvent the wheel and use <a href="http://code.google.com/p/django-tagging/">django-tagging application</a> which was made exactly for your use case. It can do all queries you describe, and much more.</p> <p>If you need to add custom fields to your Tag model, you can also take a look at <a href="http:...
9
2008-09-21T07:03:07Z
[ "python", "django", "django-models", "django-views", "tagging" ]
Union and Intersect in Django
108,193
<pre><code>class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) </code></pre> <p>Simple models just to ask my question.</p> <p>I wonder how can i query blogs using tags in two different ways.</p> <u...
30
2008-09-20T13:46:52Z
4,604,096
<p>This will do the trick for you</p> <pre><code>Blog.objects.filter(tags__name__in=['tag1', 'tag2']).annotate(tag_matches=models.Count(tags)).filter(tag_matches=2) </code></pre>
5
2011-01-05T12:45:41Z
[ "python", "django", "django-models", "django-views", "tagging" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
108,547
<p>Enums have been proposed for inclusion into the language before, but were rejected (see <a href="http://www.python.org/dev/peps/pep-0354/" rel="nofollow" title="PEP 354">http://www.python.org/dev/peps/pep-0354/</a>), though there are existing packages you could use instead of writing your own implementation:</p> <u...
5
2008-09-20T15:51:51Z
[ "python", "enums" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
108,549
<p>The builtin way to do enums is:</p> <pre><code>(FOO, BAR, BAZ) = range(3) </code></pre> <p>which works fine for small sets, but has some drawbacks:</p> <ul> <li>you need to count the number of elements by hand</li> <li>you can't skip values </li> <li>if you add one name, you also need to update the range number</...
2
2008-09-20T15:52:20Z
[ "python", "enums" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
108,556
<p>What I see more often is this, in top-level module context:</p> <pre><code>FOO_BAR = 'FOO_BAR' FOO_BAZ = 'FOO_BAZ' FOO_QUX = 'FOO_QUX' </code></pre> <p>...and later...</p> <pre><code>if something is FOO_BAR: pass # do something here elif something is FOO_BAZ: pass # do something else elif something is FOO_QUX: pa...
3
2008-09-20T15:58:02Z
[ "python", "enums" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
108,557
<p>There's a lot of good discussion <a href="http://stackoverflow.com/questions/36932/whats-the-best-way-to-implement-an-enum-in-python">here</a>. </p>
3
2008-09-20T15:58:10Z
[ "python", "enums" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
108,816
<p>The most common enum case is enumerated values that are part of a State or Strategy design pattern. The enums are specific states or specific optional strategies to be used. In this case, they're almost always part and parcel of some class definition</p> <pre><code>class DoTheNeedful( object ): ONE_CHOICE = 1...
4
2008-09-20T17:32:17Z
[ "python", "enums" ]
How should I best emulate and/or avoid enum's in Python?
108,523
<p>I've been using a small class to emulate Enums in some Python projects. Is there a better way or does this make the most sense for some situations?</p> <p>Class code here:</p> <pre><code>class Enum(object): '''Simple Enum Class Example Usage: &gt;&gt;&gt; codes = Enum('FOO BAR BAZ') # codes.BAZ will be 2 and so on...
6
2008-09-20T15:42:39Z
674,652
<p>I started with something that looks a lot like S.Lott's answer but I only overloaded 'str' and 'eq' (instead of the whole object class) so I could print and compare the enum's value.</p> <pre><code>class enumSeason(): Spring = 0 Summer = 1 Fall = 2 Winter = 3 def __init__(self, Type): se...
1
2009-03-23T18:28:48Z
[ "python", "enums" ]
Topological sort, recursive, using generators
108,586
<p>Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... </p> <pre><code>A = { 'a' : dict(b=1, c=1), 'c' : dict(d=1), 'd' : dict(e=1,f=1,g=1), 'h' : dict(j=1) } </code></pre> <p>I'd like to have a top-down, recursive solution to let's say...
3
2008-09-20T16:07:18Z
108,606
<p>Try this:</p> <pre><code>#!/usr/bin/env python def get_all(D, k): yield k for ii in D.get(k, []): for jj in get_all(D, ii): yield jj A = { 'a' : dict(b=1, c=1), 'c' : dict(d=1), 'd' : dict(e=1,f=1,g=1), 'h' : dict(j=1) } for ii in get_all(A,'a'): print ii </code></...
4
2008-09-20T16:18:00Z
[ "python", "recursion", "generator", "topology" ]
Topological sort, recursive, using generators
108,586
<p>Data: a dependency list, already verified to be acyclic. So here, 'a' depends on 'b','c' (c depends on d), etc... </p> <pre><code>A = { 'a' : dict(b=1, c=1), 'c' : dict(d=1), 'd' : dict(e=1,f=1,g=1), 'h' : dict(j=1) } </code></pre> <p>I'd like to have a top-down, recursive solution to let's say...
3
2008-09-20T16:07:18Z
108,852
<p>Both answers give the same result, but if my reading of the question is correct give the wrong answer to a simple alteration to the given graph - if you add a dependency on 'c' from 'b' (which doesn't introduce a cycle as the graph is directed) the output is: <code> a c d e g f b d e g f </code></p> <p>which isn't ...
6
2008-09-20T17:43:51Z
[ "python", "recursion", "generator", "topology" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
108,939
<p>Presumably your hack was something like this:</p> <pre><code># Deleting all messages older than "earliest_date" q = db.GqlQuery("SELECT * FROM Message WHERE create_date &lt; :1", earliest_date) results = q.fetch(1000) while results: db.delete(results) results = q.fetch(1000, len(results)) </code></pre> <p...
9
2008-09-20T18:34:42Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
109,018
<p>Unfortunately, there's no way to easily do a bulk delete. Your best bet is to write a script that deletes a reasonable number of entries per invocation, and then call it repeatedly - for example, by having your delete script return a 302 redirect whenever there's more data to delete, then fetching it with "wget --ma...
3
2008-09-20T19:03:04Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
118,828
<p>The <a href="http://groups.google.com/group/google-appengine/browse_thread/thread/ec0800a3ca92fe69#" rel="nofollow">official answer</a> from Google is that you have to delete in chunks spread over multiple requests. You can use AJAX, <a href="http://en.wikipedia.org/wiki/Meta_refresh" rel="nofollow">meta refresh</a>...
4
2008-09-23T02:44:10Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
291,819
<p>Try using <a href="http://con.appspot.com/console/help/integration">App Engine Console</a> then you dont even have to deploy any special code</p>
9
2008-11-14T23:58:35Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
323,041
<p>I've tried db.delete(results) and App Engine Console, and none of them seems to be working for me. Manually removing entries from Data Viewer (increased limit up to 200) didn't work either since I have uploaded more than 10000 entries. I ended writing this script </p> <pre><code>from google.appengine.ext import db ...
7
2008-11-27T06:00:44Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
1,023,729
<p>I am currently deleting the entities by their key, and it seems to be faster.</p> <pre><code>from google.appengine.ext import db class bulkdelete(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' try: while True: q = db.GqlQu...
27
2009-06-21T11:41:24Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
1,400,490
<p>One tip. I suggest you get to know the <a href="http://code.google.com/appengine/articles/remote%5Fapi.html" rel="nofollow">remote_api</a> for these types of uses (bulk deleting, modifying, etc.). But, even with the remote api, batch size can be limited to a few hundred at a time.</p>
4
2009-09-09T15:47:34Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
1,882,697
<p>If I were a paranoid person, I would say Google App Engine (GAE) has not made it easy for us to remove data if we want to. I am going to skip discussion on index sizes and how they translate a 6 GB of data to 35 GB of storage (being billed for). That's another story, but they do have ways to work around that - limit...
10
2009-12-10T17:41:07Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
2,245,189
<p>You can use the task queues to delete chunks of say 100 objects. Deleting objects in GAE shows how limited the Admin capabilities are in GAE. You have to work with batches on 1000 entities or less. You can use the bulkloader tool that works with csv's but the documentation does not cover java. I am using GAE Java an...
0
2010-02-11T14:48:22Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
2,511,446
<p>With django, setup url: </p> <pre><code>url(r'^Model/bdelete/$', v.bulk_delete_models, {'model':'ModelKind'}), </code></pre> <p>Setup view</p> <pre><code>def bulk_delete_models(request, model): import time limit = request.GET['limit'] or 200 start = time.clock() set = db.GqlQuery("SELECT __key__ F...
1
2010-03-24T21:12:14Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
3,376,429
<p>This worked for me:</p> <pre><code>class ClearHandler(webapp.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' q = db.GqlQuery("SELECT * FROM SomeModel") self.response.out.write("deleting...") db.delete(q) </code></pre>
0
2010-07-31T01:41:22Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
3,671,769
<p>The fastest and efficient way to handle bulk delete on Datastore is by using the new <a href="http://code.google.com/p/appengine-mapreduce/" rel="nofollow">mapper API</a> announced on the latest <a href="http://code.google.com/events/io/2010/" rel="nofollow">Google I/O</a>.</p> <p>If your language of choice is <a h...
5
2010-09-08T20:49:35Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
4,600,511
<p>If you are using Java/JPA you can do something like this:</p> <pre><code> em = EntityManagerFactoryUtils.getTransactionalEntityManager(entityManagerFactory) Query q = em.createQuery("delete from Table t"); int number = q.executeUpdate(); </code></pre> <p>Java/JDO info can be found here: <a href="http://...
1
2011-01-05T03:12:37Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
7,291,775
<p>Thank you all guys, I got what I need. :D<br> This may be useful if you have lots db models to delete, you can dispatch it in your terminal. And also, you can manage the delete list in DB_MODEL_LIST yourself.<br> Delete DB_1:</p> <pre><code>python bulkdel.py 10 DB_1 </code></pre> <p>Delete All DB:</p> <pre><code>...
0
2011-09-03T07:27:45Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
7,464,545
<p>You can now use the Datastore Admin for that: <a href="https://developers.google.com/appengine/docs/adminconsole/datastoreadmin#Deleting_Entities_in_Bulk">https://developers.google.com/appengine/docs/adminconsole/datastoreadmin#Deleting_Entities_in_Bulk</a></p>
20
2011-09-18T21:17:52Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
8,444,988
<p>Yes you can: Go to Datastore Admin, and then select the Entitiy type you want to delete and click Delete. Mapreduce will take care of deleting!</p>
1
2011-12-09T11:42:36Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
13,626,511
<p>In javascript, the following will delete all the entries for on page:</p> <pre><code>document.getElementById("allkeys").checked=true; checkAllEntities(); document.getElementById("delete_button").setAttribute("onclick",""); document.getElementById("delete_button").click(); </code></pre> <p>given that you are on the...
-2
2012-11-29T13:06:19Z
[ "python", "google-app-engine" ]
Delete all data for a kind in Google App Engine
108,822
<p>I would like to wipe out all data for a specific kind in Google App Engine. What is the best way to do this? I wrote a delete script (hack), but since there is so much data is timeout's out after a few hundred records. </p>
40
2008-09-20T17:34:24Z
33,964,279
<p>On a <a href="https://cloud.google.com/appengine/docs/python/tools/devserver?hl=en" rel="nofollow">dev server</a>, one can cd to his app's directory then run it like this:</p> <pre><code>dev_appserver.py --clear_datastore=yes . </code></pre> <p>Doing so will start the app and clear the datastore. If you already h...
0
2015-11-27T20:11:34Z
[ "python", "google-app-engine" ]
Python Music Library?
108,848
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic">music</a> and <a href="http://wiki.python.org/moin/Audio/">basic audio</a> as well as a StackOverflow question on <a href="http://stackoverflow.com/ques...
36
2008-09-20T17:42:53Z
108,885
<p>There is a variety of Python music software, you can find a catalog <a href="http://wiki.python.org/moin/PythonInMusic" rel="nofollow">here</a>.</p> <p>If you scroll down the linked page, you find a section on <strong>Music Programming in Python</strong> describing several music creation packages including <a href=...
4
2008-09-20T18:01:39Z
[ "python", "audio", "music" ]
Python Music Library?
108,848
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic">music</a> and <a href="http://wiki.python.org/moin/Audio/">basic audio</a> as well as a StackOverflow question on <a href="http://stackoverflow.com/ques...
36
2008-09-20T17:42:53Z
108,936
<p>I had to do this years ago. I used pymedia. I am not sure if it is still around any way here is some test code I wrote when I was playing with it. It is about 3 years old though.</p> <p><strong>Edit:</strong> The sample code plays an MP3 file</p> <pre><code>import pymedia import time demuxer = pymedia.muxer.Demux...
7
2008-09-20T18:33:16Z
[ "python", "audio", "music" ]
Python Music Library?
108,848
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic">music</a> and <a href="http://wiki.python.org/moin/Audio/">basic audio</a> as well as a StackOverflow question on <a href="http://stackoverflow.com/ques...
36
2008-09-20T17:42:53Z
109,147
<p>Take a close look at <a href="http://www.csounds.com/">cSounds</a>. There are Python bindings allow you to do pretty flexible digital synthesis. There are some pretty complete packages available, too. </p> <p>See <a href="http://www.csounds.com/node/188">http://www.csounds.com/node/188</a> for a package.</p> <p...
13
2008-09-20T19:51:39Z
[ "python", "audio", "music" ]
Python Music Library?
108,848
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic">music</a> and <a href="http://wiki.python.org/moin/Audio/">basic audio</a> as well as a StackOverflow question on <a href="http://stackoverflow.com/ques...
36
2008-09-20T17:42:53Z
109,642
<p>In addition to what has been mentioned previously, I wrote a simple Python audio editor. <a href="http://code.google.com/p/yaalp/source/browse/#svn/trunk" rel="nofollow">http://code.google.com/p/yaalp/source/browse/#svn/trunk</a> See main.py.</p> <p>It also has audio manipulation and some effects.</p> <p>Code's GP...
1
2008-09-20T22:39:12Z
[ "python", "audio", "music" ]
Python Music Library?
108,848
<p>I'm looking at writing a little drum machine in Python for fun. I've googled some and found the python pages on <a href="http://wiki.python.org/moin/PythonInMusic">music</a> and <a href="http://wiki.python.org/moin/Audio/">basic audio</a> as well as a StackOverflow question on <a href="http://stackoverflow.com/ques...
36
2008-09-20T17:42:53Z
3,761,953
<p>Also check out <a href="http://code.google.com/p/pyo/" rel="nofollow">http://code.google.com/p/pyo/</a></p>
2
2010-09-21T15:40:27Z
[ "python", "audio", "music" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
108,911
<p>Maybe buildbot would be useful <a href="http://buildbot.net/trac" rel="nofollow">http://buildbot.net/trac</a> </p>
2
2008-09-20T18:18:11Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
108,934
<p>For your third question, maybe the <code>trace</code> module is what you need:</p> <pre><code>&gt;&gt;&gt; def y(a): return a*a &gt;&gt;&gt; def x(a): return y(a) &gt;&gt;&gt; import trace &gt;&gt;&gt; tracer = trace.Trace(countfuncs = 1) &gt;&gt;&gt; tracer.runfunc(x, 2) 4 &gt;&gt;&gt; res = tracer.results() &gt;&...
2
2008-09-20T18:32:54Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
109,007
<p>Django's development server has a file change monitor that watches for modifications and automatically reloads itself. You could re-use this code to launch unit tests on file modification.</p>
2
2008-09-20T19:00:04Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
109,011
<p>Maybe Nose <a href="http://somethingaboutorange.com/mrl/projects/nose/" rel="nofollow">http://somethingaboutorange.com/mrl/projects/nose/</a> has a plugin <a href="http://somethingaboutorange.com/mrl/projects/nose/doc/writing_plugins.html" rel="nofollow">http://somethingaboutorange.com/mrl/projects/nose/doc/writing_...
2
2008-09-20T19:01:22Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
482,668
<p><a href="http://github.com/gfxmonk/autonose/tree/master">autonose</a> created by <a href="http://gfxmonk.net/">gfxmonk</a>:</p> <blockquote> <p>Autonose is an autotest-like tool for python, using the excellent nosetest library.</p> <p>autotest tracks filesystem changes and automatically re-run any changed te...
16
2009-01-27T08:42:41Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
1,744,498
<p>I just found this: <a href="http://www.metareal.org/p/modipyd/" rel="nofollow">http://www.metareal.org/p/modipyd/</a></p> <p>I'm currently using thumb.py, but as my current project transitions from a small project to a medium sized one, I've been looking for something that can do a bit more thorough dependency anal...
3
2009-11-16T19:58:57Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
9,461,979
<p>I found <a href="https://github.com/gfxmonk/autonose">autonose</a> to be pretty unreliable but <a href="http://pypi.python.org/pypi/sniffer/0.2.3">sniffer</a> seems to work very well.</p> <pre><code>$ pip install sniffer $ cd myproject </code></pre> <p>Then instead of running "nosetests", you run:</p> <pre><code>...
24
2012-02-27T08:28:14Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
17,866,537
<p><a href="https://github.com/guard/guard" rel="nofollow">Guard</a> is an excellent tool that monitors for file changes and triggers tasks automatically. It's written in Ruby, but it can be used as a standalone tool for any task like this. There's a <a href="https://github.com/medihack/guard-nosetests" rel="nofollow">...
2
2013-07-25T18:59:37Z
[ "python", "testing" ]
Is there something like 'autotest' for Python unittests?
108,892
<p>Basically, growl notifications (or other callbacks) when tests break or pass. <strong>Does anything like this exist?</strong></p> <p>If not, it should be pretty easy to write.. Easiest way would be to..</p> <ol> <li>run <code>python-autotest myfile1.py myfile2.py etc.py</code></li> <li>Check if files-to-be-monitor...
39
2008-09-20T18:07:40Z
20,275,347
<p>Check out pytddmon. Here is a video demonstration of how to use it: <a href="http://pytddmon.org/?page_id=33" rel="nofollow">http://pytddmon.org/?page_id=33</a></p>
1
2013-11-28T22:00:26Z
[ "python", "testing" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,106
<p>Every object has a <code>__dict__</code> variable containing all the variables and its values in it.</p> <p>Try this</p> <pre><code>&gt;&gt;&gt; hi_obj = hi() &gt;&gt;&gt; hi_obj.__dict__.keys() </code></pre>
78
2008-09-20T19:34:17Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,118
<p>You normally can't get instance attributes given just a class, at least not without instantiating the class. You can get instance attributes given an instance, though, or class attributes given a class. See the 'inspect' module. You can't get a list of instance attributes because instances really can have anything a...
13
2008-09-20T19:38:01Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,122
<p>You can also test if an object has a specific variable with:</p> <pre><code>&gt;&gt;&gt; hi_obj = hi() &gt;&gt;&gt; hasattr(hi_obj, "some attribute") </code></pre>
8
2008-09-20T19:39:31Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,127
<p>Your example shows "instance variables", not really class variables.</p> <p>Look in <code>hi_obj.__class__.__dict__.items()</code> for the class variables, along with other other class members like member functions and the containing module.</p> <pre><code>class Hi( object ): class_var = ( 23, 'skidoo' ) # cl...
4
2008-09-20T19:42:43Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,173
<p>Use vars()</p> <pre><code>class Foo(object): def __init__(self): self.a = 1 self.b = 2 vars(Foo()) #==&gt; {'a': 1, 'b': 2} vars(Foo()).keys() #==&gt; ['a', 'b'] </code></pre>
63
2008-09-20T20:02:26Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
109,207
<p>Suggest</p> <pre><code>&gt;&gt;&gt; print vars.__doc__ vars([object]) -&gt; dictionary Without arguments, equivalent to locals(). With an argument, equivalent to object.__dict__. </code></pre> <p>In otherwords, it essentially just wraps __dict__ </p>
6
2008-09-20T20:12:58Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
111,876
<p>Although not directly an answer to the OP question, there is a pretty sweet way of finding out what variables are in scope in a function. take a look at this code:</p> <pre><code>&gt;&gt;&gt; def f(x, y): z = x**2 + y**2 sqrt_z = z**.5 return sqrt_z &gt;&gt;&gt; f.func_code.co_varnames ('x', 'y', 'z', ...
5
2008-09-21T19:46:01Z
[ "python", "methods", "instance-variables" ]
How to get instance variables in Python?
109,087
<p>Is there a built-in method in Python to get an array of all a class' instance variables? For example, if I have this code:</p> <pre><code>class hi: def __init__(self): self.ii = "foo" self.kk = "bar" </code></pre> <p>Is there a way for me to do this:</p> <pre><code>&gt;&gt;&gt; mystery_method(hi) ["ii",...
66
2008-09-20T19:30:24Z
4,522,706
<p>Both the Vars() and dict methods will work for the example the OP posted, but they won't work for "loosely" defined objects like:</p> <pre><code>class foo: a = 'foo' b = 'bar' </code></pre> <p>To print all non-callable attributes, you can use the following function:</p> <pre><code>def printVars(object): f...
10
2010-12-23T21:50:34Z
[ "python", "methods", "instance-variables" ]
Python signal woes: SIGQUIT handler delays execution if SIGQUIT recieved during execution of another signal handler?
109,705
<p>The following program is very simple: it outputs a single dot each half a second. If it recieves a <strong>SIGQUIT</strong>, it proceeds to output ten <strong>Q</strong>s. If it recieves a <strong>SIGTSTP</strong> <em>(<kbd>Ctrl</kbd>-<kbd>Z</kbd>)</em>, it outputs ten <strong>Z</strong>s.</p> <p>If it recieves a <...
9
2008-09-20T23:02:35Z
109,783
<p>Your larger problem is blocking in signal handlers.</p> <p>This is usually discouraged since it can lead to strange timing conditions. But it's not quite the cause of your problem since the timing condition you're vulnerable to exists because of your choice of signal handlers.</p> <p>Anyway, here's how to at leas...
5
2008-09-20T23:39:49Z
[ "python", "signals" ]
Python signal woes: SIGQUIT handler delays execution if SIGQUIT recieved during execution of another signal handler?
109,705
<p>The following program is very simple: it outputs a single dot each half a second. If it recieves a <strong>SIGQUIT</strong>, it proceeds to output ten <strong>Q</strong>s. If it recieves a <strong>SIGTSTP</strong> <em>(<kbd>Ctrl</kbd>-<kbd>Z</kbd>)</em>, it outputs ten <strong>Z</strong>s.</p> <p>If it recieves a <...
9
2008-09-20T23:02:35Z
109,803
<p>On Python 2.5.2 on Linux 2.6.24, your code works exactly as you describe your desired results (if a signal is received while still processing a previous signal, the new signal is processed immediately after the first one is finished).</p> <p>On Python 2.4.4 on Linux 2.6.16, I see the problem behavior you describe.<...
1
2008-09-20T23:49:18Z
[ "python", "signals" ]
Change the width of form elements created with ModelForm in Django
110,378
<p>How can i change the width of a textarea form element if i used ModelForm to create it?</p> <p>Here is my product class:</p> <pre><code>class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=forms.Textarea) class Meta: model = Produc...
42
2008-09-21T06:15:13Z
110,414
<p><strong>The easiest way for your use case is to use CSS</strong>. It's a language meant for defining presentation. Look at the code generated by form, take note of the ids for fields that interest you, and change appearance of these fields through CSS.</p> <p>Example for <code>long_desc</code> field in your Product...
91
2008-09-21T06:44:02Z
[ "python", "html", "django", "django-forms", "django-templates" ]
Change the width of form elements created with ModelForm in Django
110,378
<p>How can i change the width of a textarea form element if i used ModelForm to create it?</p> <p>Here is my product class:</p> <pre><code>class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=forms.Textarea) class Meta: model = Produc...
42
2008-09-21T06:15:13Z
640,680
<p>Excellent answer by zuber, but I believe there's an error in the example code for the third approach. The constructor should be:</p> <pre><code>def __init__(self, *args, **kwargs): super(ProductForm, self).__init__(*args, **kwargs) # Call to ModelForm constructor self.fields['long_desc'].widget.attrs['cols'...
14
2009-03-12T22:02:52Z
[ "python", "html", "django", "django-forms", "django-templates" ]
Change the width of form elements created with ModelForm in Django
110,378
<p>How can i change the width of a textarea form element if i used ModelForm to create it?</p> <p>Here is my product class:</p> <pre><code>class ProductForm(ModelForm): long_desc = forms.CharField(widget=forms.Textarea) short_desc = forms.CharField(widget=forms.Textarea) class Meta: model = Produc...
42
2008-09-21T06:15:13Z
25,192,228
<p>In the event that you're using an add-on like Grappelli that makes heavy use of styles, you may find that any overridden row and col attributes get ignored because of CSS selectors acting on your widget. This could happen when using zuber's excellent Second or Third approach above.</p> <p>In this case, simply use t...
2
2014-08-07T21:08:12Z
[ "python", "html", "django", "django-forms", "django-templates" ]
Is there an easy way to request a URL in python and NOT follow redirects?
110,498
<p>Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple.</p>
24
2008-09-21T07:49:10Z
110,547
<p><a href="http://www.diveintopython.net/http_web_services/redirects.html">Dive Into Python</a> has a good chapter on handling redirects with urllib2. Another solution is <a href="http://docs.python.org/library/httplib.html">httplib</a>.</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import httplib ...
34
2008-09-21T08:33:12Z
[ "python", "http", "redirect" ]
Is there an easy way to request a URL in python and NOT follow redirects?
110,498
<p>Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple.</p>
24
2008-09-21T07:49:10Z
110,808
<p>I second olt's pointer to <a href="http://www.diveintopython.org/http_web_services/redirects.html">Dive into Python</a>. Here's an implementation using urllib2 redirect handlers, more work than it should be? Maybe, shrug.</p> <pre><code>import sys import urllib2 class RedirectHandler(urllib2.HTTPRedirectHandler): ...
5
2008-09-21T11:31:20Z
[ "python", "http", "redirect" ]
Is there an easy way to request a URL in python and NOT follow redirects?
110,498
<p>Looking at the source of urllib2 it looks like the easiest way to do it would be to subclass HTTPRedirectHandler and then use build_opener to override the default HTTPRedirectHandler, but this seems like a lot of (relatively complicated) work to do what seems like it should be pretty simple.</p>
24
2008-09-21T07:49:10Z
111,066
<p>i suppose this would help</p> <pre><code>from httplib2 import Http def get_html(uri,num_redirections=0): # put it as 0 for not to follow redirects conn = Http() return conn.request(uri,redirections=num_redirections) </code></pre>
8
2008-09-21T13:51:30Z
[ "python", "http", "redirect" ]