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 |
|---|---|---|---|---|---|---|---|---|---|
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 54,034 | <p>jQuery is a fine library, but also check out the <a href="http://www.prototypejs.org/" rel="nofollow">Prototype JavaScript framework</a>. It really turns JavaScript from being an occasionally awkward language into a beautiful and elegant language.</p>
| 1 | 2008-09-10T13:29:54Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 55,041 | <p>There is no reason why you shouldn't use GAE and Google Web Toolkit (GWT) together. You write your backend code in Python and the frontend code in Java (and possibly some JavaScript), which is then compiled to JavaScript. When using another AJAX framework you will also have this difference between server and client ... | 4 | 2008-09-10T19:00:38Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 62,976 | <p>If you want to be able to invoke method calls from JavaScript to Python, <a href="http://json-rpc.org/wiki/python-json-rpc" rel="nofollow">JSON-RPC</a> works well with Google App Engine. See Google's article, "<a href="http://code.google.com/appengine/articles/rpc.html" rel="nofollow">Using AJAX to Enable Client RP... | 0 | 2008-09-15T13:43:08Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 230,476 | <p>I'm currently using JQuery for my GAE app and it works beautifully for me. I have a chart (google charts) that is dynamic and uses an Ajax call to grab a JSON string. It really seems to work fine for me.</p>
| 0 | 2008-10-23T16:41:43Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 352,120 | <p>You may want to have a look at Pyjamas (<a href="http://pyjs.org/" rel="nofollow">http://pyjs.org/</a>), which is "GWT for Python". </p>
| 2 | 2008-12-09T08:33:51Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 605,156 | <p>Here is how we've implemented Ajax on the Google App Engine, but the idea can be generalized to other platforms.</p>
<p>We have a handler script for Ajax requests that responds -mostly- with JSON responses. The structure looks something like this (this is an excerpt from a standard GAE handler script):</p>
<pre><c... | 4 | 2009-03-03T04:56:35Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 800,037 | <p>A nice way is to use an AJAX library is to take advantage of <a href="http://code.google.com/apis/ajaxlibs/" rel="nofollow">Google's AJAX Libraries API service</a>. This is a bit faster and cleaner than downloading the JS and putting it in your <code>/static/</code> folder and doesn't eat into your disk quota.</p>
... | 7 | 2009-04-28T22:08:08Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 800,072 | <p>Google has recently announced the Java version of Google App Engine. This release also provides an Eclipse plugin that makes developing GAE applications with GWT easier.</p>
<p>See details here: <a href="http://code.google.com/appengine/docs/java/overview.html" rel="nofollow">http://code.google.com/appengine/docs/j... | 0 | 2009-04-28T22:17:55Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 994,994 | <p>try also <a href="http://ajaxian.com/archives/gquery-java-gwt-and-jquery-together" rel="nofollow">GQuery for GWT</a>. This is Java code:</p>
<pre><code>public void onModuleLoad() {
$("div").css("color", "red").click(new Function() {
public void f(Element e) {
Window.alert("Hello");
... | 2 | 2009-06-15T08:12:29Z | [
"python",
"ajax",
"google-app-engine"
] |
Any good AJAX framework for Google App Engine apps? | 53,997 | <p>I am trying to implement AJAX in my Google App Engine application, and so I am looking for a good AJAX framework that will help me. Anyone has any idea?</p>
<p>I am thinking about Google Web Toolkit, how good it is in terms of creating AJAX for Google App Engine?</p>
| 12 | 2008-09-10T13:12:07Z | 1,037,446 | <p>In my blog I deal with an easy way to do this - the link is: <a href="http://pythoughts.com/ajax-with-google-app-engine" rel="nofollow">AJAX with Google App Engine</a>.
I include all the javascript and python code I used.</p>
| 3 | 2009-06-24T10:01:26Z | [
"python",
"ajax",
"google-app-engine"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 54,873 | <p>From <a href="http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes">http://docs.python.org/2/reference/datamodel.html#new-style-and-classic-classes</a> :</p>
<blockquote>
<p>Up to Python 2.1, old-style classes were the only flavour available to the user. The concept of (old-style) class... | 340 | 2008-09-10T18:02:43Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 55,354 | <p>Or rather, you should always use new-style classes, <em>unless</em> you have code that needs to work with versions of Python older than 2.2.</p>
| 4 | 2008-09-10T21:23:53Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 242,700 | <p>New-style classes inherit from <code>object</code> and must be written as such in Python 2.2 onwards (i.e. <code>class Classname(object):</code> instead of <code>class Classname:</code>). The core change is to unify types and classes, and the nice side-effect of this is that it allows you to inherit from built-in ty... | 5 | 2008-10-28T09:54:30Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 1,203,997 | <p><strong>Declaration-wise:</strong></p>
<p>New-style classes inherit from object, or from another new-style class.</p>
<pre><code>class NewStyleClass(object):
pass
class AnotherNewStyleClass(NewStyleClass):
pass
</code></pre>
<p>Old-style classes don't.</p>
<pre><code>class OldStyleClass():
pass
</co... | 220 | 2009-07-30T01:21:59Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 3,228,045 | <p>Old style classes are still marginally faster for attribute lookup. This is not usually important, but may be useful in performance-sensitive Python 2.x code:</p>
<pre>
In [3]: class A:
...: def __init__(self):
...: self.a = 'hi there'
...:
In [4]: class B(object):
...: def __init__(se... | 29 | 2010-07-12T11:26:52Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 16,193,572 | <p>Guido has written <a href="http://python-history.blogspot.com/2010/06/inside-story-on-new-style-classes.html">The Inside Story on New-Style Classes</a>, a really great article about new-style and old-style class in Python.</p>
<p>Python 3 has only new-style class, even if you write an 'old-style class', it is impli... | 22 | 2013-04-24T13:41:26Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 16,295,402 | <p>New style classes may use <code>super(Foo, self)</code> where <code>Foo</code> is a class and <code>self</code> is the instance.</p>
<blockquote>
<p><code>super(type[, object-or-type])</code></p>
<p>Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for acc... | 4 | 2013-04-30T08:28:52Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 19,273,761 | <p>Here's a very practical, True/False difference. The only difference between the two versions of the following code is that in the second version Person inherits from object. Other than that the two versions are identical, but with different results :</p>
<p>1) old-style classes</p>
<pre><code>class Person():
_... | 8 | 2013-10-09T13:40:29Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
What is the difference between old style and new style classes in Python? | 54,867 | <p>What is the difference between old style and new style classes in Python? Is there ever a reason to use old-style classes these days?</p>
| 604 | 2008-09-10T18:01:27Z | 19,950,198 | <p><strong>Important behavior changes between old and new style classes</strong></p>
<ul>
<li><a href="http://stackoverflow.com/questions/576169/understanding-python-super-and-init-methods">super</a> added</li>
<li>MRO changed (explained below)</li>
<li><a href="http://docs.python.org/2/howto/descriptor.html">descript... | 126 | 2013-11-13T09:36:59Z | [
"python",
"class",
"oop",
"types",
"new-style-class"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 55,188 | <p>This snippet will do so. If you're going to do it frequently, you might want to make a 'sortkeys' method or somesuch to make it easier on the eyes.</p>
<pre><code>keys = list(d.keys())
keys.sort()
for key in keys:
print d[key]
</code></pre>
<p>Edit: dF's solution is better -- I forgot all about sorted().</p>... | 1 | 2008-09-10T20:08:48Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 55,193 | <p>Do you mean that you need the values sorted by the value of the key?
In that case, this should do it:</p>
<pre><code>for key in sorted(d):
print d[key]
</code></pre>
<p><strong>EDIT:</strong> changed to use sorted(d) instead of sorted(d.keys()), thanks <a href="http://stackoverflow.com/users/1694/eli-courtwrig... | 16 | 2008-09-10T20:10:05Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 55,194 | <p>Or shorter,</p>
<pre><code>for key, value in sorted(d.items()):
print value
</code></pre>
| 16 | 2008-09-10T20:10:51Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 55,197 | <pre><code>>>> d = {'b' : 'this is b', 'a': 'this is a' , 'c' : 'this is c'}
>>> for k,v in sorted(d.items()):
... print v, k
...
this is a a
this is b b
this is c c
</code></pre>
| 1 | 2008-09-10T20:11:55Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 55,202 | <pre><code>d = {'b' : 'this is b', 'a': 'this is a' , 'c' : 'this is c'}
ks = d.keys()
ks.sort()
for k in ks:
print "this is " + k
</code></pre>
| 0 | 2008-09-10T20:12:48Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 56,134 | <pre><code>for key in sorted(d):
print d[key]
</code></pre>
| 1 | 2008-09-11T09:34:47Z | [
"python",
"sorting",
"dictionary",
"list"
] |
In Python, how can you easily retrieve sorted items from a dictionary? | 55,180 | <p>Dictionaries unlike lists are not ordered (and do not have the 'sort' attribute). Therefore, you can not rely on getting the items in the same order when first added. </p>
<p>What is the easiest way to loop through a dictionary containing strings as the key value and retrieving them in ascending order by key?</p>
... | 11 | 2008-09-10T20:05:25Z | 59,235 | <p>You can also sort a dictionary by value and control the sort order:</p>
<pre><code>import operator
d = {'b' : 'this is 3', 'a': 'this is 2' , 'c' : 'this is 1'}
for key, value in sorted(d.iteritems(), key=operator.itemgetter(1), reverse=True):
print key, " ", value
</code></pre>
<p>Output:<br />
b this is ... | 1 | 2008-09-12T15:11:00Z | [
"python",
"sorting",
"dictionary",
"list"
] |
How can I get Emacs' key bindings in Python's IDLE? | 55,365 | <p>I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?</p>
| 4 | 2008-09-10T21:32:47Z | 55,493 | <p>There's a program for Windows called XKeymacs that allows you to specify emacs keybindings for different programs. It should work with IDLE.</p>
<p><a href="http://www.cam.hi-ho.ne.jp/oishi/indexen.html" rel="nofollow">http://www.cam.hi-ho.ne.jp/oishi/indexen.html</a></p>
<p>-Mark</p>
| 2 | 2008-09-10T23:33:46Z | [
"python",
"emacs",
"ide",
"keyboard"
] |
How can I get Emacs' key bindings in Python's IDLE? | 55,365 | <p>I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?</p>
| 4 | 2008-09-10T21:32:47Z | 56,008 | <p>IDLE provides Emacs keybindings without having to install other software. </p>
<ol>
<li>Open up the menu item Options -> Configure IDLE...</li>
<li>Go to Keys tab</li>
<li>In the drop down menu on the right
side of the dialog change the select
to "IDLE Classic Unix"</li>
</ol>
<p>It's not the true emacs key bindin... | 6 | 2008-09-11T08:18:07Z | [
"python",
"emacs",
"ide",
"keyboard"
] |
How can I get Emacs' key bindings in Python's IDLE? | 55,365 | <p>I use Emacs primarily for coding Python but sometimes I use IDLE. Is there a way to change the key bindings easily in IDLE to match Emacs?</p>
| 4 | 2008-09-10T21:32:47Z | 85,113 | <p><a href="http://www.python.org/doc/2.5/lib/module-readline.html" rel="nofollow">'readline' module</a> supposedly provides Emacs like key bindings and even functionality. However, it is not available on Windows but on Unix. Therefore, this might be a viable solution if you are not using Windows.</p>
<pre><code>impor... | 0 | 2008-09-17T16:36:39Z | [
"python",
"emacs",
"ide",
"keyboard"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 55,399 | <pre><code>/<input type="hidden" name="fooId" value="([\d-]+)" \/>/
</code></pre>
| 0 | 2008-09-10T21:56:05Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 55,401 | <p>Parsing is one of those areas where you really don't want to roll your own if you can avoid it, as you'll be chasing down the edge-cases and bugs for years go come</p>
<p>I'd recommend using <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>. It has a very good reputation and l... | 5 | 2008-09-10T21:57:00Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 55,404 | <pre><code>import re
reg = re.compile('<input type="hidden" name="([^"]*)" value="<id>" />')
value = reg.search(inputHTML).group(1)
print 'Value is', value
</code></pre>
| 8 | 2008-09-10T21:59:47Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 55,424 | <p>For this particular case, BeautifulSoup is harder to write than a regex, but it is much more robust... I'm just contributing with the BeautifulSoup example, given that you already know which regexp to use :-)</p>
<pre><code>from BeautifulSoup import BeautifulSoup
#Or retrieve it from the web, etc.
html_data = ope... | 27 | 2008-09-10T22:16:24Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 56,144 | <pre><code>/<input\s+type="hidden"\s+name="([A-Za-z0-9_]+)"\s+value="([A-Za-z0-9_\-]*)"\s*/>/
>>> import re
>>> s = '<input type="hidden" name="fooId" value="12-3456789-1111111111" />'
>>> re.match('<input\s+type="hidden"\s+name="([A-Za-z0-9_]+)"\s+value="([A-Za-z0-9_\-]*)"\s*... | 0 | 2008-09-11T09:41:15Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 64,983 | <p>I agree with Vinko <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a> is the way to go. However I suggest using <code>fooId['value']</code> to <a href="http://www.crummy.com/software/BeautifulSoup/documentation.html#The%20attributes%20of%20Tags">get the attribute</a> rather than relying on val... | 18 | 2008-09-15T17:35:44Z | [
"python",
"regex",
"screen-scraping"
] |
Python regular expression for HTML parsing (BeautifulSoup) | 55,391 | <p>I want to grab the value of a hidden input field in HTML.</p>
<pre><code><input type="hidden" name="fooId" value="12-3456789-1111111111" />
</code></pre>
<p>I want to write a regular expression in Python that will return the value of fooId, given that I know the line in the HTML follows the format</p>
<pre>... | 9 | 2008-09-10T21:49:53Z | 1,421,480 | <p>Pyparsing is a good interim step between BeautifulSoup and regex. It is more robust than just regexes, since its HTML tag parsing comprehends variations in case, whitespace, attribute presence/absence/order, but simpler to do this kind of basic tag extraction than using BS.</p>
<p>Your example is especially simple... | 1 | 2009-09-14T13:14:10Z | [
"python",
"regex",
"screen-scraping"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 56,262 | <p>don't you actually want something like:</p>
<pre><code>html(head(script(type='text/javascript', content='var a = ...')),
body(h1('And I like the fact that 3 < 1'), p('just some paragraph'))
</code></pre>
<p>I think I saw something like that somewhere. This would be wonderful.</p>
<p><strong>EDIT:</strong> Actu... | 4 | 2008-09-11T10:55:44Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 56,269 | <p>Another way is using the <a href="http://codespeak.net/lxml/tutorial.html#the-e-factory" rel="nofollow">E Factory</a> builder from lxml (available in <a href="http://effbot.org/zone/element-builder.htm" rel="nofollow">Elementtree</a> too)</p>
<pre><code>>>> from lxml import etree
>>> from lxml.bu... | 28 | 2008-09-11T11:04:15Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 56,470 | <p>I assume that you're actually creating an XML DOM tree, because you want to validate that what goes into this file is valid XML, since otherwise you'd just write a static string to a file. If validating your output is indeed your goal, then I'd suggest</p>
<pre><code>from xml.dom.minidom import parseString
doc = ... | 10 | 2008-09-11T12:53:06Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 58,460 | <p>Try <a href="http://uche.ogbuji.net/tech/4suite/amara" rel="nofollow">http://uche.ogbuji.net/tech/4suite/amara</a>. It is quite complete and has a straight forward set of access tools. Normal Unicode support, etc. </p>
<pre><code>#
#Output the XML entry
#
def genFileOLD(out,label,term,idval):
filename=entryTime... | 0 | 2008-09-12T07:48:15Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 62,157 | <p>I ended up using saxutils.escape(str) to generate valid XML strings and then validating it with Eli's approach to be sure I didn't miss any tag</p>
<pre><code>from xml.sax import saxutils
from xml.dom.minidom import parseString
from xml.parsers.expat import ExpatError
xml = '''<?xml version="1.0" encoding="%s"?... | 3 | 2008-09-15T11:00:37Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 3,098,902 | <p>There's always <a href="http://effbot.org/zone/xml-writer.htm">SimpleXMLWriter</a>, part of the ElementTree toolkit. The interface is dead simple.</p>
<p>Here's an example: </p>
<pre><code>from elementtree.SimpleXMLWriter import XMLWriter
import sys
w = XMLWriter(sys.stdout)
html = w.start("html")
w.start("head"... | 24 | 2010-06-23T04:16:17Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 7,060,046 | <p><a href="https://github.com/galvez/xmlwitch">https://github.com/galvez/xmlwitch</a>:</p>
<pre><code>import xmlwitch
xml = xmlwitch.Builder(version='1.0', encoding='utf-8')
with xml.feed(xmlns='http://www.w3.org/2005/Atom'):
xml.title('Example Feed')
xml.updated('2003-12-13T18:30:02Z')
with xml.author:
... | 7 | 2011-08-14T22:09:27Z | [
"python",
"xml",
"xhtml"
] |
XML writing tools for Python | 56,229 | <p>I'm currently trying ElementTree and it looks fine, it escapes HTML entities and so on and so forth. Am I missing something truly wonderful I haven't heard of?</p>
<p>This is similar to what I'm actually doing:</p>
<pre><code>import xml.etree.ElementTree as ET
root = ET.Element('html')
head = ET.SubElement(root,'h... | 34 | 2008-09-11T10:35:37Z | 19,728,898 | <p>For anyone encountering this now, there's actually a way to do this hidden away in Python's standard library in <a href="http://docs.python.org/2.7/library/xml.sax.utils.html" rel="nofollow">xml.sax.utils.XMLGenerator</a>. Here's an example of it in action:</p>
<pre><code>>>> from xml.sax.saxutils import X... | 2 | 2013-11-01T14:36:08Z | [
"python",
"xml",
"xhtml"
] |
Anyone used Dabo for a medium-big project? | 56,417 | <p>We're at the beginning of a new ERP-ish client-server application, developed as a Python rich client. We're currently evaluating Dabo as our main framework and it looks quite nice and easy to use, but I was wondering, has anyone used it for medium-to-big sized projects?<br />
Thanks for your time!</p>
| 18 | 2008-09-11T12:29:09Z | 103,212 | <p>I have no Dabo experience at all but this question is on the top of the list fo such a long time that I decided to give it a shot:</p>
<h2>Framework selection</h2>
<h2>Assumptions:</h2>
<ol>
<li>medium-to-big project: we're talking about a team of more than 20 people working on something for about a year for the ... | 1 | 2008-09-19T15:56:41Z | [
"python",
"erp",
"dabo"
] |
Anyone used Dabo for a medium-big project? | 56,417 | <p>We're at the beginning of a new ERP-ish client-server application, developed as a Python rich client. We're currently evaluating Dabo as our main framework and it looks quite nice and easy to use, but I was wondering, has anyone used it for medium-to-big sized projects?<br />
Thanks for your time!</p>
| 18 | 2008-09-11T12:29:09Z | 106,464 | <p>I'm one of the authors of the Dabo framework. One of our users pointed out to me the extremely negative answer you received, and so I thought I had better chime in and clear up some of the incorrect assumptions in the first reply.</p>
<p>Dabo is indeed well-known in the Python community. I have presented it at 3 of... | 24 | 2008-09-19T23:55:08Z | [
"python",
"erp",
"dabo"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,832 | <p>What about:</p>
<pre><code>round(n,1)+epsilon
</code></pre>
| -4 | 2008-09-11T15:11:04Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,833 | <p>can't help the way it's stored, but at least formatting works correctly: </p>
<pre><code>'%.1f' % round(n, 1) # gives you '5.6'
</code></pre>
| 66 | 2008-09-11T15:11:41Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,840 | <p>You can switch the data type to a integer:</p>
<pre><code>>>> n = 5.59
>>> int(n * 10) / 10.0
5.5
>>> int(n * 10 + 0.5)
56
</code></pre>
<p>And then display the number by inserting the locale's decimal separator.</p>
<p>However, <a href="http://stackoverflow.com/questions/56820/round-i... | 5 | 2008-09-11T15:12:19Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,841 | <p>You can use the string format operator <code>%</code>, similar to sprintf.</p>
<pre><code>mystring = "%.2f" % 5.5999
</code></pre>
| 3 | 2008-09-11T15:12:25Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,844 | <p>You get '5.6' if you do <code>str(round(n, 1))</code> instead of just <code>round(n, 1)</code>.</p>
| 9 | 2008-09-11T15:13:28Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,845 | <p>Floating point math is vulnerable to slight, but annoying, precision inaccuracies. If you can work with integer or fixed point, you will be guaranteed precision.</p>
| 5 | 2008-09-11T15:13:32Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,849 | <p><strong>printf</strong> the sucker.</p>
<pre><code>print '%.1f' % 5.59 # returns 5.6
</code></pre>
| 3 | 2008-09-11T15:14:15Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 56,850 | <p>Formatting works correctly even without having to round:</p>
<pre><code>"%.1f" % n
</code></pre>
| 81 | 2008-09-11T15:14:22Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 57,704 | <p><code>round(5.59, 1)</code> is working fine. The problem is that 5.6 cannot be represented exactly in binary floating point.</p>
<pre><code>>>> 5.6
5.5999999999999996
>>>
</code></pre>
<p>As Vinko says, you can use string formatting to do rounding for display.</p>
<p>Python has a <a href="http:/... | 15 | 2008-09-11T21:27:35Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 3,225,829 | <p>Take a look at the <a href="http://docs.python.org/library/decimal.html" rel="nofollow">Decimal module</a></p>
<blockquote>
<p>Decimal âis based on a floating-point
model which was designed with people
in mind, and necessarily has a
paramount guiding principle â
computers must provide an arithmetic
... | 3 | 2010-07-12T04:12:38Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 15,398,691 | <p>If you use the Decimal module you can approximate without the use of the 'round' function. Here is what I've been using for rounding especially when writing monetary applications: </p>
<pre><code>Decimal(str(16.2)).quantize(Decimal('.01'), rounding=ROUND_UP)
</code></pre>
<p>This will return a Decimal Number whic... | 11 | 2013-03-13T23:48:33Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 17,296,776 | <p>It's a big problem indeed. Try out this code:</p>
<pre><code>print "%.2f" % (round((2*4.4+3*5.6+3*4.4)/8,2),)
</code></pre>
<p>It displays 4.85. Then you do: </p>
<pre><code>print "Media = %.1f" % (round((2*4.4+3*5.6+3*4.4)/8,1),)
</code></pre>
<p>and it shows 4.8. Do you calculations by hand the exact answer is... | 2 | 2013-06-25T12:00:58Z | [
"python",
"floating-point"
] |
round() in Python doesn't seem to be rounding properly | 56,820 | <p>The documentation for the <a href="http://docs.python.org/lib/built-in-funcs.html">round()</a> function states that you pass it a number, and the positions past the decimal to round. Thus it <em>should</em> do this:</p>
<pre><code>n = 5.59
round(n, 1) # 5.6
</code></pre>
<p>But, in actuality, good old floating poi... | 71 | 2008-09-11T15:08:09Z | 33,771,679 | <p>Works Perfect </p>
<pre><code>format(5.59, '.1f') # to display
float(format(5.59, '.1f')) #to round
</code></pre>
| 1 | 2015-11-18T04:10:22Z | [
"python",
"floating-point"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 57,745 | <p>You could find an answer here -- <a href="http://stackoverflow.com/questions/53224/getting-international-characters-from-a-web-page#53246">Getting international characters from a web page?</a></p>
<p><strong>EDIT</strong>: It seems like <code>BeautifulSoup</code> doesn't convert entities written in hexadecimal form... | 7 | 2008-09-11T21:52:28Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 57,877 | <p>Use the builtin <code>unichr</code> -- BeautifulSoup isn't necessary:</p>
<pre><code>>>> entity = '&#x01ce'
>>> unichr(int(entity[3:],16))
u'\u01ce'
</code></pre>
| 18 | 2008-09-11T23:09:08Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 58,125 | <p>Python has the <a href="https://docs.python.org/2/library/htmllib.html#module-htmlentitydefs">htmlentitydefs</a> module, but this doesn't include a function to unescape HTML entities.</p>
<p>Python developer Fredrik Lundh (author of elementtree, among other things) has such a function <a href="http://effbot.org/zo... | 55 | 2008-09-12T01:40:41Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 573,629 | <p>This is a function which should help you to get it right and convert entities back to utf-8 characters.</p>
<pre><code>def unescape(text):
"""Removes HTML or XML character references
and entities from a text string.
@param text The HTML (or XML) source text.
@return The plain text, as a Unicode stri... | 6 | 2009-02-21T19:45:58Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 4,438,857 | <p>Not sure why the Stack Overflow thread does not include the ';' in the search/replace (i.e. lambda m: '&#%d*<em>;</em>*') If you don't, BeautifulSoup can barf because the adjacent character can be interpreted as part of the HTML code (i.e. &#39B for &#39Blackout). ... | 3 | 2010-12-14T11:52:26Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 9,216,990 | <p>An alternative, if you have lxml:</p>
<pre><code>>>> import lxml.html
>>> lxml.html.fromstring('&#x01ce').text
u'\u01ce'
</code></pre>
| 14 | 2012-02-09T18:55:48Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 12,614,706 | <p>The standard libâs very own HTMLParser has an undocumented function unescape() which does exactly what you think it does:</p>
<pre><code>import HTMLParser
h = HTMLParser.HTMLParser()
h.unescape('&copy; 2010') # u'\xa9 2010'
h.unescape('&#169; 2010') # u'\xa9 2010'
</code></pre>
| 45 | 2012-09-27T05:34:44Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 27,424,874 | <p>If you are on Python 3.4 you can just do:</p>
<pre><code>s = html.unescape(s)
</code></pre>
<p><a href="https://docs.python.org/3.4/library/html.html#html.unescape">https://docs.python.org/3.4/library/html.html#html.unescape</a></p>
| 5 | 2014-12-11T14:12:00Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 33,486,253 | <p>Another solution is the builtin library xml.sax.saxutils (both for html and xml). However, it will convert only &gt, &amp and &lt.</p>
<pre><code>from xml.sax.saxutils import unescape
escaped_text = unescape(text_to_escape)
</code></pre>
| 1 | 2015-11-02T20:28:35Z | [
"python",
"html",
"entities"
] |
Convert XML/HTML Entities into Unicode String in Python | 57,708 | <p>I'm doing some web scraping and sites frequently use HTML entities to represent non ascii characters. Does Python have a utility that takes a string with HTML entities and returns a unicode type?</p>
<p>For example:</p>
<p>I get back:</p>
<pre><code>&#x01ce;
</code></pre>
<p>which represents an "Ç" with a t... | 60 | 2008-09-11T21:28:46Z | 34,463,462 | <p>Here is the Python 3 version of <a href="http://stackoverflow.com/a/58125/2086547">dF's answer</a>:</p>
<pre><code>import re
import html.entities
def unescape(text):
"""
Removes HTML or XML character references and entities from a text string.
:param text: The HTML (or XML) source text.
:return... | 0 | 2015-12-25T13:55:16Z | [
"python",
"html",
"entities"
] |
Does re.compile() or any given Python library call throw an exception? | 58,119 | <p>I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s... | 11 | 2008-09-12T01:35:33Z | 58,129 | <p>Well, <code>re.compile</code> certainly may:</p>
<pre><code>>>> import re
>>> re.compile('he(lo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python25\lib\re.py", line 180, in compile
return _compile(pattern, flags)
File "C:\Python25\lib\re... | 9 | 2008-09-12T01:42:38Z | [
"python",
"regex",
"exception"
] |
Does re.compile() or any given Python library call throw an exception? | 58,119 | <p>I can't tell from the Python documentation whether the re.compile(x) function may throw an exception (assuming you pass in a string). I imagine there is something that could be considered an invalid regular expression. The larger question is, where do I go to find if a given Python library call may throw exception(s... | 11 | 2008-09-12T01:35:33Z | 58,168 | <p>Unlike Java, where there are exceptions that must be declared to be raised (and some that don't have to be, but that's another story), any Python code may raise any exception at any time.</p>
<p>There are a list of <a href="http://docs.python.org/lib/module-exceptions.html">built-in exceptions</a>, which generally ... | 6 | 2008-09-12T02:10:16Z | [
"python",
"regex",
"exception"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 58,296 | <p>This isn't possible without cooperation from an external server, because there could be any number of NATs between you and the other computer. If it's a custom protocol, you could ask the other system to report what address it's connected to.</p>
| 7 | 2008-09-12T04:23:53Z | [
"python",
"sockets"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 58,299 | <p>The only way I can think of that's guaranteed to give it to you is to hit a service like <a href="http://whatismyip.com/" rel="nofollow">http://whatismyip.com/</a> to get it.</p>
| 4 | 2008-09-12T04:24:34Z | [
"python",
"sockets"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 256,358 | <p>import socket</p>
<p>s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)</p>
<p>s.connect(("msn.com",80))</p>
<p>s.getsockname()</p>
| 1 | 2008-11-02T01:17:04Z | [
"python",
"sockets"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 2,646,313 | <p>Using the address suggested in the source of <a href="http://whatismyip.com" rel="nofollow">http://whatismyip.com</a></p>
<pre><code>import urllib
def get_my_ip_address():
whatismyip = 'http://www.whatismyip.com/automation/n09230945.asp'
return urllib.urlopen(whatismyip).readlines()[0]
</code></pre>
| 0 | 2010-04-15T14:46:48Z | [
"python",
"sockets"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 8,305,740 | <p><a href="https://github.com/bobeirasa/mini-scripts/blob/master/externalip.py" rel="nofollow">https://github.com/bobeirasa/mini-scripts/blob/master/externalip.py</a></p>
<pre><code>'''
Finds your external IP address
'''
import urllib
import re
def get_ip():
group = re.compile(u'(?P<ip>\d+\.\d+\.\d+\.\d+)... | 3 | 2011-11-29T04:11:24Z | [
"python",
"sockets"
] |
How do I get the external IP of a socket in Python? | 58,294 | <p>When I call <code>socket.getsockname()</code> on a socket object, it returns a tuple of my machine's internal IP and the port. However, I would like to retrieve my external IP. What's the cheapest, most efficient manner of doing this?</p>
| 8 | 2008-09-12T04:21:51Z | 8,848,856 | <pre><code>print (urllib.urlopen('http://automation.whatismyip.com/n09230945.asp').read())
</code></pre>
| 1 | 2012-01-13T10:10:36Z | [
"python",
"sockets"
] |
Can I document Python code with doxygen (and does it make sense)? | 58,622 | <p>I like doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments and also has its own self-documentation facility which seems to be the pythonic way to document.</p>
<p>Can I just use doxygen? Anything particular to be aware... | 49 | 2008-09-12T10:26:40Z | 58,701 | <p>This is <a href="http://www.stack.nl/~dimitri/doxygen/docblocks.html#pythonblocks">documented on the doxygen website</a>, but to summarize here:</p>
<p>You can use doxygen to document your Python code. You can either use the Python documentation string syntax:</p>
<pre><code>"""@package docstring
Documentation for... | 30 | 2008-09-12T11:11:03Z | [
"python",
"documentation",
"doxygen",
"docstring",
"python-sphinx"
] |
Can I document Python code with doxygen (and does it make sense)? | 58,622 | <p>I like doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments and also has its own self-documentation facility which seems to be the pythonic way to document.</p>
<p>Can I just use doxygen? Anything particular to be aware... | 49 | 2008-09-12T10:26:40Z | 59,018 | <p>An other very good documentation tool is <a href="http://sphinx.pocoo.org/">sphinx</a>. It will be used for the upcoming python 2.6 <a href="http://docs.python.org/dev/">documentation</a> and is used by <a href="http://docs.djangoproject.com/en/dev/">django</a> and a lot of other python projects.</p>
<p>From the sp... | 11 | 2008-09-12T13:48:59Z | [
"python",
"documentation",
"doxygen",
"docstring",
"python-sphinx"
] |
Can I document Python code with doxygen (and does it make sense)? | 58,622 | <p>I like doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments and also has its own self-documentation facility which seems to be the pythonic way to document.</p>
<p>Can I just use doxygen? Anything particular to be aware... | 49 | 2008-09-12T10:26:40Z | 59,955 | <p>Sphinx is mainly a tool for formatting docs written independently from the source code, as I understand it.</p>
<p>For generating API docs from Python docstrings, the leading tools are <a href="https://github.com/BurntSushi/pdoc" rel="nofollow">pdoc</a> and <a href="https://launchpad.net/pydoctor" rel="nofollow">py... | 18 | 2008-09-12T21:04:48Z | [
"python",
"documentation",
"doxygen",
"docstring",
"python-sphinx"
] |
Can I document Python code with doxygen (and does it make sense)? | 58,622 | <p>I like doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments and also has its own self-documentation facility which seems to be the pythonic way to document.</p>
<p>Can I just use doxygen? Anything particular to be aware... | 49 | 2008-09-12T10:26:40Z | 497,322 | <p>The <a href="https://pypi.python.org/pypi/doxypy/">doxypy</a> input filter allows you to use pretty much all of Doxygen's formatting tags in a standard Python docstring format. I use it to document a large mixed C++ and Python game application framework, and it's working well.</p>
| 48 | 2009-01-30T21:30:02Z | [
"python",
"documentation",
"doxygen",
"docstring",
"python-sphinx"
] |
Can I document Python code with doxygen (and does it make sense)? | 58,622 | <p>I like doxygen to create documentation of C or PHP code. I have an upcoming Python project and I think I remember that Python doesn't have /* .. */ comments and also has its own self-documentation facility which seems to be the pythonic way to document.</p>
<p>Can I just use doxygen? Anything particular to be aware... | 49 | 2008-09-12T10:26:40Z | 35,377,654 | <p>In the end, you only have two options:</p>
<p>You generate your content using Doxygen, or you generate your content using Sphinx*.</p>
<ol>
<li><p><strong>Doxygen</strong>: It is not the tool of choice for most Python projects. But if you have to deal with other related projects written in C or C++ it could make s... | 4 | 2016-02-13T08:16:17Z | [
"python",
"documentation",
"doxygen",
"docstring",
"python-sphinx"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 58,917 | <p>You could actually pull this off, but it would require using metaclasses, which are <em>deep</em> magic (there be dragons). If you want an intro to metaclasses, there's a series of <a href="http://www.ibm.com/developerworks/linux/library/l-pymeta.html" rel="nofollow">articles from IBM</a> which manage to introduce t... | 7 | 2008-09-12T13:13:57Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 58,990 | <p>Maybe not as slick as the Ruby version, but how about something like this:</p>
<pre><code>from Boots import App, Para, Button, alert
def Shoeless(App):
t = Para(text = 'Not Clicked')
b = Button(label = 'The label')
def on_b_clicked(self):
alert('You clicked the button!')
self.t.text = ... | 2 | 2008-09-12T13:40:35Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 60,563 | <p>This could be an oversimplification, i don't think it would be a good idea to try to make a general purpose ui library this way. On the other hand you could use this approach (metaclasses and friends) to simplify the definition of certain classes of user interfaces for an existing ui library and depending of the app... | 2 | 2008-09-13T14:20:42Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 62,780 | <p>With some Metaclass magic to keep the ordering I have the following working. I'm not sure how pythonic it is but it is good fun for creating simple things. </p>
<pre><code>class w(Wndw):
title='Hello World'
class txt(Txt): # either a new class
text='Insert name here'
lbl=Lbl(text='Hello') # or an instanc... | 3 | 2008-09-15T13:18:54Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 334,828 | <p>I have this same problem. I wan to to create a wrapper around any GUI toolkit for Python that is easy to use, and inspired by Shoes, but needs to be a OOP approach (against ruby blocks).</p>
<p>More information in: <a href="http://wiki.alcidesfonseca.com/blog/python-universal-gui-revisited" rel="nofollow">http://wi... | 1 | 2008-12-02T17:48:06Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 334,938 | <p>The only attempt to do this that I know of is <a href="http://zephyrfalcon.org/labs/dope_on_wax.html" rel="nofollow">Hans Nowak's Wax</a> (which is unfortunately dead).</p>
| 3 | 2008-12-02T18:23:10Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,077 | <p>The closest you can get to rubyish blocks is the with statement from pep343: </p>
<p><a href="http://www.python.org/dev/peps/pep-0343/" rel="nofollow">http://www.python.org/dev/peps/pep-0343/</a></p>
| 3 | 2008-12-02T19:09:45Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,132 | <p>I was never satisfied with David Mertz's articles at IBM on metaclsses so I recently wrote my own <a href="http://askawizard.blogspot.com/2008/09/metaclasses-python-saga-part-4_30.html" rel="nofollow">metaclass article</a>. Enjoy.</p>
| 4 | 2008-12-02T19:30:23Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,358 | <p>If you really want to code UI, you could try to get something similar to django's ORM; sth like this to get a simple help browser:</p>
<pre><code>class MyWindow(Window):
class VBox:
entry = Entry()
bigtext = TextView()
def on_entry_accepted(text):
bigtext.value = eval(text).... | 1 | 2008-12-02T20:37:49Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,400 | <p>Declarative is not necessarily more (or less) pythonic than functional IMHO. I think a layered approach would be the best (from buttom up):</p>
<ol>
<li>A native layer that accepts and returns python data types.</li>
<li>A functional dynamic layer.</li>
<li>One or more declarative/object-oriented layers.</li>
</ol>... | 1 | 2008-12-02T20:48:23Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,443 | <p>Personally, I would try to implement <a href="http://docs.jquery.com/Main_Page" rel="nofollow">JQuery</a> like API in a GUI framework.</p>
<pre><code>class MyWindow(Window):
contents = (
para('Hello World!'),
button('Click Me', id='ok'),
para('Epilog'),
)
def __init__(self):
... | 1 | 2008-12-02T21:03:49Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 335,887 | <p>This is extremely contrived and not pythonic at all, but here's my attempt at a semi-literal translation using the new "with" statement.</p>
<pre><code>with Shoes():
t = Para("Not clicked!")
with Button("The Label"):
Alert("You clicked the button!")
t.replace("Clicked!")
</code></pre>
<p>The hardest pa... | 4 | 2008-12-03T00:15:11Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 336,089 | <p>Here's an approach that goes about GUI definitions a bit differently using class-based meta-programming rather than inheritance.</p>
<p>This is largley Django/SQLAlchemy inspired in that it is heavily based on meta-programming and separates your GUI code from your "code code". I also think it should make heavy use... | 1 | 2008-12-03T02:37:06Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 336,525 | <pre><code>## All you need is this class:
class MainWindow(Window):
my_button = Button('Click Me')
my_paragraph = Text('This is the text you wish to place')
my_alert = AlertBox('What what what!!!')
@my_button.clicked
def my_button_clicked(self, button, event):
self.my_paragraph.text.append... | 5 | 2008-12-03T08:48:06Z | [
"python",
"user-interface",
"frameworks"
] |
How would you design a very "Pythonic" UI framework? | 58,711 | <p>I have been playing with the Ruby library "shoes". Basically you can write a GUI application in the following way:</p>
<pre><code>Shoes.app do
t = para "Not clicked!"
button "The Label" do
alert "You clicked the button!" # when clicked, make an alert
t.replace "Clicked!" # ..and replace the label's text... | 11 | 2008-09-12T11:18:04Z | 336,583 | <p>If you use <a href="http://www.pygtk.org/" rel="nofollow">PyGTK</a> with <a href="http://glade.gnome.org/" rel="nofollow">glade</a> and <a href="http://www.pixelbeat.org/libs/libglade.py" rel="nofollow">this glade wrapper</a>, then PyGTK actually becomes somewhat pythonic. A little at least.</p>
<p>Basically, you c... | 3 | 2008-12-03T09:18:40Z | [
"python",
"user-interface",
"frameworks"
] |
Storing multiple arrays in Python | 59,648 | <p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com</p>
<p>I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of... | 1 | 2008-09-12T18:09:02Z | 59,662 | <p>Are you talking about doing this?</p>
<pre><code>>>> a = [ ['a', 'b'], ['c', 'd'] ]
>>> a[1]
['c', 'd']
>>> a[1][1]
'd'
</code></pre>
| 2 | 2008-09-12T18:14:01Z | [
"python",
"arrays"
] |
Storing multiple arrays in Python | 59,648 | <p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com</p>
<p>I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of... | 1 | 2008-09-12T18:09:02Z | 59,663 | <p>Lists in python can contain any type of object -- If I understand the question correctly, will a <code>list</code> of <code>list</code>s do the job? Something like this (assuming you have a function <code>generate_poll_data()</code> which creates your data:</p>
<pre><code>data = []
for in xrange(num_iterations):
... | 1 | 2008-09-12T18:14:04Z | [
"python",
"arrays"
] |
Storing multiple arrays in Python | 59,648 | <p>I am writing a program to simulate the actual polling data companies like Gallup or Rasmussen publish daily: www.gallup.com and www.rassmussenreports.com</p>
<p>I'm using a brute force method, where the computer generates some random daily polling data and then calculates three day averages to see if the average of... | 1 | 2008-09-12T18:09:02Z | 59,709 | <p>since you are thinking in <em>variables</em>, you might prefer a dictionary over a list of lists:</p>
<pre><code>data = {}
data['a'] = [generate_poll_data()]
data['b'] = [generate_poll_data()]
</code></pre>
<p>etc.</p>
| 1 | 2008-09-12T18:31:04Z | [
"python",
"arrays"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.