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 list |
|---|---|---|---|---|---|---|---|---|---|
MySQLdb within python2.5 virtualenv | 2,304,539 | <p>I have a Fedora 11 box with MySQL server. Fedora 11 uses python 2.6 internally and python 2.6 is automatically installed on the box. I have created a python virtual-env for version 2.5.5, so that I can run turbogears 1.x application. I have MySQLdb rpm installed on the box (and it works fine with python 2.6).</p>... | 3 | 2010-02-21T02:28:10Z | 22,272,551 | <p>In case it does not work even after installing mysql-devel package, check the contents of "/usr/include/mysql". </p>
<p>If is empty then its possible that mysql-devel has installed the header files at some pther place, run following command to find </p>
<blockquote>
<p>find /usr/include/ -maxdepth 1 -name mysql*... | 0 | 2014-03-08T17:25:19Z | [
"python",
"mysql",
"virtualenv"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 2,304,640 | <p>If you're talking about the <code>@username</code> thing they use on twitter, then you can use this:</p>
<pre><code>import re
twitter_username_re = re.compile(r'@([A-Za-z0-9_]+)')
</code></pre>
<p>To make every instance an HTML link, you could do something like this:</p>
<pre><code>my_html_str = twitter_username_... | 15 | 2010-02-21T03:25:04Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 2,304,704 | <p>The only characters accepted in the form are A-Z, 0-9, and underscore. <em>Usernames are not case-sensitive</em>, though, so you could use <code>r'@(?i)[a-z0-9_]+'</code> to match everything correctly and also discern between users.</p>
| 2 | 2010-02-21T03:56:23Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 2,330,300 | <p>Twitter <a href="http://engineering.twitter.com/2010/02/introducing-open-source-twitter-text.html">recently released</a> to open source both <a href="http://github.com/mzsanford/twitter-text-java">java</a> and <a href="http://github.com/mzsanford/twitter-text-rb">ruby</a> (<a href="http://rubygems.org/gems/twitter-t... | 9 | 2010-02-24T22:55:59Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 2,330,440 | <p>Shorter, <code>/@([\w]+)/</code> works fine.</p>
| 1 | 2010-02-24T23:19:47Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 2,420,608 | <p><a href="http://www.barattalo.it/2010/03/10/php-parse-url-mailto-and-also-twitters-usernames-and-arguments/" rel="nofollow">Here is a PHP function</a> that links urls and also mailto and twitter usernames and arguments tags.</p>
| -2 | 2010-03-10T21:10:10Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 6,351,873 | <pre><code>(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9]+)
</code></pre>
<p>Ive used this as it disregards emails</p>
<p>Here is a sample tweet</p>
<pre><code>@Hello how are @you doing, email @000 me @ whats.up@example.com @shahmirj
</code></pre>
<p>Picks Up:</p>
<pre><code>@Hello
@you
@shahmirj
</code>... | 47 | 2011-06-15T01:01:13Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 13,396,934 | <p>The regex I use, and that have been tested in multiple contexts :</p>
<pre class="lang-py prettyprint-override"><code>/(^|[^@\w])@(\w{1,15})\b/
</code></pre>
<p>This is the cleanest way I've found to test and replace Twitter username in strings.</p>
<pre class="lang-py prettyprint-override"><code>#!/usr/bin/pytho... | 9 | 2012-11-15T11:48:51Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 14,989,811 | <p>This is a method I have used in a project that takes the text attribute of a tweet object and returns the text with both the hashtags and user_mentions linked to their appropriate pages on twitter, complying with the most recent twitter display guidelines</p>
<pre><code>def link_tweet(tweet):
"""
This method takes ... | 1 | 2013-02-20T21:00:04Z | [
"python",
"regex",
"twitter"
] |
regex for Twitter username | 2,304,632 | <p>Could you provide a regex that match Twitter usernames?</p>
<p>Extra bonus if a Python example is provided.</p>
| 28 | 2010-02-21T03:19:46Z | 22,414,384 | <p>This regex seems to solve Twitter usernames:</p>
<pre><code>^@[A-Za-z0-9_]{1,15}$
</code></pre>
<p>Max 15 characters, allows underscores directly after the @, (which Twitter does), and allows all underscores (which, after a quick search, I found that Twitter apparently also does). Excludes email addresses.</p>
| 1 | 2014-03-14T19:45:24Z | [
"python",
"regex",
"twitter"
] |
How to use Twitter API to check if a user/password is valid? | 2,304,712 | <p>I have a user and a password and I'd like to use Twitter API (I'm using python-twitter) to check if those are valid data.</p>
| 3 | 2010-02-21T03:59:26Z | 2,304,770 | <p>urllib2 will raise HTTPError if the credentials are wrong, and the message will be 'HTTP Error 401: Unauthorized'. You could use a temporary instance of the API to make an authorized request (GetFriends(), for example) in a try/except block to determine if the credentials are valid.</p>
<pre><code>import twitter, u... | 1 | 2010-02-21T04:29:57Z | [
"python",
"twitter"
] |
How to use Twitter API to check if a user/password is valid? | 2,304,712 | <p>I have a user and a password and I'd like to use Twitter API (I'm using python-twitter) to check if those are valid data.</p>
| 3 | 2010-02-21T03:59:26Z | 2,304,909 | <p>If you grab the 0.7 version of <a href="http://code.google.com/p/python-twitter/source/browse/twitter.py" rel="nofollow">python-twitter</a>, a VerifyCredentials method has been added. If the returned value is <code>None</code> then the username/password combo was incorrect.</p>
<p>I liked using <code>api.GetUser(u... | 0 | 2010-02-21T05:31:02Z | [
"python",
"twitter"
] |
First Order Logic Engine | 2,304,726 | <p>I'd like to create an application that can do simple reasoning using first order logic. Can anyone recommend an "engine" that can accept an arbitrary number of FOL expressions, and allow querying of those expressions (preferably accessible via Python)?</p>
| 6 | 2010-02-21T04:08:09Z | 2,304,781 | <p>Recipe 303057: Pythologic -- Prolog syntax in Python / <a href="http://code.activestate.com/recipes/303057/" rel="nofollow">http://code.activestate.com/recipes/303057/</a></p>
| 1 | 2010-02-21T04:38:14Z | [
"python",
"logic",
"machine-learning",
"reasoning"
] |
First Order Logic Engine | 2,304,726 | <p>I'd like to create an application that can do simple reasoning using first order logic. Can anyone recommend an "engine" that can accept an arbitrary number of FOL expressions, and allow querying of those expressions (preferably accessible via Python)?</p>
| 6 | 2010-02-21T04:08:09Z | 2,304,789 | <p><a href="http://christophe.delord.free.fr/pylog/index.html" rel="nofollow">PyLog</a>:</p>
<blockquote>
<p>PyLog is a first order logic library
including a PROLOG engine in Python.</p>
</blockquote>
| 3 | 2010-02-21T04:41:39Z | [
"python",
"logic",
"machine-learning",
"reasoning"
] |
First Order Logic Engine | 2,304,726 | <p>I'd like to create an application that can do simple reasoning using first order logic. Can anyone recommend an "engine" that can accept an arbitrary number of FOL expressions, and allow querying of those expressions (preferably accessible via Python)?</p>
| 6 | 2010-02-21T04:08:09Z | 2,330,258 | <p>Don't query using first-order logic (FOL) unless you absolutely have to: first-order logic is not decidable, but only semi-decidable, and so queries will often, unavoidably not terminate.</p>
<p><a href="http://en.wikipedia.org/wiki/Description_logic">Description logic</a> is essentially a decidable fragment of fir... | 6 | 2010-02-24T22:48:32Z | [
"python",
"logic",
"machine-learning",
"reasoning"
] |
Is there a way of checking for membership from the values of a dictionary? Once confirmed, can we do other things? | 2,304,749 | <p>I understand that it's quite easy to check if a key is available in a dictionary, but what about certain values?</p>
<p>So, what I have here is a dictionary of lists where the key references a set of, for consistency's sake, strings. It would look a bit like this: </p>
<pre><code>menu = {'breakfast':['soft-boiled... | 1 | 2010-02-21T04:21:30Z | 2,304,856 | <p>Membership in <code>menu</code> is easy:</p>
<pre><code>[k for k, v in menu.iteritems() if 'chips' in v]
</code></pre>
<p>Membership with <code>defaultdict</code> works exactly the same way since containment checking doesn't mutate it.</p>
| 2 | 2010-02-21T05:11:15Z | [
"python",
"dictionary"
] |
Is there a way of checking for membership from the values of a dictionary? Once confirmed, can we do other things? | 2,304,749 | <p>I understand that it's quite easy to check if a key is available in a dictionary, but what about certain values?</p>
<p>So, what I have here is a dictionary of lists where the key references a set of, for consistency's sake, strings. It would look a bit like this: </p>
<pre><code>menu = {'breakfast':['soft-boiled... | 1 | 2010-02-21T04:21:30Z | 2,305,108 | <p>One obvious way is to just go thru whole dict and replace the values but IMO it is better to design it so that it is easy to replace ingredients e.g. have a single object(may be singleton class) for each type of ingredient, so you can just replace the types on the fly e.g.</p>
<pre><code>tea.remove('assam')
</code>... | 0 | 2010-02-21T06:46:59Z | [
"python",
"dictionary"
] |
Is there a way of checking for membership from the values of a dictionary? Once confirmed, can we do other things? | 2,304,749 | <p>I understand that it's quite easy to check if a key is available in a dictionary, but what about certain values?</p>
<p>So, what I have here is a dictionary of lists where the key references a set of, for consistency's sake, strings. It would look a bit like this: </p>
<pre><code>menu = {'breakfast':['soft-boiled... | 1 | 2010-02-21T04:21:30Z | 2,305,137 | <p>It looks like the basic thing you're asking for is how to iterate through a dictionary -- once you have that, it's all basic stuff.</p>
<pre><code>for key,value in mydict.iteritems():
print "%s = %s" %(key, value)
</code></pre>
<p>now, to apply it directly to your situation:</p>
<pre><code>for meal, food in m... | 0 | 2010-02-21T06:57:03Z | [
"python",
"dictionary"
] |
QWebView not loading external CSS | 2,304,952 | <p>I am using a QWebView to display some content and I want to use custom CSS to spruce up the output. I found that I can use the <code>QWebSettings.setUserStyleSheetUrl()</code> method to load my own CSS into the view. The <code>.css</code> file is in the same directory as my main program.</p>
<pre><code>self.webvi... | 3 | 2010-02-21T05:43:37Z | 2,305,088 | <p>In Qt, all paths to external files need to be <strong>ABSOLUTE</strong> paths, not relative ones.</p>
<p>To fix the problem, I add to make the following change:</p>
<pre><code>path = os.getcwd()
self.webview.settings().setUserStyleSheetUrl(QUrl.fromLocalFile(path + "/myCustom.css"))
</code></pre>
<p>And everythin... | 7 | 2010-02-21T06:34:57Z | [
"python",
"qt",
"pyqt",
"qwebview",
"pyside"
] |
QWebView not loading external CSS | 2,304,952 | <p>I am using a QWebView to display some content and I want to use custom CSS to spruce up the output. I found that I can use the <code>QWebSettings.setUserStyleSheetUrl()</code> method to load my own CSS into the view. The <code>.css</code> file is in the same directory as my main program.</p>
<pre><code>self.webvi... | 3 | 2010-02-21T05:43:37Z | 5,198,529 | <blockquote>
<p>In Qt, all paths to external files
need to be ABSOLUTE paths, not
relative ones.</p>
</blockquote>
<p>That's not true. The code below works for me.</p>
<pre><code>#include <QtCore>
#include <QtGui>
#include <QtWebKit>
int main(int argc, char ** argv)
{
QApplication app(arg... | 1 | 2011-03-04T19:50:01Z | [
"python",
"qt",
"pyqt",
"qwebview",
"pyside"
] |
QWebView not loading external CSS | 2,304,952 | <p>I am using a QWebView to display some content and I want to use custom CSS to spruce up the output. I found that I can use the <code>QWebSettings.setUserStyleSheetUrl()</code> method to load my own CSS into the view. The <code>.css</code> file is in the same directory as my main program.</p>
<pre><code>self.webvi... | 3 | 2010-02-21T05:43:37Z | 13,212,523 | <p>I just ran into this, so I'll post my test snippet here; the snippet generates its own .html and .css file in the same directory as the python script; and the script was called from the same directory for testing. </p>
<p>At least in <code>python</code>/<code>PyQt4</code>, it seems that - indeed - it is <em>only</e... | 1 | 2012-11-03T19:08:56Z | [
"python",
"qt",
"pyqt",
"qwebview",
"pyside"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,305,055 | <p>How about <a href="http://lucene.apache.org/pylucene/" rel="nofollow">python bindings for Lucene</a>?</p>
| 1 | 2010-02-21T06:22:16Z | [
"python",
"search",
"lucene"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,305,062 | <p>Why you need lucene-like when you can use lucene (PyLucene) :)</p>
<p><a href="http://lucene.apache.org/pylucene/">http://lucene.apache.org/pylucene/</a></p>
<p>It is great and builds against the latest build of lucene</p>
<p>quote from site:</p>
<blockquote>
<p>PyLucene is a Python extension for
accessing J... | 8 | 2010-02-21T06:26:29Z | [
"python",
"search",
"lucene"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,305,096 | <p>See <strong><a href="http://wiki.apache.org/solr/SolPython" rel="nofollow">SolPython</a></strong> and <strong><a href="http://code.google.com/p/solrpy/" rel="nofollow">solrpy</a></strong></p>
<blockquote>
<h2>What is solrpy?</h2>
<p>solrpy is a python client for solr, an
enterprise search server built on t... | 2 | 2010-02-21T06:39:19Z | [
"python",
"search",
"lucene"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,307,477 | <p>You can also check <a href="http://www.elasticsearch.com" rel="nofollow">ElasticSearch</a>, it has native JSON interface so integrating with it in python should be simpler. Seems like <a href="http://simonwillison.net/2010/Feb/11/elastic/" rel="nofollow">Simon Willison</a> thinks it got potential...</p>
| 10 | 2010-02-21T21:14:56Z | [
"python",
"search",
"lucene"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,307,594 | <p>How about Sphinx? <a href="http://www.sphinxsearch.com/" rel="nofollow">http://www.sphinxsearch.com/</a></p>
<p>It has Python bindings included.
I don't have comparision with other solutions like Lucene,
but I'm using Sphinx for CRM and it works very well,
indexing emails, notes etc.</p>
| 0 | 2010-02-21T21:48:10Z | [
"python",
"search",
"lucene"
] |
Is there a open-search solution for python? | 2,305,026 | <p>lucene-like would be preferred.</p>
<p>thanks</p>
| 3 | 2010-02-21T06:13:54Z | 2,307,630 | <p><a href="http://xapian.org/" rel="nofollow">Xapian</a> is an excellent Lucene-alternative, with fairly good Python-bindings, which is also easier to install than pylucene.</p>
| 0 | 2010-02-21T22:01:14Z | [
"python",
"search",
"lucene"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,125 | <p>Open a second file to write to, read and then write the lines you want to copy over, write the new lines, read the lines you want to skip, then copy the rest.</p>
| 2 | 2010-02-21T06:54:26Z | [
"python",
"file-io"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,136 | <p>Read the whole file as a list of lines, then replace the lines you want to delete with a new list of lines:</p>
<pre><code>f = open('file.txt')
data = f.readlines()
f.close()
data[2:4] = [
'new line1\n',
'new line2\n',
'new line3\n']
f = open('processed.txt','w')
f.writelines(data)
f.close()
</code></pr... | 3 | 2010-02-21T06:57:01Z | [
"python",
"file-io"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,139 | <p>There are be several ways to achieve that</p>
<ol>
<li><p>if you file is small and your lines unique, you can just read whole file and replace the line e.g.</p>
<p>f.read().replace("third line", "new line1\nnew line2\nnew line3")</p></li>
<li><p>But if the file is big or lines not unqiue, just read thru file line ... | 0 | 2010-02-21T06:57:23Z | [
"python",
"file-io"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,144 | <p>For <strong>python2.6</strong></p>
<pre><code>with open("file1") as infile:
with open("file2","w") as outfile:
for i,line in enumerate(infile):
if i==2:
# 3rd line
outfile.write("new line1\n")
outfile.write("new line2\n")
outfil... | 7 | 2010-02-21T07:00:18Z | [
"python",
"file-io"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,159 | <pre><code>import os
i = open(inputFilePath, 'r')
o = open(inputFilePath+"New", 'w')
lineNo = 0
for line in input:
lineNo += 1
if lineNo != 3:
o.write(line)
else:
o.write(myNewLines)
i.close()
o.close()
os.remove(inputFilePath)
os.rename(inputFilePath+"New", inputFilePath)
</code></pre>
<... | 1 | 2010-02-21T07:10:02Z | [
"python",
"file-io"
] |
Remove and insert lines in a text file | 2,305,115 | <p>I have a text file looks like:</p>
<pre>
first line
second line
third line
forth line
fifth line
sixth line
</pre>
<p>I want to replace the third and forth lines with three new lines. The above contents would become:</p>
<pre>
first line
second line
new line1
new line2
new line3
fifth line ... | 4 | 2010-02-21T06:49:37Z | 2,305,167 | <pre><code>import fileinput
myinsert="""new line1\nnew line2\nnew line3"""
for line in fileinput.input("file",inplace=1):
linenum=fileinput.lineno()
if linenum==1 or linenum>4 :
line=line.rstrip()
if linenum==2:
line=line+myinsert
print line
</code></pre>
<p>Or if you file is not to... | 4 | 2010-02-21T07:16:17Z | [
"python",
"file-io"
] |
Using BeautifulSoup to parse lines seperated by <br> tags? | 2,305,191 | <p>I have a page that looks like this:</p>
<pre><code>Company A<br />
123 Main St.<br />
Suite 101<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Company B<br />
456 Main St.<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
</code></... | 7 | 2010-02-21T07:30:07Z | 2,305,197 | <p>Once you have this HTML fragment, just use a regex to replace <code><br /></code> followed by an optional newline by a single newline, then split on multiple newlines. This should result in multiple individual paragraphs which you can process manually.</p>
| 2 | 2010-02-21T07:34:33Z | [
"python",
"parsing",
"beautifulsoup"
] |
Using BeautifulSoup to parse lines seperated by <br> tags? | 2,305,191 | <p>I have a page that looks like this:</p>
<pre><code>Company A<br />
123 Main St.<br />
Suite 101<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Company B<br />
456 Main St.<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
</code></... | 7 | 2010-02-21T07:30:07Z | 2,305,330 | <p>you can do a little bit of manipulation first before anything. eg change all newlines to blanks, then substitute 2 occurrences and more of <code><br /></code> to some other delimiter like <code>|</code>. after that you can get your fields.</p>
<pre><code>html="""
Company A<br />
123 Main St.<br />... | 0 | 2010-02-21T08:35:10Z | [
"python",
"parsing",
"beautifulsoup"
] |
Using BeautifulSoup to parse lines seperated by <br> tags? | 2,305,191 | <p>I have a page that looks like this:</p>
<pre><code>Company A<br />
123 Main St.<br />
Suite 101<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Company B<br />
456 Main St.<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
</code></... | 7 | 2010-02-21T07:30:07Z | 2,305,423 | <p>Perhaps you could use this function:</p>
<pre><code>def partition_by(pred, iterable):
current = None
current_flag = None
chunk = []
for item in iterable:
if current is None:
current = item
current_flag = pred(current)
chunk = [current]
elif pred(it... | 0 | 2010-02-21T09:16:20Z | [
"python",
"parsing",
"beautifulsoup"
] |
Using BeautifulSoup to parse lines seperated by <br> tags? | 2,305,191 | <p>I have a page that looks like this:</p>
<pre><code>Company A<br />
123 Main St.<br />
Suite 101<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
Company B<br />
456 Main St.<br />
Someplace, NY 1234<br />
<br />
<br />
<br />
</code></... | 7 | 2010-02-21T07:30:07Z | 25,754,374 | <p>You should look into the <code>.strings</code>attribute found in tags, then use "\n".join() on that.</p>
| 4 | 2014-09-09T22:12:25Z | [
"python",
"parsing",
"beautifulsoup"
] |
python 2.6.4 doesn't support mod_python? | 2,305,210 | <p>am looking for a way to run django by just using my xampp, and i bumped into this tutorial online
<a href="http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html" rel="nofollow">http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html</a>
according to the author, mod_python 3.3.1 is not supported by ... | 1 | 2010-02-21T07:40:43Z | 2,305,233 | <p>mod_python must be compiled against the specific version of Python that the handler will be run in. At the time there was probably no Windows installer for mod_python built against 2.6.4, hence the hysteria.</p>
<p>In all fairness, you should probably be using <a href="http://code.google.com/p/modwsgi/" rel="nofoll... | 6 | 2010-02-21T07:48:41Z | [
"python",
"django",
"mod-python"
] |
How can I limit an SQL query to be nondestructive? | 2,305,353 | <p>I'm planning on building a Django log-viewing app with powerful filters. I'd like to enable the user to finely filter the results with some custom (possibly DB-specific) SELECT queries.</p>
<p>However, I dislike giving the user write access to the database. Is there a way to make sure a query doesn't change anythin... | 2 | 2010-02-21T08:48:46Z | 2,305,359 | <p>Create and use non-modifiable views.</p>
| 1 | 2010-02-21T08:50:45Z | [
"python",
"sql",
"django",
"security",
"sql-injection"
] |
How can I limit an SQL query to be nondestructive? | 2,305,353 | <p>I'm planning on building a Django log-viewing app with powerful filters. I'd like to enable the user to finely filter the results with some custom (possibly DB-specific) SELECT queries.</p>
<p>However, I dislike giving the user write access to the database. Is there a way to make sure a query doesn't change anythin... | 2 | 2010-02-21T08:48:46Z | 2,305,379 | <p>Connect with a user that has only been granted SELECT permissions. Situations like this is why permissions exist in the first place.</p>
| 14 | 2010-02-21T08:57:39Z | [
"python",
"sql",
"django",
"security",
"sql-injection"
] |
Sampling keys due to their values | 2,305,501 | <p>I have a dictionary in python with key->value as <code>str->int</code>. If I have to chose a key based on it's own value, then as the value gets larger the key has a lower possibility of being chosen. </p>
<p>For example, if <code>key1=2</code> and <code>key2->1</code>, then the attitude of <code>key1</code> ... | 1 | 2010-02-21T09:52:19Z | 2,305,571 | <p>It the values are not too large, you can do it this way</p>
<pre><code>>>> from random import choice
>>> d={"key1":2,"key2":1}
>>> c=[]
>>> for k,v in d.items():
... c+=[k]*v
...
>>> choice(c)
'key1'
>>> sum(1 for x in range(100) if choice(c)=="key1")
63
>&... | 1 | 2010-02-21T10:24:24Z | [
"python",
"dictionary",
"sampling"
] |
Sampling keys due to their values | 2,305,501 | <p>I have a dictionary in python with key->value as <code>str->int</code>. If I have to chose a key based on it's own value, then as the value gets larger the key has a lower possibility of being chosen. </p>
<p>For example, if <code>key1=2</code> and <code>key2->1</code>, then the attitude of <code>key1</code> ... | 1 | 2010-02-21T09:52:19Z | 2,305,591 | <p>If the values are too large for gnibler's approach:</p>
<p>Build a list of tuples <code>(key, index)</code>, where <code>index</code> is the sum of all values that come before key in the list (this would be the index of the first occurrence of <code>key</code> gnibler's list <code>c</code>. Also calculate the sum o... | 2 | 2010-02-21T10:36:44Z | [
"python",
"dictionary",
"sampling"
] |
Sampling keys due to their values | 2,305,501 | <p>I have a dictionary in python with key->value as <code>str->int</code>. If I have to chose a key based on it's own value, then as the value gets larger the key has a lower possibility of being chosen. </p>
<p>For example, if <code>key1=2</code> and <code>key2->1</code>, then the attitude of <code>key1</code> ... | 1 | 2010-02-21T09:52:19Z | 2,305,592 | <p><strong>1.</strong> Construct a CDF-like list like this:</p>
<pre><code>def build_cdf(distrib):
cdf = []
val = 0
for key, freq in distrib.items():
val += freq
cdf.append((val, key))
return (val, cdf)
</code></pre>
<p>This function returns a tuple, the 1st value is the sum of probabi... | 1 | 2010-02-21T10:37:44Z | [
"python",
"dictionary",
"sampling"
] |
Sampling keys due to their values | 2,305,501 | <p>I have a dictionary in python with key->value as <code>str->int</code>. If I have to chose a key based on it's own value, then as the value gets larger the key has a lower possibility of being chosen. </p>
<p>For example, if <code>key1=2</code> and <code>key2->1</code>, then the attitude of <code>key1</code> ... | 1 | 2010-02-21T09:52:19Z | 2,305,661 | <p>A quick and simple version of the algorithm from oefe's and KennyTM's answers:</p>
<pre><code>def select_weighted(d):
offset = random.randint(0, sum(d.itervalues())-1)
for k, v in d.iteritems():
if offset < v:
return k
offset -= v
</code></pre>
| 0 | 2010-02-21T11:13:03Z | [
"python",
"dictionary",
"sampling"
] |
Threading and pyfsevents | 2,305,701 | <p>The module <a href="http://pypi.python.org/pypi/pyfsevents" rel="nofollow">pyfsevents</a> allows Python programs to utilize the Mac OS X FSEvents framework. One can register a path and a callback function, then call the listen() function, which blocks until a file system event happens in the registered path.</p>
<p... | 0 | 2010-02-21T11:29:52Z | 2,306,153 | <p>Yes, as <a href="http://pypi.python.org/pypi/pyfsevents/0.2b1" rel="nofollow">the docs</a> say (under "Limitations"),</p>
<blockquote>
<p>Thread-unsafe: CFRunLoop's and Python
threads do not quite interact well
when put together :)</p>
</blockquote>
<p>What I recommend is using <a href="http://docs.python.or... | 1 | 2010-02-21T14:25:38Z | [
"python",
"osx",
"multithreading"
] |
Threading and pyfsevents | 2,305,701 | <p>The module <a href="http://pypi.python.org/pypi/pyfsevents" rel="nofollow">pyfsevents</a> allows Python programs to utilize the Mac OS X FSEvents framework. One can register a path and a callback function, then call the listen() function, which blocks until a file system event happens in the registered path.</p>
<p... | 0 | 2010-02-21T11:29:52Z | 10,757,766 | <p>Try out MacFSEvents. It is thread-safe. <a href="https://github.com/malthe/macfsevents" rel="nofollow">https://github.com/malthe/macfsevents</a></p>
| 0 | 2012-05-25T16:02:50Z | [
"python",
"osx",
"multithreading"
] |
How do I get started with zc.buildout and Distribute? | 2,305,723 | <p>I want to use buildout for dependency management, and I hear distribute is the new good way to manage installation of your project.</p>
<p>However, easy tutorials to get started seem to be thin on the ground. The most straight forward I've seen is Jacob Kaplan-Moss's <a href="http://jacobian.org/writing/django-apps... | 5 | 2010-02-21T11:37:32Z | 2,335,060 | <p>I've just started documenting the whole toolchain at <a href="http://reinout.vanrees.org/weblog/tags/softwarereleasesseries.html" rel="nofollow">http://reinout.vanrees.org/weblog/tags/softwarereleasesseries.html</a> (2010-02-25: still got to write the buildout and the pastescript article).</p>
<p>Basic toolchain id... | 6 | 2010-02-25T15:14:46Z | [
"python",
"buildout",
"distribute"
] |
How do I get started with zc.buildout and Distribute? | 2,305,723 | <p>I want to use buildout for dependency management, and I hear distribute is the new good way to manage installation of your project.</p>
<p>However, easy tutorials to get started seem to be thin on the ground. The most straight forward I've seen is Jacob Kaplan-Moss's <a href="http://jacobian.org/writing/django-apps... | 5 | 2010-02-21T11:37:32Z | 2,341,421 | <p>You've probably already found it, but have you checked out <a href="http://www.buildout.org" rel="nofollow">the buildout website</a> already?</p>
| 0 | 2010-02-26T12:08:42Z | [
"python",
"buildout",
"distribute"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,305,747 | <p>This is a simple O(n * m) algorithm:</p>
<pre><code>any(a[i:i + len(b)] == b for i in range(len(a) - len(b) + 1))
</code></pre>
<p>Note that is not the fastest way of doing this. If you need high performance you could use similar techniques to those used in <a href="http://en.wikipedia.org/wiki/String_searching_al... | 6 | 2010-02-21T11:47:07Z | [
"python",
"list"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,305,765 | <p>This is probably not very efficient, but you could use:</p>
<pre><code>In [1]: a = [1,3,2,2,2]
In [2]: b = [1,3,2]
In [3]: b == [val for val in a if val in b]
Out[3]: False
In [4]: a = [6,1,3,2,5,4]
In [5]: b == [val for val in a if val in b]
Out[5]: True
</code></pre>
<p>The first test returns False because o... | 0 | 2010-02-21T11:53:18Z | [
"python",
"list"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,305,807 | <p>if its "in the same order", </p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
>>> ' '.join(map(str,b)) in ' '.join(map(str,a))
True
>>> a = [1,1,2,2,2,13,2]
>>> b = [1,3,2]
>>> ' '.join(map(str,b)) in ' '.join(map(str,a))
False
</code></pre>
| -2 | 2010-02-21T12:11:18Z | [
"python",
"list"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,305,958 | <p>Here's a solution that works for lists of ints.</p>
<p>Turn for example [1, 3, 2] into the string "'1', '3', '2'". Then use built-in string inclusion to see if it's in the other list.</p>
<pre><code>repr(map(str, b))[1:-1] in repr(map(str, a))[1:-1]
</code></pre>
| 1 | 2010-02-21T13:11:14Z | [
"python",
"list"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,306,305 | <p>If by 'in the same order' you meant subsequence (as opposed to substring) then this non-one-liner should work fast:</p>
<pre><code> def is_subsequence(x, y):
i, j = 0, 0
while i < len(x) and j < len(y):
if x[i] == y[j]:
i += 1
j += 1
return i == len(x)
</code></pre>
| 2 | 2010-02-21T15:17:23Z | [
"python",
"list"
] |
Seeing if a list exists within another list? | 2,305,729 | <p>Basically lets say i have:</p>
<pre><code>>>> a = [1,3,2,2,2]
>>> b = [1,3,2]
</code></pre>
<p>I want to see if the all the elements in b, exists within a, and in the same order. So for the above example b would exist within a.</p>
<p>I am kinda hoping theres a really simple one line answer.</p>... | 3 | 2010-02-21T11:39:33Z | 2,307,305 | <p>Sorry, but what you want to do is effectively the same as string matching (albeit with lists instead of strings). You might want to look at <a href="http://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm" rel="nofollow">Knuth-Morris-Pratt</a> or <a href="http://en.wikipedia.org/wiki/Boyer%E2%80%93... | 0 | 2010-02-21T20:12:01Z | [
"python",
"list"
] |
python: dictionary dilemma: how to properly index objects based on an attribute | 2,305,798 | <p>first, an example:</p>
<blockquote>
<p>given a bunch of Person objects with
various attributes (name, ssn, phone,
email address, credit card #, etc.)</p>
<p>now imagine the following simple
website:</p>
<ol>
<li>uses a person's email address as unique login name</li>
<li>lets users edit their ... | 4 | 2010-02-21T12:07:43Z | 2,305,823 | <p>Consider this.</p>
<pre><code>class Person( object ):
def __init__( self, name, addr, email, etc. ):
self.observer= []
... etc. ...
@property
def name( self ): return self._name
@name.setter
def name( self, value ):
self._name= value
for observer in self.observed... | 3 | 2010-02-21T12:17:43Z | [
"python",
"design-patterns",
"data-structures",
"dictionary",
"indexing"
] |
python: dictionary dilemma: how to properly index objects based on an attribute | 2,305,798 | <p>first, an example:</p>
<blockquote>
<p>given a bunch of Person objects with
various attributes (name, ssn, phone,
email address, credit card #, etc.)</p>
<p>now imagine the following simple
website:</p>
<ol>
<li>uses a person's email address as unique login name</li>
<li>lets users edit their ... | 4 | 2010-02-21T12:07:43Z | 2,318,117 | <p>Well, another way may be to implement the following:</p>
<ol>
<li><p><code>Attr</code> is an abstraction for a "value". We need this since there is no "assignment overloading" in Python (simple get / set paradigm is used as the cleanest alternative). <code>Attr</code> also acts as an "Observable".</p></li>
<li><p><... | 0 | 2010-02-23T12:40:10Z | [
"python",
"design-patterns",
"data-structures",
"dictionary",
"indexing"
] |
UnicodeDecodeError problem with mechanize | 2,305,997 | <p>I receive the following string from one website via mechanize:</p>
<pre><code>'We\x92ve'
</code></pre>
<p>I know that \x92 stands for <strong>â</strong> character. I'm trying to convert that string to Unicode:</p>
<pre><code>>> unicode('We\x92ve','utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte... | 3 | 2010-02-21T13:24:39Z | 2,306,010 | <p><code>\x92</code> stands for <code>â</code> alright, but it does so in the Windows-1252 encoding, not in UTF-8:</p>
<pre><code>>>> print unicode('We\x92ve','1252')
Weâve
</code></pre>
<p>If you don't know what encoding your source data is in, you can detect it using <a href="http://chardet.feedparser.... | 3 | 2010-02-21T13:30:57Z | [
"python",
"unicode",
"mechanize"
] |
How to fix the wxpython events called? | 2,306,000 | <p>with this code:</p>
<pre><code>import wx
class Plugin(wx.Panel):
def __init__(self, parent, *args, **kwargs):
panel = wx.Panel.__init__(self, parent, *args, **kwargs)
self.colorOver = ((89,89,89))
self.colorLeave = ((110,110,110))
self.colorFont = ((145,145,145))
self.... | 0 | 2010-02-21T13:25:02Z | 2,309,367 | <p>Problem is you are hiding and showing bitmap on mouseover, so when you move mouseover bitmap, mouse goes off panel, onPanelMouseLeave is called and you hide bitmap, which means now mouse if over panel, onPanelMouseOver is called and in that event you again show bitmap and that means now mouse if over bitmap again an... | 2 | 2010-02-22T07:14:26Z | [
"python",
"events",
"button",
"wxpython",
"panel"
] |
How to get the status of an Asterisk Server using a Socket - Python | 2,306,115 | <p>I'm trying to get the status of an Asterisk Server using a python socket but nothing happens.</p>
<p>Here is my code:</p>
<pre><code>import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.105'
PORT = 5038
s.connect((HOST, PORT))
params = """Action: login
Events: off
Username: admin... | 2 | 2010-02-21T14:10:43Z | 2,307,557 | <p>You have malformed your code there. The Asterisk AMI requires \r\n termination between commands.</p>
<p>You need to send each command in a separate packet:</p>
<pre><code>params = """Action: login
Events: off
Username: admin
Secret: mypass"""
s.send(params + '\r\n')
data = s.recv(1024)
print data + '\n'
params =... | 2 | 2010-02-21T21:38:55Z | [
"python",
"sockets",
"asterisk"
] |
How to get the status of an Asterisk Server using a Socket - Python | 2,306,115 | <p>I'm trying to get the status of an Asterisk Server using a python socket but nothing happens.</p>
<p>Here is my code:</p>
<pre><code>import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.1.105'
PORT = 5038
s.connect((HOST, PORT))
params = """Action: login
Events: off
Username: admin... | 2 | 2010-02-21T14:10:43Z | 2,321,350 | <p>Handling of even such simple TCP based protocol may become tricky.</p>
<p>Problems in this case:</p>
<ol>
<li>Each line should be terminated with '\r\n' (not just '\n' as you send)</li>
<li>You should receive all output or the connection may block. Please note, that output may came in multiple chunks (though, it w... | 1 | 2010-02-23T20:11:48Z | [
"python",
"sockets",
"asterisk"
] |
How to write XML elements with namespaces in python | 2,306,149 | <p>I just tried this python 2.5 snippet to write some XML:</p>
<pre><code>xmldoc = xml.dom.minidom.Document()
feed = xmldoc.createElementNS("http://www.w3.org/2005/Atom", "feed")
xmldoc.appendChild(feed)
print xmldoc.toprettyxml()
</code></pre>
<p>I expected the output to look like this:</p>
<pre><code><?xml vers... | 1 | 2010-02-21T14:24:45Z | 2,306,216 | <p>minidom <a href="http://bugs.python.org/issue1621421" rel="nofollow">does not support</a> namespace normalization. The only workaround I'm aware of is explicitely setting the xmlns attribute with</p>
<pre><code>xmldoc.documentElement.setAttribute('xmlns', 'http://www.w3.org/2005/Atom')
</code></pre>
| 1 | 2010-02-21T14:46:09Z | [
"python",
"xml"
] |
Potential use of Python decorator or other refactorization: iterative optimization | 2,306,171 | <p>Forgive me for yet another question on Python decorators. I did read through many of them, but I wonder what the best solution to the specific following problem is.</p>
<p>I have written several functions that do some form of gradient descent in numpy/scipy. Given a matrix X, I try to iteratively minimize some dist... | 1 | 2010-02-21T14:32:34Z | 2,306,204 | <p>The following should work well as the decorator you want to use:</p>
<pre><code>import functools
def iterate(update):
@functools.wraps(update)
def inner(X, A=None, S=None, K=2, maxiter=10, c=0.1):
M, N = X.shape
O = matrix(ones([M, N]))
if A is None:
A = matrix(rand(M, K... | 5 | 2010-02-21T14:42:33Z | [
"python",
"refactoring",
"numpy",
"decorator"
] |
Numpy masked array modification | 2,306,280 | <p>Currently I have a code that checks if given element in array is equal = 0 and if so then set the value to 'level' value (temp_board is 2D numpy array, indices_to_watch contains 2D coordinates that should be watched for zeros).</p>
<pre><code> indices_to_watch = [(0,1), (1,2)]
for index in indices_to_watch:
... | 1 | 2010-02-21T15:05:05Z | 2,306,300 | <p>You should try something along those lines:</p>
<pre><code>temp_board[temp_board[field_list] == 0] = level
</code></pre>
| 0 | 2010-02-21T15:14:33Z | [
"python",
"numpy",
"masked-array"
] |
Numpy masked array modification | 2,306,280 | <p>Currently I have a code that checks if given element in array is equal = 0 and if so then set the value to 'level' value (temp_board is 2D numpy array, indices_to_watch contains 2D coordinates that should be watched for zeros).</p>
<pre><code> indices_to_watch = [(0,1), (1,2)]
for index in indices_to_watch:
... | 1 | 2010-02-21T15:05:05Z | 2,306,309 | <p>I'm not sure i follow all of the detail in your question. If i understood it correctly, then it seems like this is straightforward Numpy indexing. The code below checks the array (A) for zeros, and where it finds them, it replaces them with 'level'.</p>
<pre><code>import numpy as NP
A = NP.random.randint(0, 10, 20)... | 1 | 2010-02-21T15:18:42Z | [
"python",
"numpy",
"masked-array"
] |
Numpy masked array modification | 2,306,280 | <p>Currently I have a code that checks if given element in array is equal = 0 and if so then set the value to 'level' value (temp_board is 2D numpy array, indices_to_watch contains 2D coordinates that should be watched for zeros).</p>
<pre><code> indices_to_watch = [(0,1), (1,2)]
for index in indices_to_watch:
... | 1 | 2010-02-21T15:05:05Z | 2,316,797 | <p>Assuming that it is not very inefficient to find out where <code>temp_board</code> is <code>0</code>, you can do what you want like this:</p>
<pre><code># First figure out where the array is zero
zindex = numpy.where(temp_board == 0)
# Make a set of tuples out of it
zindex = set(zip(*zindex))
# Make a set of tuples... | 1 | 2010-02-23T08:50:01Z | [
"python",
"numpy",
"masked-array"
] |
Reading text files into list, then storing in dictionay fills system memory ? (A what am I doing wrong?) Python | 2,306,523 | <p>I have 43 text files that consume "232.2 MB on disk (232,129,355 bytes) for 43 items". what to read them in to memory (see code below). The problem I am having is that each file which is about 5.3mb on disk is causing python to use an additional 100mb of system memory. If check the size of the dict() getsizeof() (se... | 1 | 2010-02-21T16:35:01Z | 2,306,660 | <p>This line specifically gets the size of the function object:</p>
<pre><code>print str(sys.getsizeof(ImportDataFrom))
</code></pre>
<p>that's unlikely to be what you're interested in.</p>
<p>The size of a container does <strong>not</strong> include the size of the data it contains. Consider, for example:</p>
<pr... | 2 | 2010-02-21T17:17:52Z | [
"python",
"memory",
"file"
] |
Reading text files into list, then storing in dictionay fills system memory ? (A what am I doing wrong?) Python | 2,306,523 | <p>I have 43 text files that consume "232.2 MB on disk (232,129,355 bytes) for 43 items". what to read them in to memory (see code below). The problem I am having is that each file which is about 5.3mb on disk is causing python to use an additional 100mb of system memory. If check the size of the dict() getsizeof() (se... | 1 | 2010-02-21T16:35:01Z | 2,307,000 | <p>The dictionary itself is very small - the bulk of the data is the whole content of the files stored in lists, containing one tuple per line. The 20x size increase is bigger than I expected but seems to be real. Splitting a 27-bytes line from your example input into a tuple, gives me 309 bytes (counting recursively... | 3 | 2010-02-21T18:53:14Z | [
"python",
"memory",
"file"
] |
gstreamer: interleaving 2 audios - link error | 2,306,605 | <p>I am trying to interleave two audio files as given in the interleave GStreamer documentation:</p>
<pre><code>gst-launch interleave name=i ! audioconvert ! wavenc ! filesink location=file.wav filesrc location=file1.wav ! \
decodebin ! audioconvert ! "audio/x-raw-int,channels=1" ! queue ! i.sink0 filesrc location=... | 2 | 2010-02-21T16:57:54Z | 2,866,398 | <p>try</p>
<pre><code>gst-launch interleave name=i ! audioconvert ! wavenc ! filesink location=file.wav filesrc location=file1.wav ! \
decodebin ! audioconvert ! "audio/x-raw-int,channels=1" ! queue ! i. filesrc location=file2.wav ! \
decodebin ! audioconvert ! "audio/x-raw-int,channels=1" ! queue ! i.
</code></pr... | 0 | 2010-05-19T14:26:41Z | [
"c#",
"c++",
"python",
"gstreamer"
] |
Django form validation: making "required" conditional? | 2,306,800 | <p>I'm new to Django (and Python), and am trying to figure out how to conditionalize certain aspects of form validation. In this case, there's a HTML interface to the application where the user can choose a date and a time from widgets. The <code>clean</code> method on the form object takes the values of the time and d... | 11 | 2010-02-21T18:00:06Z | 2,307,132 | <p>This is done with the <code>clean</code> method on the form. You need to set <code>foo_date</code> and <code>foo_time</code> to <code>required=False</code>, though, because <code>clean</code> is only called after every field has been validated (see also the <a href="http://docs.djangoproject.com/en/dev/ref/forms/val... | 19 | 2010-02-21T19:25:40Z | [
"python",
"django",
"django-forms"
] |
Django form validation: making "required" conditional? | 2,306,800 | <p>I'm new to Django (and Python), and am trying to figure out how to conditionalize certain aspects of form validation. In this case, there's a HTML interface to the application where the user can choose a date and a time from widgets. The <code>clean</code> method on the form object takes the values of the time and d... | 11 | 2010-02-21T18:00:06Z | 14,917,108 | <p>I found myself needing a "standard" way to do this, as my forms have several conditionally required fields. So I created a superclass with the following method:</p>
<pre><code>def validate_required_field(self, cleaned_data, field_name, message="This field is required"):
if(field_name in cleaned_data and cleaned... | 6 | 2013-02-17T01:28:48Z | [
"python",
"django",
"django-forms"
] |
Variable Files with Python | 2,306,947 | <p>I am trying to have a file path like 'C:\Programfiles\file.txt' but i would like to have file.txt be a variable that i can change whenever i need to. I am trying to compare 2 directories then copy files from one to another if they arent already there. i have this code so far.</p>
<pre><code>import os
import shutil
... | 2 | 2010-02-21T18:40:18Z | 2,306,997 | <p>Use <code>%s</code> instead of <code>%r</code>, and <code>C.pop().replace(' ', '\\ ')</code> instead of <code>C</code>, which is a <code>set</code> and not a string (the <code>replace</code> is needed to "escape" every space -- I think). Last but not least, I think you're using <code>shutil.copy2</code> wrong: see ... | 1 | 2010-02-21T18:53:00Z | [
"python",
"file",
"variables",
"python-3.x"
] |
Variable Files with Python | 2,306,947 | <p>I am trying to have a file path like 'C:\Programfiles\file.txt' but i would like to have file.txt be a variable that i can change whenever i need to. I am trying to compare 2 directories then copy files from one to another if they arent already there. i have this code so far.</p>
<pre><code>import os
import shutil
... | 2 | 2010-02-21T18:40:18Z | 2,307,065 | <p>Please use <code>os.path.join</code> to construct paths. Also, you should put the directories in variables for reuse. Furthermore you need to iterate over the difference between the folders (<code>B - A</code>) in order to get each filename that's in the difference set (<code>C</code> is the set of files that have b... | 4 | 2010-02-21T19:10:08Z | [
"python",
"file",
"variables",
"python-3.x"
] |
Variable Files with Python | 2,306,947 | <p>I am trying to have a file path like 'C:\Programfiles\file.txt' but i would like to have file.txt be a variable that i can change whenever i need to. I am trying to compare 2 directories then copy files from one to another if they arent already there. i have this code so far.</p>
<pre><code>import os
import shutil
... | 2 | 2010-02-21T18:40:18Z | 2,308,108 | <p>you should use a library like <a href="http://docs.python.org/library/filecmp.html" rel="nofollow">filecmp</a> to compare directories/files</p>
<pre><code>>>> import filecmp
>>> import os
>>> dira = os.path.join("/home","dir1")
>>> dirb = os.path.join("/home","dir2")
>>>... | 2 | 2010-02-22T00:28:44Z | [
"python",
"file",
"variables",
"python-3.x"
] |
Exchange Oauth Request Token for Access Token fails Google API | 2,306,984 | <p>I am having trouble exchanging my Oauth request token for an Access Token. My Python application successfully asks for a Request Token and then redirects to the Google login page asking to grant access to my website. When I grant access I retrieve a 200 status code but exchanging this authorized request token for an... | 2 | 2010-02-21T18:50:17Z | 3,110,939 | <p>When you're exchanging for the access token, the oauth_verifier parameter is required. If you don't provide that parameter, then google will tell you that the token is invalid.</p>
| 1 | 2010-06-24T14:35:53Z | [
"python",
"oauth",
"google-api"
] |
Modifiying a Django view for a certain project | 2,307,219 | <p>So I simply want to use the delete() from the django.contrib.comments.views.moderation module, but only allowing the users with permission to delete their comments. In order to do this, all I have to do is uncomment <code>#@permission_required("comments.delete_comment")</code>, but I want to be able to do this witho... | 0 | 2010-02-21T19:50:03Z | 2,309,572 | <p>That line is only commented out because Django 1.1 maintains compatibility with Python 2.3 which doesn't support the decorator (<code>@</code>) syntax. But the view is decorated with <code>permission_required</code> nonetheless (with syntax that is compatible with Python 2.3), as you can see <a href="http://code.dja... | 0 | 2010-02-22T08:10:15Z | [
"python",
"django",
"django-comments"
] |
Pass array of structs from Python to C | 2,307,290 | <p><strong>[Update: Problem solved! See bottom of the post]</strong></p>
<p>I need to allow python developers to pass an array of packed data (in this case vertices) into my API, which is a series of C++ interfaces exposed manually through the Python C API. My initial impression with this is to use the ctypes Structur... | 7 | 2010-02-21T20:07:51Z | 2,308,691 | <p>Not tested but you should give this a try and let us know if its fast enough for your needs.</p>
<p>On the python side, pack the vertices into a string instead of an object.</p>
<pre><code>str = "" # byte stream for encoding data
str += struct.pack("5f i", vert1.x, vert1.y, vert1.z, vert1.u, vert1.v, vert1.color) ... | 2 | 2010-02-22T03:51:46Z | [
"python",
"python-3.x",
"structure",
"python-c-api"
] |
Pass array of structs from Python to C | 2,307,290 | <p><strong>[Update: Problem solved! See bottom of the post]</strong></p>
<p>I need to allow python developers to pass an array of packed data (in this case vertices) into my API, which is a series of C++ interfaces exposed manually through the Python C API. My initial impression with this is to use the ctypes Structur... | 7 | 2010-02-21T20:07:51Z | 2,308,717 | <p>The easiest thing I can see to do would be to just avoid the issue altogether and expose a Device_ReadVertex that takes in x, y, z, u, v and color as arguments. This has obvious drawbacks, like making the Python programmers feed it vertices one by one.</p>
<p>If that's not good enough (seems likely it isn't), then... | 1 | 2010-02-22T04:02:40Z | [
"python",
"python-3.x",
"structure",
"python-c-api"
] |
What is the difference between root.destroy() and root.quit()? | 2,307,464 | <p>In Python using <code>tkinter</code>, what is the difference between <code>root.destroy()</code> and <code>root.quit()</code> when closing the root window?</p>
<p>Is one prefered over the other? Does one release resources that the other doesn't?</p>
| 18 | 2010-02-21T21:09:21Z | 2,308,687 | <p>"quit() stops the TCL interpreter. This is in most cases what you want, because your Tkinter-app will also stop. It can be a problem, if you e.g. call your app from idle. idle is itself a Tkinker-app, so if you call quit() in your app and the TCL interpreter gets terminated, idle will also terminate (or get confused... | 17 | 2010-02-22T03:50:24Z | [
"python",
"tkinter"
] |
Generating and applying diffs in python | 2,307,472 | <p>Is there an 'out-of-the-box' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later? </p>
<p>I want to keep the revision history of a text, but I don't want to save the entire text for each revision if there is just a single edited line.... | 20 | 2010-02-21T21:13:09Z | 2,307,489 | <p>Does it have to be a python solution?<br>
My first thoughts as to a solution would be to use either a Version Control System (Subversion, Git, etc.) or the <code>diff</code> / <code>patch</code> utilities that are standard with a unix system, or are part of <code>cygwin</code> for a windows based system.</p>
| 2 | 2010-02-21T21:18:06Z | [
"python",
"diff",
"revision",
"difflib"
] |
Generating and applying diffs in python | 2,307,472 | <p>Is there an 'out-of-the-box' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later? </p>
<p>I want to keep the revision history of a text, but I don't want to save the entire text for each revision if there is just a single edited line.... | 20 | 2010-02-21T21:13:09Z | 2,307,541 | <p>AFAIK most diff algorithms use a simple <a href="http://en.wikipedia.org/wiki/Longest_common_subsequence_problem" rel="nofollow">Longest Common Subsequence</a> match, to find the common part between two texts and whatever is left is considered the difference. It shouldn't be too difficult to code up your own dynamic... | 2 | 2010-02-21T21:34:57Z | [
"python",
"diff",
"revision",
"difflib"
] |
Generating and applying diffs in python | 2,307,472 | <p>Is there an 'out-of-the-box' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later? </p>
<p>I want to keep the revision history of a text, but I don't want to save the entire text for each revision if there is just a single edited line.... | 20 | 2010-02-21T21:13:09Z | 2,307,741 | <p>Did you have a look at diff-match-patch from google? Apparantly google Docs uses this set of algoritms. It includes not only a diff module, but also a patch module, so you can generate the newest file from older files and diffs.</p>
<p>A python version is included.</p>
<p><a href="http://code.google.com/p/google-d... | 21 | 2010-02-21T22:39:28Z | [
"python",
"diff",
"revision",
"difflib"
] |
Generating and applying diffs in python | 2,307,472 | <p>Is there an 'out-of-the-box' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later? </p>
<p>I want to keep the revision history of a text, but I don't want to save the entire text for each revision if there is just a single edited line.... | 20 | 2010-02-21T21:13:09Z | 2,307,743 | <p>Does difflib.unified_diff do want you want? There is an example <a href="http://www.doughellmann.com/PyMOTW/difflib/index.html">here</a>.</p>
| 9 | 2010-02-21T22:39:35Z | [
"python",
"diff",
"revision",
"difflib"
] |
Generating and applying diffs in python | 2,307,472 | <p>Is there an 'out-of-the-box' way in python to generate a list of differences between two texts, and then applying this diff to one file to obtain the other, later? </p>
<p>I want to keep the revision history of a text, but I don't want to save the entire text for each revision if there is just a single edited line.... | 20 | 2010-02-21T21:13:09Z | 35,889,979 | <p>Probably you can use <a href="https://docs.python.org/2/library/difflib.html" rel="nofollow">unified_diff</a> to generate the list of difference in a file. Only the changed texts in your file can be written it into a new text file where you can use it for your future reference.
This is the code which helps you to w... | 0 | 2016-03-09T11:13:15Z | [
"python",
"diff",
"revision",
"difflib"
] |
Python JSON New York Times API | 2,307,523 | <p>Really new to Python and getting data from the web, so here it goes.</p>
<p>I have been able to pull data from the NYT api and parse the JSON output into a CSV file. However, depending on my search, I may get the following error when I attempt to write a row to the CSV.</p>
<blockquote>
<p>UnicodeEncodeError: '... | 2 | 2010-02-21T21:28:58Z | 2,307,582 | <p>Every piece of textual data is encoded. It's hard to tell what the problem is without any code, so the only advice I can give now is: Try decoding the response before parsing it ...</p>
<pre><code>resp = do_request()
## look on the nyt site if they mention the encoding used and use it instead.
decoded = resp.decode... | 0 | 2010-02-21T21:45:47Z | [
"python",
"json",
"api"
] |
Python JSON New York Times API | 2,307,523 | <p>Really new to Python and getting data from the web, so here it goes.</p>
<p>I have been able to pull data from the NYT api and parse the JSON output into a CSV file. However, depending on my search, I may get the following error when I attempt to write a row to the CSV.</p>
<blockquote>
<p>UnicodeEncodeError: '... | 2 | 2010-02-21T21:28:58Z | 2,308,566 | <p>It appears to be trying to decode '\/' which is used whenever a slash is used. This can be avoided by making using the string function.</p>
<pre><code>str('http:\/\/www.nytimes.com\/2010\/02\/17\/business\/global\/17barclays.html')
'http:\\/\\/www.nytimes.com\\/2010\\/02\\/17\\/business\\/global\\/17barclays.html'... | 0 | 2010-02-22T03:04:49Z | [
"python",
"json",
"api"
] |
Python JSON New York Times API | 2,307,523 | <p>Really new to Python and getting data from the web, so here it goes.</p>
<p>I have been able to pull data from the NYT api and parse the JSON output into a CSV file. However, depending on my search, I may get the following error when I attempt to write a row to the CSV.</p>
<blockquote>
<p>UnicodeEncodeError: '... | 2 | 2010-02-21T21:28:58Z | 2,365,608 | <p>You need to check your HTTP headers to see what char encoding they are using when returning the results. My bet is that everything is encoded as utf-8 and when you try to write to CSV, you are implicitly encoding output as ascii. </p>
<p>The ' they are using is not in the ascii char set. You can catch the Unicod... | 1 | 2010-03-02T18:22:55Z | [
"python",
"json",
"api"
] |
Python JSON New York Times API | 2,307,523 | <p>Really new to Python and getting data from the web, so here it goes.</p>
<p>I have been able to pull data from the NYT api and parse the JSON output into a CSV file. However, depending on my search, I may get the following error when I attempt to write a row to the CSV.</p>
<blockquote>
<p>UnicodeEncodeError: '... | 2 | 2010-02-21T21:28:58Z | 15,287,078 | <p>Be careful about nytimes API -- it does not provide you the full body text.</p>
| 0 | 2013-03-08T05:04:08Z | [
"python",
"json",
"api"
] |
Python class syntax - is this a good idea? | 2,307,590 | <p>I'm tempted to define my Python classes like this:</p>
<pre><code>class MyClass(object):
"""my docstring"""
msg = None
a_variable = None
some_dict = {}
def __init__(self, msg):
self.msg = msg
</code></pre>
<p>Is declaring the object variables (msg, a_variable, etc) at the top, like Ja... | 4 | 2010-02-21T21:47:36Z | 2,307,601 | <p>Defining variables in the class defintion like that makes the variable accessible between every instance of that class. In Java terms it is <em>a bit like</em> making the variable static. However, there are major differences as show below.</p>
<pre><code>class MyClass(object):
msg = "ABC"
print MyClass.msg ... | 8 | 2010-02-21T21:50:22Z | [
"python",
"syntax"
] |
Python class syntax - is this a good idea? | 2,307,590 | <p>I'm tempted to define my Python classes like this:</p>
<pre><code>class MyClass(object):
"""my docstring"""
msg = None
a_variable = None
some_dict = {}
def __init__(self, msg):
self.msg = msg
</code></pre>
<p>Is declaring the object variables (msg, a_variable, etc) at the top, like Ja... | 4 | 2010-02-21T21:47:36Z | 2,307,613 | <p>Careful. The two msg attributes are actually stored in two different dictionaries.
One overshadows the other, but the clobbered <code>msg</code> attribute is still taking up space in a dictionary. So it goes unused and yet still takes up some memory.</p>
<pre><code>class MyClass(object):
msg = 'FeeFiFoFum' ... | 4 | 2010-02-21T21:54:05Z | [
"python",
"syntax"
] |
Python class syntax - is this a good idea? | 2,307,590 | <p>I'm tempted to define my Python classes like this:</p>
<pre><code>class MyClass(object):
"""my docstring"""
msg = None
a_variable = None
some_dict = {}
def __init__(self, msg):
self.msg = msg
</code></pre>
<p>Is declaring the object variables (msg, a_variable, etc) at the top, like Ja... | 4 | 2010-02-21T21:47:36Z | 2,307,625 | <p>Declaring variables directly inside the class definition makes them class variables instead of instance variables. Class variables are somewhat similar to static variables in Java and should be used like <code>MyClass.a_variable</code>. But they can also be used like <code>self.a_variable</code>, which is a problem ... | 6 | 2010-02-21T21:59:40Z | [
"python",
"syntax"
] |
Python class syntax - is this a good idea? | 2,307,590 | <p>I'm tempted to define my Python classes like this:</p>
<pre><code>class MyClass(object):
"""my docstring"""
msg = None
a_variable = None
some_dict = {}
def __init__(self, msg):
self.msg = msg
</code></pre>
<p>Is declaring the object variables (msg, a_variable, etc) at the top, like Ja... | 4 | 2010-02-21T21:47:36Z | 2,307,716 | <p>When you declare a class, Python will parse its code and put everything in the namespace of the class; then the class will be used as a kind of template for all objects derived from it - but any object will have its own copy of the reference.<br>
Note that you <em>always</em> have a reference; as such, if you are ab... | 1 | 2010-02-21T22:30:45Z | [
"python",
"syntax"
] |
Uploading a HTML file to Google App Engine - getting 405 | 2,307,645 | <p>I'm trying to do a simple echo app using Python. I want to submit a file with a POST form and echo it back (an HTML file).</p>
<p>Here's the <code>handlers</code> section of the YAML I'm using: </p>
<pre><code>handlers:
- url: /statics
static_dir: statics
- url: .*
script: main.py
</code></pre>
<p>It's basic... | 3 | 2010-02-21T22:07:22Z | 2,307,729 | <p>You are submitting your form with the POST method, but you implemented a <code>get()</code> handler instead of a <code>post()</code> handler. Changing <code>def get(self):</code> to <code>def post(self):</code> should fix the HTTP 405 error.</p>
| 9 | 2010-02-21T22:35:07Z | [
"python",
"google-app-engine"
] |
How does assignment of a function as a class attribute become a method in Python? | 2,307,653 | <pre><code>>>> class A(object): pass
>>> def func(cls): pass
>>> A.func = func
>>> A.func
<unbound method A.func>
</code></pre>
<p>How does this assignment create a method? It seems unintuitive that assignment does the following for classes:</p>
<ul>
<li>Turn functions into u... | 9 | 2010-02-21T22:11:43Z | 2,307,713 | <p>Point 1: The function <code>func</code> you defined exists as a <a href="http://en.wikipedia.org/wiki/First-class_object" rel="nofollow">First-Class Object</a> in Python.</p>
<p>Point 2: Classes in Python store their attributes in their <code>__dict__</code>.</p>
<p>So what happens when you pass a function as the ... | 0 | 2010-02-21T22:30:22Z | [
"python",
"class-method"
] |
How does assignment of a function as a class attribute become a method in Python? | 2,307,653 | <pre><code>>>> class A(object): pass
>>> def func(cls): pass
>>> A.func = func
>>> A.func
<unbound method A.func>
</code></pre>
<p>How does this assignment create a method? It seems unintuitive that assignment does the following for classes:</p>
<ul>
<li>Turn functions into u... | 9 | 2010-02-21T22:11:43Z | 2,307,744 | <p>Relating to MTsoul's comment to Gabriel Hurley's answer:</p>
<p>What is different is that <code>func</code> has a <code>__call__()</code> method, making it "callable", i.e. you can apply the <code>()</code> operator to it. Check out <a href="http://docs.python.org/reference/datamodel.html" rel="nofollow">the Python... | 0 | 2010-02-21T22:39:41Z | [
"python",
"class-method"
] |
How does assignment of a function as a class attribute become a method in Python? | 2,307,653 | <pre><code>>>> class A(object): pass
>>> def func(cls): pass
>>> A.func = func
>>> A.func
<unbound method A.func>
</code></pre>
<p>How does this assignment create a method? It seems unintuitive that assignment does the following for classes:</p>
<ul>
<li>Turn functions into u... | 9 | 2010-02-21T22:11:43Z | 2,307,753 | <p>What you have to consider is that in Python <a href="http://diveintopython.net/getting_to_know_python/everything_is_an_object.html" rel="nofollow"><strong>everything</strong> is an object</a>. By establishing that it is easier to understand what is happening. If you have a function <code>def foo(bar): print bar</cod... | 3 | 2010-02-21T22:42:53Z | [
"python",
"class-method"
] |
How does assignment of a function as a class attribute become a method in Python? | 2,307,653 | <pre><code>>>> class A(object): pass
>>> def func(cls): pass
>>> A.func = func
>>> A.func
<unbound method A.func>
</code></pre>
<p>How does this assignment create a method? It seems unintuitive that assignment does the following for classes:</p>
<ul>
<li>Turn functions into u... | 9 | 2010-02-21T22:11:43Z | 2,307,992 | <p><a href="http://docs.python.org/reference/datamodel.html#descriptors" rel="nofollow">Descriptors</a> are the magic<sup>1</sup> that turns an ordinary function into a bound or unbound method when you retrieve it from an instance or class, since theyâre all just functions that need different binding strategies. The ... | 4 | 2010-02-21T23:48:28Z | [
"python",
"class-method"
] |
How does assignment of a function as a class attribute become a method in Python? | 2,307,653 | <pre><code>>>> class A(object): pass
>>> def func(cls): pass
>>> A.func = func
>>> A.func
<unbound method A.func>
</code></pre>
<p>How does this assignment create a method? It seems unintuitive that assignment does the following for classes:</p>
<ul>
<li>Turn functions into u... | 9 | 2010-02-21T22:11:43Z | 2,308,271 | <p>You're right that this has something to do with descriptor protocol. Descriptors are how passing the receiver object as the first parameter of a method is implemented in Python. You can read more detail about Python attribute lookup from <a href="http://stackoverflow.com/questions/852308/how-the-method-resolution-an... | 4 | 2010-02-22T01:23:20Z | [
"python",
"class-method"
] |
When using Parallel Python, is there any way to tell on which machine the job has run? | 2,307,739 | <p>I have written a simple program using parallel python, and all works well. However, mainly for curiosities sake, I would like to know on which machine each task ran, and how long it took.</p>
<p>Is there any way to programmatically get this information for the job that is returned?</p>
| 3 | 2010-02-21T22:39:21Z | 2,311,629 | <p>A uuid1 could help:</p>
<pre><code>>>> import uuid
>>> uuid.uuid1()
UUID('b46fa8cf-1fc1-11df-b891-001641ec3fab')
>>>
</code></pre>
<p>See pydoc uuid and the RFC 4122 for more details, I think the last 48 bits are unique to the host. Not sure you you call/return that in Parallel python ... | 1 | 2010-02-22T14:53:20Z | [
"python",
"parallel-python"
] |
Encoding detection library in python | 2,307,795 | <p>This is somehow related to my question <a href="http://stackoverflow.com/questions/2305997/unicodedecodeerror-problem-with-mechanize">here</a>.</p>
<p>I process tons of texts (in HTML and XML mainly) fetched via HTTP. I'm looking for a library in python that can do smart encoding detection based on different strate... | 3 | 2010-02-21T22:55:54Z | 2,307,806 | <p>BeautifulSoup (the html parser) incorporates a class called UnicodeDammit that does just that. Have a look and see if you like it. </p>
| 3 | 2010-02-21T22:58:15Z | [
"python",
"html",
"xml",
"http",
"character-encoding"
] |
Encoding detection library in python | 2,307,795 | <p>This is somehow related to my question <a href="http://stackoverflow.com/questions/2305997/unicodedecodeerror-problem-with-mechanize">here</a>.</p>
<p>I process tons of texts (in HTML and XML mainly) fetched via HTTP. I'm looking for a library in python that can do smart encoding detection based on different strate... | 3 | 2010-02-21T22:55:54Z | 2,308,000 | <p><a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>'s <a href="http://www.crummy.com/software/BeautifulSoup/documentation.html#Beautiful%20Soup%20Gives%20You%20Unicode,%20Dammit" rel="nofollow">UnicodeDammit</a>, which in turn uses <a href="https://pypi.python.org/pypi/chardet" r... | 9 | 2010-02-21T23:52:44Z | [
"python",
"html",
"xml",
"http",
"character-encoding"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.