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
Google Appengine and Python exceptions
2,151,472
<p>In my Google Appengine application I have defined a custom exception InvalidUrlException(Exception) in the module 'gvu'. Somewhere in my code I do:</p> <pre><code>try: results = gvu.article_parser.parse(source_url) except gvu.InvalidUrlException as e: self.redirect('/home?message='+str(e)) ... </code></pre>...
1
2010-01-28T00:34:50Z
24,442,402
<p>I was getting the same error because I was using the <code>pydoc</code> command instead of the <code>pydoc3</code> command on a python3 file that was using python3 print statements (print statements with parenthesis).</p>
2
2014-06-27T00:42:50Z
[ "python", "google-app-engine", "exception" ]
Problem with jQuery Ajax...how do I update two DIVs with ONE ajax call?
2,151,490
<pre><code>function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ $("#main").html(html); } }); }; </code></pre> <p>This is the entire code that will populate <strong>#main</strong>:</p> <pre><code>&lt;p&gt;{...
0
2010-01-28T00:39:07Z
2,151,539
<p>Use a regular expression</p> <pre><code>success:function(html){ $("#main").html(html); $("secondary").html( /.*?(?=,)/.exec(html) ); } </code></pre>
0
2010-01-28T00:51:23Z
[ "javascript", "jquery", "python", "ajax", "django" ]
Problem with jQuery Ajax...how do I update two DIVs with ONE ajax call?
2,151,490
<pre><code>function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ $("#main").html(html); } }); }; </code></pre> <p>This is the entire code that will populate <strong>#main</strong>:</p> <pre><code>&lt;p&gt;{...
0
2010-01-28T00:39:07Z
2,151,541
<pre><code>$('#secondary').html($('#main p').html().split(',')[0]); </code></pre>
0
2010-01-28T00:51:45Z
[ "javascript", "jquery", "python", "ajax", "django" ]
Problem with jQuery Ajax...how do I update two DIVs with ONE ajax call?
2,151,490
<pre><code>function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ $("#main").html(html); } }); }; </code></pre> <p>This is the entire code that will populate <strong>#main</strong>:</p> <pre><code>&lt;p&gt;{...
0
2010-01-28T00:39:07Z
2,151,544
<p>One option is to return json with the data you need for each area.</p> <pre><code>$.ajax({ method:"get", url:"/main/", dataType: "json", data:"q="+query, beforeSend:function() {}, success:function(json){ $("#main").html(json.main); $("#secondary").html(json.secondary); } ...
6
2010-01-28T00:52:09Z
[ "javascript", "jquery", "python", "ajax", "django" ]
Problem with jQuery Ajax...how do I update two DIVs with ONE ajax call?
2,151,490
<pre><code>function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ $("#main").html(html); } }); }; </code></pre> <p>This is the entire code that will populate <strong>#main</strong>:</p> <pre><code>&lt;p&gt;{...
0
2010-01-28T00:39:07Z
2,151,550
<p>You will need to return a XML or JSON object from the request which will the be used to fill in only the relevant parts. Try something like this: </p> <pre><code>function ajaxCall(query){ $.ajax({ method:"get", url:"/main/", data:"q="+query, beforeSend:function() {}, success:function(html){ ...
1
2010-01-28T00:53:28Z
[ "javascript", "jquery", "python", "ajax", "django" ]
Returning an instance of a class from a file in python
2,151,499
<p>In my program I have a package filled with various .py files each containing a class definition. I want to make a list where each entry is an instance of one of those classes. In addition, my program doesn't know how many files are in the package or what the files or classes are called, so I can't just import each...
1
2010-01-28T00:40:55Z
2,151,534
<p>This sounds like a bit of a bad design. It would probably be better if you elaborate on the problem and we can help you to solve it some other way. However, what you want isn't hard:</p> <pre><code>import types import my_package my_package_members = [getattr(my_package, i) for i in dir(my_package)] my_modules = [i...
2
2010-01-28T00:49:47Z
[ "python" ]
Returning an instance of a class from a file in python
2,151,499
<p>In my program I have a package filled with various .py files each containing a class definition. I want to make a list where each entry is an instance of one of those classes. In addition, my program doesn't know how many files are in the package or what the files or classes are called, so I can't just import each...
1
2010-01-28T00:40:55Z
2,151,594
<p>To acheive this you are going to need to do the following things:</p> <ul> <li>Have your code enumerate the source files containing your code.</li> <li>For each source file, import the code specified in the file into a new module.</li> <li>For each module, locate all the classes contained, instantiate each one and ...
0
2010-01-28T01:03:25Z
[ "python" ]
Returning an instance of a class from a file in python
2,151,499
<p>In my program I have a package filled with various .py files each containing a class definition. I want to make a list where each entry is an instance of one of those classes. In addition, my program doesn't know how many files are in the package or what the files or classes are called, so I can't just import each...
1
2010-01-28T00:40:55Z
2,151,858
<p>If you're willing to do a bit more work, you can use <a href="http://peak.telecommunity.com/DevCenter/PkgResources#entry-points" rel="nofollow"><code>pkg_resource</code>'s entry points</a> to advertise and discover the relevant classes. The Fedora Account System <a href="http://git.fedorahosted.org/git/?p=fas.git;a=...
0
2010-01-28T02:17:18Z
[ "python" ]
Returning an instance of a class from a file in python
2,151,499
<p>In my program I have a package filled with various .py files each containing a class definition. I want to make a list where each entry is an instance of one of those classes. In addition, my program doesn't know how many files are in the package or what the files or classes are called, so I can't just import each...
1
2010-01-28T00:40:55Z
2,152,187
<p>Assuming, first, that all your modules exist as <code>.py</code> files in the package's directory:</p> <pre><code>import inspect, glob, os, sys def thelistyouwant(pathtothepackage): sys.path.insert(0, pathtothepackage) result = [] for fn in glob.glob(os.path.join(pathtothepackage, '*.py')): if fn.startsw...
0
2010-01-28T03:52:42Z
[ "python" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
2,151,546
<pre><code>def getUniqueAttributeValues(xml_attribute_nodes): return set(l for item in xml_attribute_nodes for l in item.getContent().split()) </code></pre> <p>If you want to have a list, just convert the set to a list before returning.</p>
0
2010-01-28T00:52:46Z
[ "python", "xml", "list" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
2,151,551
<p>Unions are not supported by lists, which are ordered, but are supported by sets. Check out <a href="https://docs.python.org/3/library/stdtypes.html#set-types-set-frozenset" rel="nofollow">set.union</a>.</p>
3
2010-01-28T00:53:35Z
[ "python", "xml", "list" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
2,151,553
<p><a href="http://docs.python.org/library/stdtypes.html#set.union"><code>set.union</code></a> does what you want:</p> <pre><code>&gt;&gt;&gt; results_list = [[1,2,3], [1,2,4]] &gt;&gt;&gt; results_union = set().union(*results_list) &gt;&gt;&gt; print results_union set([1, 2, 3, 4]) </code></pre> <p>You can also do t...
44
2010-01-28T00:54:10Z
[ "python", "xml", "list" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
2,151,573
<p>I used the following to do intersections, which avoids the need for sets.</p> <pre><code>a, b= [[1,2,3], [1,2]] s = filter( lambda x: x in b, a) </code></pre> <p>or,</p> <pre><code>s = [ x for x in b if x in a ] </code></pre>
1
2010-01-28T00:58:16Z
[ "python", "xml", "list" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
2,152,138
<p>Since you seem to be using Python 2.5 (it <strong>would</strong> be nice to mention in your Q if you need an A for versions != 2.6, the current production one, by the way;-) and want a list rather than a set as the result, I recommend:</p> <pre><code> import itertools ... return list(set(itertools.chain(*...
8
2010-01-28T03:38:01Z
[ "python", "xml", "list" ]
Pythonic Way to Create Union of All Values Contained in Multiple Lists
2,151,517
<p>Doing some XML processing in python. (Edit: I'm forced to use Python 2.4 for this project, boo!) I want to know what is the most Pythonic way to do this (create union of all values in multiple lists):</p> <pre><code>def getUniqueAttributeValues(xml_attribute_nodes): # split attribute values by whitespace int...
23
2010-01-28T00:44:41Z
35,722,614
<p>You can also follow this style </p> <pre><code>In [12]: a = ['Orange and Banana', 'Orange Banana'] In [13]: b = ['Grapes', 'Orange Banana'] In [14]: c = ['Foobanana', 'Orange and Banana'] In [20]: list(set(a) | set(b) | set(c)) Out[20]: ['Orange and Banana', 'Foobanana', 'Orange Banana', 'Grapes'] In [21]: list(s...
0
2016-03-01T12:13:48Z
[ "python", "xml", "list" ]
Python's subprocess.Popen object hangs gathering child output when child process does not exit
2,151,640
<p>When a process exits abnormally or not at all, I still want to be able to gather what output it may have generated up until that point.</p> <p>The obvious solution to this example code is to kill the child process with an os.kill, but in my real code, the child is hung waiting for NFS and does not respond to a SIGK...
2
2010-01-28T01:14:49Z
2,151,694
<p>Problem is that bash doesn't answer to CTRL-C when not connected with a terminal. Switching to SIGHUP or SIGTERM seems to do the trick:</p> <pre><code>cmd = ["bash", 'childProc.sh'] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, clos...
1
2010-01-28T01:33:02Z
[ "python", "subprocess", "hang" ]
Python's subprocess.Popen object hangs gathering child output when child process does not exit
2,151,640
<p>When a process exits abnormally or not at all, I still want to be able to gather what output it may have generated up until that point.</p> <p>The obvious solution to this example code is to kill the child process with an os.kill, but in my real code, the child is hung waiting for NFS and does not respond to a SIGK...
2
2010-01-28T01:14:49Z
2,151,987
<p>There are good tips in another stackoverflow question: <a href="http://stackoverflow.com/questions/874815/how-do-i-get-real-time-information-back-from-a-subprocess-popen-in-python-2-5">How do I get &#39;real-time&#39; information back from a subprocess.Popen in python (2.5)</a></p> <p>Most of the hints in there wor...
0
2010-01-28T02:58:11Z
[ "python", "subprocess", "hang" ]
Python's subprocess.Popen object hangs gathering child output when child process does not exit
2,151,640
<p>When a process exits abnormally or not at all, I still want to be able to gather what output it may have generated up until that point.</p> <p>The obvious solution to this example code is to kill the child process with an os.kill, but in my real code, the child is hung waiting for NFS and does not respond to a SIGK...
2
2010-01-28T01:14:49Z
2,246,870
<p>Here's a POSIX way of doing it without the temporary file. I realize that subprocess is a little superfluous here, but since the original question used it...</p> <pre><code>import subprocess import os import time import signal import sys pr, pw = os.pipe() pid = os.fork () if pid: #parent os.close(pw) c...
1
2010-02-11T18:51:43Z
[ "python", "subprocess", "hang" ]
Python's subprocess.Popen object hangs gathering child output when child process does not exit
2,151,640
<p>When a process exits abnormally or not at all, I still want to be able to gather what output it may have generated up until that point.</p> <p>The obvious solution to this example code is to kill the child process with an os.kill, but in my real code, the child is hung waiting for NFS and does not respond to a SIGK...
2
2010-01-28T01:14:49Z
2,794,774
<p>I had the exact same problem. I ended up fixing the issue (after scouring Google and finding many related problems) by simply setting the following parameters when calling <code>subprocess.Popen</code> (or <code>.call</code>):</p> <pre><code>stdout=None </code></pre> <p>and</p> <pre><code>stderr=None </code></pr...
0
2010-05-08T16:26:27Z
[ "python", "subprocess", "hang" ]
How can I make Sphinx's inheritance_diagram readable?
2,151,711
<p>Similar to <a href="http://groups.google.com/group/sphinx-dev/browse_thread/thread/6bdbc72cb82dab9/e81592216cd30fc4?lnk=gst&amp;q=attributes#e81592216cd30fc4" rel="nofollow">this chap's post</a>, I'm seeing Sphinx generate unreadable graphviz output:</p> <a href="http://picasaweb.google.com/lh/photo/90xhSPuxMy-S5-w...
5
2010-01-28T01:36:01Z
2,151,808
<p>I figured out the answer from <a href="http://groups.google.com/group/sphinx-dev/browse_thread/thread/bc0f04997d8a3ac6/e7335502302927e6?show_docid=e7335502302927e6">this thread</a>. In the <code>graphviz.py</code> code, they have a default value for the size of the graph at 8.0x12.0. If you want to allow Graphviz ...
6
2010-01-28T02:01:58Z
[ "python", "graphviz", "python-sphinx" ]
Google App Engine Patch - How to use stylesheets?
2,151,776
<p>Struggling with an install of GAE-Patch and using my stylesheets. My settings.py has the following lines included already, but the media generator is not compiling and packaging it properly:</p> <pre><code> 'combined-%(LANGUAGE_DIR)s.css': ( 'global/look.css', ), 'combined-%(LANGUAGE_DIR)s.css': ...
2
2010-01-28T01:52:19Z
2,157,129
<p>You should look at the app.yaml file:</p> <p>It should look like this:</p> <pre><code>handlers: - url: /media static_dir: _generated_media </code></pre> <p>This means that you need to put your css, etc in the _generated_media folder.</p>
2
2010-01-28T19:01:55Z
[ "python", "django", "google-app-engine" ]
Conditionally Require Only One Field In Django Model Form
2,151,966
<p>Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out?</p> <pre><code>If field1 has no data, but field2 does form is valid. </code></pre> <hr> <pre><code>If field1 has no data and field2 has no data form is invalid </code></pre> <p>Not lo...
7
2010-01-28T02:52:50Z
2,151,974
<p>Override .clean(self) method, check for self.cleaned_data and raise ValidationError</p> <p><a href="https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other" rel="nofollow">https://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-and-validating...
7
2010-01-28T02:54:32Z
[ "python", "django", "forms", "validation", "model" ]
Conditionally Require Only One Field In Django Model Form
2,151,966
<p>Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out?</p> <pre><code>If field1 has no data, but field2 does form is valid. </code></pre> <hr> <pre><code>If field1 has no data and field2 has no data form is invalid </code></pre> <p>Not lo...
7
2010-01-28T02:52:50Z
23,434,418
<p>You can also do this using the model if you know the validation will apply to all objects of this class. To use the below at the form level, use cleaned_data. Here is a sample right from django doc using ValidationError:</p> <pre><code>class Article(models.Model): status = models.CharField(max_length=75, blank...
1
2014-05-02T18:11:54Z
[ "python", "django", "forms", "validation", "model" ]
Conditionally Require Only One Field In Django Model Form
2,151,966
<p>Anyway to make a field conditionally required based on whether or not another field in the same form has been filled out?</p> <pre><code>If field1 has no data, but field2 does form is valid. </code></pre> <hr> <pre><code>If field1 has no data and field2 has no data form is invalid </code></pre> <p>Not lo...
7
2010-01-28T02:52:50Z
36,327,449
<p>The best solution for conditionally required field is to override clean method of the form and pop up the error on condition. For example:</p> <pre><code>clean(self): if self.cleaned_data.get(some_field) == 1: self.errors.pop(other_field, None) </code></pre>
0
2016-03-31T08:00:12Z
[ "python", "django", "forms", "validation", "model" ]
Can I get my instance of mechanize.Browser to stay on the same page after calling b.form.submit()?
2,152,098
<p>In Python's mechanize.Browser module, when you submit a form the browser instance goes to that page. For this one request, I don't want that; I want it just to stay on the page it's currently on and give me the response in another object (for looping purposes). Anyone know a quick to do this?</p> <p>EDIT: Hmm, so I...
3
2010-01-28T03:24:46Z
2,167,177
<p>The answer to my immediate question in the headline is yes, with <code>mechanize.Browser.open_novisit()</code>. It works just like <code>open()</code>, but it doesn't change the state of the Browser instance -- that is, it will retrieve the page, and your Browser object will stay where it was.</p>
7
2010-01-30T07:21:49Z
[ "python", "screen-scraping", "mechanize" ]
Blogger (Python) API: How do I retrieve a post by post ID?
2,152,112
<p>Having previously obtained a post ID from a call to <code>gdata.blogger.client.add_post()</code>...</p> <pre><code>post = client.add_post(...) post_id = post.get_post_id() </code></pre> <p>...how do I use that post id to retrieve the post in the future? I thought maybe <code>gdata.blogger.client.Query</code> woul...
2
2010-01-28T03:29:24Z
2,160,077
<p>Continue my theme of answering my own questions...</p> <p>After lots of fiddling, it looks like this is one solution. Given:</p> <ul> <li>client -- a gdata.blogger.client.BloggerClient instance, and</li> <li>blog -- a gdata.blogger.data.Blog instance</li> <li>post_id -- a post id as returned by gdata.blogger.data....
1
2010-01-29T05:30:29Z
[ "python", "blogger", "gdata" ]
Blogger (Python) API: How do I retrieve a post by post ID?
2,152,112
<p>Having previously obtained a post ID from a call to <code>gdata.blogger.client.add_post()</code>...</p> <pre><code>post = client.add_post(...) post_id = post.get_post_id() </code></pre> <p>...how do I use that post id to retrieve the post in the future? I thought maybe <code>gdata.blogger.client.Query</code> woul...
2
2010-01-28T03:29:24Z
2,459,228
<p>Are you able to get the list of blogs that the user is following (not the ones the user owns/authors)?</p>
0
2010-03-17T00:47:43Z
[ "python", "blogger", "gdata" ]
How can I declare a 5x5 grid of numbers in Python?
2,152,296
<p>How would I declare this? I'm thinking something along the lines of:</p> <pre><code>boardPieces = ["A","O","A" "A", "A", "O" ] </code></pre>
1
2010-01-28T04:27:13Z
2,152,309
<pre><code>[[0] * 5 for x in range(5)] </code></pre> <p>or</p> <pre><code>[[0 for x in range(5)] for y in range(5)] </code></pre> <p>The first will only work with immutable types, while the second will work with any type.</p>
2
2010-01-28T04:30:00Z
[ "python" ]
How can I declare a 5x5 grid of numbers in Python?
2,152,296
<p>How would I declare this? I'm thinking something along the lines of:</p> <pre><code>boardPieces = ["A","O","A" "A", "A", "O" ] </code></pre>
1
2010-01-28T04:27:13Z
2,152,311
<p>I'm assuming a 2d matrix? Something like this should work.</p> <pre><code>boardPieces = [["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"],["A","O","A","A", "A"]] </code></pre>
5
2010-01-28T04:30:05Z
[ "python" ]
How can I declare a 5x5 grid of numbers in Python?
2,152,296
<p>How would I declare this? I'm thinking something along the lines of:</p> <pre><code>boardPieces = ["A","O","A" "A", "A", "O" ] </code></pre>
1
2010-01-28T04:27:13Z
2,152,318
<p>Just do like this.</p> <pre><code>[["A","O","A","O","A"],[...],[...],[...],[...]] </code></pre>
0
2010-01-28T04:30:59Z
[ "python" ]
How can I declare a 5x5 grid of numbers in Python?
2,152,296
<p>How would I declare this? I'm thinking something along the lines of:</p> <pre><code>boardPieces = ["A","O","A" "A", "A", "O" ] </code></pre>
1
2010-01-28T04:27:13Z
2,152,657
<p>In addition to the answers given - if you need to do work with 2D (or higher dimension) arrays in Python, a very good library for this purpose is Numpy - <a href="http://numpy.scipy.org/" rel="nofollow">http://numpy.scipy.org/</a>.</p> <p>Among others, it lets you easily "reshape" an array in whatever logical form ...
3
2010-01-28T06:15:10Z
[ "python" ]
Python: Obtain edge end points of the graph
2,152,325
<p>I need the edge end points from a graph. I have installed networkx. I have some idea how to proceed.</p> <p>networkx.Graph.edges_iter() returns all the edges in the graph</p> <pre><code>[e for e in G.edges_iter()] [(0, 1), (1, 2), (2, 3)] </code></pre> <p>What I want is a list [0,1,1,2,2,3]</p> <p>How do I get t...
2
2010-01-28T04:35:57Z
2,152,340
<pre><code>&gt;&gt;&gt; import itertools &gt;&gt;&gt; list(itertools.chain(*[(0, 1), (1, 2), (2, 3)])) [0, 1, 1, 2, 2, 3] </code></pre> <p>You may not need <code>list(...)</code> because its already iterable.</p> <p>And you may also try <code>itertools.chain(G.edges_iter())</code> directly</p>
2
2010-01-28T04:43:12Z
[ "python" ]
Python: Obtain edge end points of the graph
2,152,325
<p>I need the edge end points from a graph. I have installed networkx. I have some idea how to proceed.</p> <p>networkx.Graph.edges_iter() returns all the edges in the graph</p> <pre><code>[e for e in G.edges_iter()] [(0, 1), (1, 2), (2, 3)] </code></pre> <p>What I want is a list [0,1,1,2,2,3]</p> <p>How do I get t...
2
2010-01-28T04:35:57Z
2,152,393
<pre><code>edgeList = [] for (a,b) in G.edges_iter(): edgeList.append(a) edgeList.append(b) </code></pre>
1
2010-01-28T04:58:05Z
[ "python" ]
Python: Convert a list into a normal value
2,152,401
<p>I have a list</p> <pre><code>a = [3] print a [3] </code></pre> <p>I want ot convert it into a normal integer</p> <pre><code>print a 3 </code></pre> <p>How do I do that?</p>
1
2010-01-28T05:01:44Z
2,152,409
<pre><code>a = a[0] print a 3 </code></pre> <p>Or are you looking for <code>sum</code>?</p> <pre><code>&gt;&gt;&gt; a=[1] &gt;&gt;&gt; sum(a) 1 &gt;&gt;&gt; a=[1,2,3] &gt;&gt;&gt; sum(a) 6 </code></pre>
5
2010-01-28T05:03:22Z
[ "python" ]
Python: Convert a list into a normal value
2,152,401
<p>I have a list</p> <pre><code>a = [3] print a [3] </code></pre> <p>I want ot convert it into a normal integer</p> <pre><code>print a 3 </code></pre> <p>How do I do that?</p>
1
2010-01-28T05:01:44Z
2,152,412
<p>The problem is not clear. If <code>a</code> has only one element, you can get it by:</p> <pre><code>a = a[0] </code></pre> <p>If it has more than one, then you need to specify how to get a number from more than one.</p>
2
2010-01-28T05:03:57Z
[ "python" ]
Python: Convert a list into a normal value
2,152,401
<p>I have a list</p> <pre><code>a = [3] print a [3] </code></pre> <p>I want ot convert it into a normal integer</p> <pre><code>print a 3 </code></pre> <p>How do I do that?</p>
1
2010-01-28T05:01:44Z
2,152,741
<p>I imagine there are many ways.</p> <p>If you want an int() you should cast it on each item in the list:</p> <pre><code>&gt;&gt;&gt; a = [3,2,'1'] &gt;&gt;&gt; while a: print int(a.pop()) 1 2 3 </code></pre> <p>That would also empty a and pop() off each back handle cases where they are strings.</p> <p>You could...
1
2010-01-28T06:33:53Z
[ "python" ]
How can I install Easy_Install for Python 2.6.4 in Mac OSX 10.4.11
2,152,463
<p>I get the following errors, I've placed [my name] for anonymity:</p> <pre><code>&gt;&gt;&gt; python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py File "&lt;stdin&gt;", line 1 python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py ^ SyntaxError...
1
2010-01-28T05:17:11Z
2,152,494
<p>Try running that command from a shell (i.e. straight from Terminal.app), not from inside the python interpreter.</p>
2
2010-01-28T05:25:21Z
[ "python", "easy-install" ]
How can I install Easy_Install for Python 2.6.4 in Mac OSX 10.4.11
2,152,463
<p>I get the following errors, I've placed [my name] for anonymity:</p> <pre><code>&gt;&gt;&gt; python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py File "&lt;stdin&gt;", line 1 python /Users/[myname]/Desktop/setuptools-0.6c11/ez_setup.py ^ SyntaxError...
1
2010-01-28T05:17:11Z
2,153,263
<p>The ez_setup.py script may or may not work depending on your environment. If not, follow the instructions <a href="http://pypi.python.org/pypi/setuptools" rel="nofollow">here</a>. In particular, from the shell, make sure that the python 2.6 you installed is now invoked by the command <code>python</code>:</p> <pre>...
4
2010-01-28T08:54:08Z
[ "python", "easy-install" ]
how to find time at particular timezone from anywhere
2,152,471
<p>I need to know the current time at CDT when my Python script is run. However this script will be run in multiple different timezones so a simple offset won't work. I only need a solution for Linux, but a cross platform solution would be ideal.</p>
5
2010-01-28T05:19:13Z
2,152,511
<p>You can use <code>time.gmtime()</code> to get time GMT (UTC) from any machine no matter the timezone, then you can apply your offset.</p>
4
2010-01-28T05:32:46Z
[ "python", "linux", "datetime", "timezone" ]
how to find time at particular timezone from anywhere
2,152,471
<p>I need to know the current time at CDT when my Python script is run. However this script will be run in multiple different timezones so a simple offset won't work. I only need a solution for Linux, but a cross platform solution would be ideal.</p>
5
2010-01-28T05:19:13Z
2,152,557
<p><a href="http://pypi.python.org/pypi/pytz">pytz</a> or <a href="http://pypi.python.org/pypi/python-dateutil/">dateutil.tz</a> is the trick here. Basically it's something like this:</p> <pre><code>&gt;&gt;&gt; from pytz import timezone &gt;&gt;&gt; mytz = timezone('Europe/Paris') &gt;&gt;&gt; yourtz = timezone('US/E...
8
2010-01-28T05:46:39Z
[ "python", "linux", "datetime", "timezone" ]
how to find time at particular timezone from anywhere
2,152,471
<p>I need to know the current time at CDT when my Python script is run. However this script will be run in multiple different timezones so a simple offset won't work. I only need a solution for Linux, but a cross platform solution would be ideal.</p>
5
2010-01-28T05:19:13Z
2,153,272
<p>A simple offset will work, you just need to offset from UTC.</p> <p>Using <a href="http://docs.python.org/library/datetime.html" rel="nofollow">datetime</a> you can get the current utc (gmt) time and use datetime objects:</p> <p><a href="http://docs.python.org/library/datetime.html#datetime.datetime.utcnow" rel="n...
1
2010-01-28T08:55:57Z
[ "python", "linux", "datetime", "timezone" ]
Python looping: idiomatically comparing successive items in a list
2,152,640
<p>I need to loop over a list of objects, comparing them like this: 0 vs. 1, 1 vs. 2, 2 vs. 3, etc. (I'm using pysvn to extract a list of diffs.) I wound up just looping over an index, but I keep wondering if there's some way to do it which is more closely idiomatic. It's Python; shouldn't I be using iterators in some ...
6
2010-01-28T06:09:10Z
2,152,654
<p>Store the previous value in a variable. Initialize the variable with a value you're not likely to find in the sequence you're handling, so you can know if you're at the first element. Compare the old value to the current value.</p>
0
2010-01-28T06:14:41Z
[ "loops", "iterator", "python" ]
Python looping: idiomatically comparing successive items in a list
2,152,640
<p>I need to loop over a list of objects, comparing them like this: 0 vs. 1, 1 vs. 2, 2 vs. 3, etc. (I'm using pysvn to extract a list of diffs.) I wound up just looping over an index, but I keep wondering if there's some way to do it which is more closely idiomatic. It's Python; shouldn't I be using iterators in some ...
6
2010-01-28T06:09:10Z
2,152,658
<p>I'd probably do:</p> <pre><code>import itertools for rev1, rev2 in zip(dm_revisions, itertools.islice(dm_revisions, 1, None)): summary = svn.diff_sumeraize(svn_python, revision1=rev, revision2=rev2) </code></pre> <p>Something similarly cleverer and not touching the iterators themselves could probably be done u...
4
2010-01-28T06:15:23Z
[ "loops", "iterator", "python" ]
Python looping: idiomatically comparing successive items in a list
2,152,640
<p>I need to loop over a list of objects, comparing them like this: 0 vs. 1, 1 vs. 2, 2 vs. 3, etc. (I'm using pysvn to extract a list of diffs.) I wound up just looping over an index, but I keep wondering if there's some way to do it which is more closely idiomatic. It's Python; shouldn't I be using iterators in some ...
6
2010-01-28T06:09:10Z
2,152,772
<p>Reduce can be used for this purpose, if you take care to <em>leave a copy of the current item in the result of the reducing function</em>.</p> <pre><code>def diff_summarize(revisionList, nextRevision): '''helper function (adaptor) for using svn.diff_summarize with reduce''' if revisionList: # remove...
-1
2010-01-28T06:41:00Z
[ "loops", "iterator", "python" ]
Python looping: idiomatically comparing successive items in a list
2,152,640
<p>I need to loop over a list of objects, comparing them like this: 0 vs. 1, 1 vs. 2, 2 vs. 3, etc. (I'm using pysvn to extract a list of diffs.) I wound up just looping over an index, but I keep wondering if there's some way to do it which is more closely idiomatic. It's Python; shouldn't I be using iterators in some ...
6
2010-01-28T06:09:10Z
2,152,948
<p>This is called a sliding window. There's an <a href="http://www.python.org/doc/2.3.5/lib/itertools-example.html">example in the <code>itertools</code> documentation</a> that does it. Here's the code:</p> <pre><code>from itertools import islice def window(seq, n=2): "Returns a sliding window (of width n) over d...
12
2010-01-28T07:29:57Z
[ "loops", "iterator", "python" ]
Python looping: idiomatically comparing successive items in a list
2,152,640
<p>I need to loop over a list of objects, comparing them like this: 0 vs. 1, 1 vs. 2, 2 vs. 3, etc. (I'm using pysvn to extract a list of diffs.) I wound up just looping over an index, but I keep wondering if there's some way to do it which is more closely idiomatic. It's Python; shouldn't I be using iterators in some ...
6
2010-01-28T06:09:10Z
2,164,669
<p>So many complex solutions posted, why not keep it simple?</p> <pre><code>myList = range(5) for idx, item1 in enumerate(myList[:-1]): item2 = L[idx + 1] print item1, item2 &gt;&gt;&gt; 0 1 1 2 2 3 3 4 </code></pre>
3
2010-01-29T19:42:48Z
[ "loops", "iterator", "python" ]
Displaying dictionary value in django template
2,152,652
<p>All,</p> <p>I have the following in my views.py</p> <pre><code>def getgradeform(request): id1=request.user.get_pf().id sc=Sc.objects.filter(id=id1) logging.debug(sc) logging.debug("++++") dict={} dict.update({'sc': sc}) return render_to_response('content/add.html',dict) </code></pre> <p>Loggi...
1
2010-01-28T06:13:00Z
2,152,701
<p>If you want any value in a dictionary, you have to do it on the way</p> <pre><code>dict.key </code></pre> <p>(On python you'll write it as dict['key'])</p> <p>So, to present the value stored with key 'name' </p> <pre><code>{{ sc.name }} </code></pre> <p>Anyway, I think this is not you're case. I think you're no...
5
2010-01-28T06:25:24Z
[ "python", "django", "templates" ]
Template extraction in python/php
2,152,786
<p>Are there existing template extract libraries in either python or php? Perl has <a href="http://metacpan.org/pod/Template%3a%3aExtract" rel="nofollow">Template::Extract</a>, but I haven't been able to find a similar implementation in either python or php. </p> <p>The only thing close in python that I could find is ...
3
2010-01-28T06:46:33Z
2,152,827
<p><code>TmeplateMaker</code> does seem to do what you need, at least according to its documentation. Instead of receiving a template as an input, it infers ("learns") if from a few documents. Then, it has the <code>extract</code> method to extract the data from other documents that were created with this template.</p>...
1
2010-01-28T07:00:09Z
[ "php", "python", "templates", "extract" ]
Template extraction in python/php
2,152,786
<p>Are there existing template extract libraries in either python or php? Perl has <a href="http://metacpan.org/pod/Template%3a%3aExtract" rel="nofollow">Template::Extract</a>, but I haven't been able to find a similar implementation in either python or php. </p> <p>The only thing close in python that I could find is ...
3
2010-01-28T06:46:33Z
2,152,885
<p>Here is an interesting discussion from Adrian the author of TemplateMaker <a href="http://www.holovaty.com/writing/templatemaker/" rel="nofollow">http://www.holovaty.com/writing/templatemaker/</a></p> <p>It seems to be a lot like what I would call a wrapper induction library.</p> <p>If your looking for something e...
0
2010-01-28T07:14:27Z
[ "php", "python", "templates", "extract" ]
Template extraction in python/php
2,152,786
<p>Are there existing template extract libraries in either python or php? Perl has <a href="http://metacpan.org/pod/Template%3a%3aExtract" rel="nofollow">Template::Extract</a>, but I haven't been able to find a similar implementation in either python or php. </p> <p>The only thing close in python that I could find is ...
3
2010-01-28T06:46:33Z
2,411,362
<p>After digging around some more I found a solution to exactly what I was looking for. filippo posted a list of python solutions for screen scraping in this post: <a href="http://stackoverflow.com/questions/2861/options-for-html-scraping/1970411#1970411">http://stackoverflow.com/questions/2861/options-for-html-scrapin...
2
2010-03-09T18:07:29Z
[ "php", "python", "templates", "extract" ]
Filtering a list of strings based on contents
2,152,898
<p>Given the list <code>['a','ab','abc','bac']</code>, I want to compute a list with strings that have <code>'ab'</code> in them. I.e. the result is <code>['ab','abc']</code>. How can this be done in Python?</p>
25
2010-01-28T07:17:41Z
2,152,904
<pre><code>[x for x in L if 'ab' in x] </code></pre>
9
2010-01-28T07:19:13Z
[ "python", "list" ]
Filtering a list of strings based on contents
2,152,898
<p>Given the list <code>['a','ab','abc','bac']</code>, I want to compute a list with strings that have <code>'ab'</code> in them. I.e. the result is <code>['ab','abc']</code>. How can this be done in Python?</p>
25
2010-01-28T07:17:41Z
2,152,907
<p>Tried this out quickly in the interactive shell:</p> <pre><code>&gt;&gt;&gt; l = ['a', 'ab', 'abc', 'bac'] &gt;&gt;&gt; [x for x in l if 'ab' in x] ['ab', 'abc'] &gt;&gt;&gt; </code></pre> <p>Why does this work? Because the <a href="http://docs.python.org/library/stdtypes.html#sequence-types-str-unicode-list-tuple...
3
2010-01-28T07:19:53Z
[ "python", "list" ]
Filtering a list of strings based on contents
2,152,898
<p>Given the list <code>['a','ab','abc','bac']</code>, I want to compute a list with strings that have <code>'ab'</code> in them. I.e. the result is <code>['ab','abc']</code>. How can this be done in Python?</p>
25
2010-01-28T07:17:41Z
2,152,908
<p>This simple filtering can be achieved in many ways with Python. The best approach is to use "list comprehensions" as follows:</p> <pre><code>&gt;&gt;&gt; lst = ['a', 'ab', 'abc', 'bac'] &gt;&gt;&gt; res = [k for k in lst if 'ab' in k] &gt;&gt;&gt; res ['ab', 'abc'] &gt;&gt;&gt; </code></pre> <p>Another way is to ...
36
2010-01-28T07:20:01Z
[ "python", "list" ]
Filtering a list of strings based on contents
2,152,898
<p>Given the list <code>['a','ab','abc','bac']</code>, I want to compute a list with strings that have <code>'ab'</code> in them. I.e. the result is <code>['ab','abc']</code>. How can this be done in Python?</p>
25
2010-01-28T07:17:41Z
2,152,909
<pre><code>mylist = ['a', 'ab', 'abc'] assert 'ab' in mylist </code></pre>
0
2010-01-28T07:20:33Z
[ "python", "list" ]
Filtering a list of strings based on contents
2,152,898
<p>Given the list <code>['a','ab','abc','bac']</code>, I want to compute a list with strings that have <code>'ab'</code> in them. I.e. the result is <code>['ab','abc']</code>. How can this be done in Python?</p>
25
2010-01-28T07:17:41Z
2,152,919
<pre><code>list = ['a', 'ab', 'abc', 'bac'] prefix = 'ab' filter(lambda x: x.startsWith(prefix), list) </code></pre>
2
2010-01-28T07:22:48Z
[ "python", "list" ]
Custom auth handler with mechanize
2,153,095
<p>I would like to use <a href="http://code.google.com/p/python-ntlm/" rel="nofollow">python-ntlm</a> with mechanize.Browser() I have got HTTPNtlmAuthHandler working with urllib2 and mechanize.urlopen() and tried to use it with Browser() but it doesn't work</p> <p>Here is the code I'm using for urlopen</p> <pre><code...
4
2010-01-28T08:07:08Z
5,123,565
<p>There may be better options, but the only way I could get it to work was to remove the HTTPRobotRulesProcessor handler which was somehow preventing the HTTPNtlmAuthHandler from being called.</p> <p>Note: The following code also happens to remove the ProxyHandler in order to bypass the proxy server - remove if appl...
1
2011-02-25T22:48:38Z
[ "python", "mechanize" ]
Python example of Joe's Erlang websocket example
2,153,294
<p>I've just been working through the erlang websockets example from <a href="http://armstrongonsoftware.blogspot.com/2009/12/comet-is-dead-long-live-websockets.html" rel="nofollow">Joe Armstrong's blog</a> I'm still quite new to erlang so I decided to write a simple server in python that would help teach me about webs...
9
2010-01-28T08:58:50Z
2,153,880
<p>For those who are interested this was the solution</p> <pre><code>import threading import socket def start_server(): tick = 0 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(('localhost', 1234)) sock.listen(100) while True: print 'listening...' csock, address ...
10
2010-01-28T10:48:54Z
[ "python", "websocket" ]
Python example of Joe's Erlang websocket example
2,153,294
<p>I've just been working through the erlang websockets example from <a href="http://armstrongonsoftware.blogspot.com/2009/12/comet-is-dead-long-live-websockets.html" rel="nofollow">Joe Armstrong's blog</a> I'm still quite new to erlang so I decided to write a simple server in python that would help teach me about webs...
9
2010-01-28T08:58:50Z
3,433,665
<p>Thanks for sharing the code. I ran into one problem running this code in Windows. Which I think it might help for people who are still figuring.</p> <ol> <li><p>I strink the space, so that it bacame 'Upgrade: WebSocket'</p></li> <li><p>Make sure your hosting page is matching the Origin, which in this case it's 'htt...
0
2010-08-08T08:46:30Z
[ "python", "websocket" ]
Python example of Joe's Erlang websocket example
2,153,294
<p>I've just been working through the erlang websockets example from <a href="http://armstrongonsoftware.blogspot.com/2009/12/comet-is-dead-long-live-websockets.html" rel="nofollow">Joe Armstrong's blog</a> I'm still quite new to erlang so I decided to write a simple server in python that would help teach me about webs...
9
2010-01-28T08:58:50Z
4,726,532
<p>Eventlet has websocket support built in and stargate is a package for using websockets with the pyramid web framework: <a href="http://boothead.github.com/stargate/" rel="nofollow">http://boothead.github.com/stargate/</a></p>
0
2011-01-18T16:38:12Z
[ "python", "websocket" ]
Python object conversion
2,153,295
<p>Assume that we have a an object <code>k</code> of type <code>class A</code>. We defined a second <code>class B(A)</code>. What is the best practice to "convert" object <code>k</code> to <code>class B</code> and preserve all data in <code>k</code>?</p>
21
2010-01-28T08:59:13Z
2,153,327
<pre><code>a = A() # parent class b = B() # subclass b.value = 3 # random setting of values a.__dict__ = b.__dict__ # give object a b's values # now proceed to use object a </code></pre> <p>Would this satisfy your use case? Note: Only the instance variables of b will be accessible from object a, not class B's class ...
6
2010-01-28T09:06:42Z
[ "python" ]
Python object conversion
2,153,295
<p>Assume that we have a an object <code>k</code> of type <code>class A</code>. We defined a second <code>class B(A)</code>. What is the best practice to "convert" object <code>k</code> to <code>class B</code> and preserve all data in <code>k</code>?</p>
21
2010-01-28T08:59:13Z
2,154,790
<p>This does the "class conversion" but it is subject to collateral damage. Creating another object and replacing its <code>__dict__</code> as BrainCore posted would be safer - but this code does what you asked, with no new object being created.</p> <pre><code>class A(object): pass class B(A): def __add__(sel...
15
2010-01-28T13:30:47Z
[ "python" ]
Python: Finding average of a nested list
2,153,444
<p>I have a list</p> <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]] </code></pre> <p>Now I want to find the average of these inner list so that </p> <pre><code>a = [(1+4+7)/3,(2+5+8)/3,(3+6+9)/3] </code></pre> <p>'a' should not be a nested list in the end. Kindly provide an answer for the generic case</p>
10
2010-01-28T09:27:29Z
2,153,459
<pre><code>a = [sum(x)/len(x) for x in zip(*a)] # a is now [4, 5, 6] for your example </code></pre> <p>In Python 2.x, if you don't want integer division, replace <code>sum(x)/len(x)</code> by <code>1.0*sum(x)/len(x)</code> above.</p> <p><a href="http://docs.python.org/library/functions.html#zip">Documentation for zip...
10
2010-01-28T09:30:23Z
[ "python" ]
Python: Finding average of a nested list
2,153,444
<p>I have a list</p> <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]] </code></pre> <p>Now I want to find the average of these inner list so that </p> <pre><code>a = [(1+4+7)/3,(2+5+8)/3,(3+6+9)/3] </code></pre> <p>'a' should not be a nested list in the end. Kindly provide an answer for the generic case</p>
10
2010-01-28T09:27:29Z
2,153,489
<pre><code>&gt;&gt;&gt; import itertools &gt;&gt;&gt; [sum(x)/len(x) for x in itertools.izip(*a)] [4, 5, 6] </code></pre>
4
2010-01-28T09:36:24Z
[ "python" ]
Python: Finding average of a nested list
2,153,444
<p>I have a list</p> <pre><code>a = [[1,2,3],[4,5,6],[7,8,9]] </code></pre> <p>Now I want to find the average of these inner list so that </p> <pre><code>a = [(1+4+7)/3,(2+5+8)/3,(3+6+9)/3] </code></pre> <p>'a' should not be a nested list in the end. Kindly provide an answer for the generic case</p>
10
2010-01-28T09:27:29Z
2,157,646
<p>If you have <a href="http://numpy.scipy.org/" rel="nofollow">numpy</a> installed:</p> <pre><code>&gt;&gt;&gt; import numpy as np &gt;&gt;&gt; a = [[1,2,3],[4,5,6],[7,8,9]] &gt;&gt;&gt; arr = np.array(a) &gt;&gt;&gt; arr array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) &gt;&gt;&gt; np.mean(arr) 5.0 &gt;&gt;&gt...
3
2010-01-28T20:17:17Z
[ "python" ]
Loading a document on OpenOffice using an external Python program
2,153,843
<p>I'm trying to create a python program (using pyUNO ) to make some changes on a OpenOffice calc sheet.</p> <p>I've launched previously OpenOffice on "accept" mode to be able to connect from an external program. Apparently, should be as easy as:</p> <pre><code>import uno # get the uno component context from the PyUN...
6
2010-01-28T10:41:54Z
2,181,306
<p>It has been a long time since I did anything with PyUNO, but looking at the code that worked last time I ran it back in '06, I did my load document like this:</p> <pre><code>def urlify(path): return uno.systemPathToFileUrl(os.path.realpath(path)) desktop.loadComponentFromURL( urlify(tempfilename), "_b...
4
2010-02-02T01:15:41Z
[ "python", "pyuno" ]
Loading a document on OpenOffice using an external Python program
2,153,843
<p>I'm trying to create a python program (using pyUNO ) to make some changes on a OpenOffice calc sheet.</p> <p>I've launched previously OpenOffice on "accept" mode to be able to connect from an external program. Apparently, should be as easy as:</p> <pre><code>import uno # get the uno component context from the PyUN...
6
2010-01-28T10:41:54Z
2,380,994
<p>This looks like issue 90701: <a href="http://www.openoffice.org/issues/show_bug.cgi?id=90701" rel="nofollow">http://www.openoffice.org/issues/show_bug.cgi?id=90701</a></p> <p>See also <a href="http://piiis.blogspot.com/2008/10/pyuno-broken-in-ooo-30-with-system.html" rel="nofollow">http://piiis.blogspot.com/2008/10...
2
2010-03-04T16:39:52Z
[ "python", "pyuno" ]
Python: Visualization tool for graphs
2,153,878
<p>Guys I have asked this question before but did not receive a single comment or answer</p> <p>I want to simulate a search algorithm on a power law graph and want to visually see the algorithm move from one node to another on the graph. How do I do that?</p>
4
2010-01-28T10:48:05Z
2,153,894
<p>You can adapt this completely different code I happen to have written for <a href="http://stackoverflow.com/questions/2151162/find-the-most-points-enclosed-in-a-fixed-size-circle">http://stackoverflow.com/questions/2151162/find-the-most-points-enclosed-in-a-fixed-size-circle</a> :)</p> <p>The useful bit is:</p> <p...
2
2010-01-28T10:51:19Z
[ "python" ]
Python: Visualization tool for graphs
2,153,878
<p>Guys I have asked this question before but did not receive a single comment or answer</p> <p>I want to simulate a search algorithm on a power law graph and want to visually see the algorithm move from one node to another on the graph. How do I do that?</p>
4
2010-01-28T10:48:05Z
2,154,170
<p>You can use <a href="http://matplotlib.sourceforge.net/" rel="nofollow">matplotlib</a> for that.</p> <p>Here is a simlple example of a mesh with an animated highlighted point:</p> <pre><code>import matplotlib.pyplot as plt import time x_size = 4 y_size = 3 # create the points and edges of the mesh points = [(x,y...
2
2010-01-28T11:43:13Z
[ "python" ]
Returning the first N characters of a unicode string
2,153,920
<p>I have a string in unicode and I need to return the first N characters. I am doing this:</p> <pre><code>result = unistring[:5] </code></pre> <p>but of course the length of unicode strings != length of characters. Any ideas? The only solution is using re?</p> <p>Edit: More info</p> <pre><code>unistring = "ΜετÎ...
9
2010-01-28T10:56:23Z
2,154,536
<p>When you say:</p> <pre><code>unistring = "Μεταλλικα" #Metallica written in Greek letters </code></pre> <p>You <em>do not have</em> a unicode string. You have a bytestring in (presumably) UTF-8. That is not the same thing. A unicode string is a separate datatype in Python. You get unicode by decoding bytes...
7
2010-01-28T12:44:50Z
[ "python", "unicode", "python-2.x" ]
Returning the first N characters of a unicode string
2,153,920
<p>I have a string in unicode and I need to return the first N characters. I am doing this:</p> <pre><code>result = unistring[:5] </code></pre> <p>but of course the length of unicode strings != length of characters. Any ideas? The only solution is using re?</p> <p>Edit: More info</p> <pre><code>unistring = "ΜετÎ...
9
2010-01-28T10:56:23Z
2,154,990
<p>Unfortunately for historical reasons prior to Python 3.0 there are two string types. <a href="http://stackoverflow.com/questions/1979004/what-is-the-difference-between-isinstanceaaa-basestring-and-isinstanceaaa/1979107#1979107">byte strings (<code>str</code>) and Unicode strings (<code>unicode</code>)</a>. </p> <p>...
6
2010-01-28T14:03:48Z
[ "python", "unicode", "python-2.x" ]
Returning the first N characters of a unicode string
2,153,920
<p>I have a string in unicode and I need to return the first N characters. I am doing this:</p> <pre><code>result = unistring[:5] </code></pre> <p>but of course the length of unicode strings != length of characters. Any ideas? The only solution is using re?</p> <p>Edit: More info</p> <pre><code>unistring = "ΜετÎ...
9
2010-01-28T10:56:23Z
2,162,232
<p>There is no correct straight-forward approach with any type of "Unicode string".</p> <p>Even Python "Unicode" UTF-16 string has variable length characters so, you can't just cut with ustring[:5]. Because some Unicode Code points may use more then one "character" i.e. Surrogate pairs.</p> <p>So if you want to cut 5...
4
2010-01-29T13:39:24Z
[ "python", "unicode", "python-2.x" ]
Efficient reordering of coordinate pairs (2-tuples) in a list of pairs in Python
2,153,976
<p>I am wanting to zip up a list of entities with a new entity to generate a list of coordinates (2-tuples), but I want to assure that for (i, j) that i &lt; j is always true.</p> <p>However, I am not extremely pleased with my current solutions:</p> <pre><code>from itertools import repeat mems = range(1, 10, 2) mem...
2
2010-01-28T11:05:01Z
2,154,015
<h2>Most recent version:</h2> <pre><code>def zipij7(m=mem, ms=mems): cpy = sorted(ms + [m]) loc = cpy.index(m) return zip(ms[:(loc)], repeat(m)) + zip(repeat(m), ms[(loc):]) </code></pre> <p>Benches slightly faster for me than truppo's, slower by 30% than Michal's. (Looking into that now)</p> <hr> <p>I may h...
0
2010-01-28T11:12:40Z
[ "python", "sorting", "tuples" ]
Efficient reordering of coordinate pairs (2-tuples) in a list of pairs in Python
2,153,976
<p>I am wanting to zip up a list of entities with a new entity to generate a list of coordinates (2-tuples), but I want to assure that for (i, j) that i &lt; j is always true.</p> <p>However, I am not extremely pleased with my current solutions:</p> <pre><code>from itertools import repeat mems = range(1, 10, 2) mem...
2
2010-01-28T11:05:01Z
2,154,043
<h2>Current version:</h2> <p>(Fastest at the time of posting with Python 2.6.4 on my machine.)</p> <p>Update 3: Since we're going all out, let's do a binary search -- in a way which doesn't require injecting <code>m</code> into <code>mems</code>:</p> <pre><code>def binsearch(x, lst): low, high = -1, len(lst) ...
2
2010-01-28T11:19:27Z
[ "python", "sorting", "tuples" ]
Efficient reordering of coordinate pairs (2-tuples) in a list of pairs in Python
2,153,976
<p>I am wanting to zip up a list of entities with a new entity to generate a list of coordinates (2-tuples), but I want to assure that for (i, j) that i &lt; j is always true.</p> <p>However, I am not extremely pleased with my current solutions:</p> <pre><code>from itertools import repeat mems = range(1, 10, 2) mem...
2
2010-01-28T11:05:01Z
2,154,101
<p>Why not just inline your ij()-function?</p> <pre><code>def zipij(m=mem, ms=mems): return [(i, m) if i &lt; m else (m, i) for i in ms] </code></pre> <p>(This runs in 0.64 ms instead of 2.12 ms on my computer)</p> <p><strong>Some benchmarks:</strong></p> <p>zipit.py:</p> <pre><code>from itertools import repeat ...
2
2010-01-28T11:30:30Z
[ "python", "sorting", "tuples" ]
Log onto a Website and select options using Python
2,154,095
<p>I am trying to log onto a website using Python. I have written the code to connect to the target but I need to login and select a button on the website and wait for a response. I have looked at the HTTP Protocol in Python and was thinking of using 'HTTPConnection.putrequest'. I am not sure how to do this, I have the...
3
2010-01-28T11:28:37Z
2,154,308
<p>Yes, you use <a href="http://pypi.python.org/pypi/mechanize/0.1.11" rel="nofollow">mechanize</a>, which a sort of a "webbrowser" for Python. With it you can easily open web pages, find forms, fill in form values and submit the forms from Python. I use it (via Zopes testbrowser module) for testing web applications.</...
3
2010-01-28T12:05:09Z
[ "python", "web-services", "https", "httplib" ]
Log onto a Website and select options using Python
2,154,095
<p>I am trying to log onto a website using Python. I have written the code to connect to the target but I need to login and select a button on the website and wait for a response. I have looked at the HTTP Protocol in Python and was thinking of using 'HTTPConnection.putrequest'. I am not sure how to do this, I have the...
3
2010-01-28T11:28:37Z
2,154,688
<p>Use <a href="http://docs.python.org/library/urllib2.html" rel="nofollow">urllib2</a> and create a POST request.</p> <p>For more information, read:</p> <ul> <li><a href="http://stackoverflow.com/questions/1507170/urllib2-submitting-a-form-and-then-redirecting">http://stackoverflow.com/questions/1507170/urllib2-subm...
1
2010-01-28T13:12:17Z
[ "python", "web-services", "https", "httplib" ]
How to enter item into Google AppEngine Datastore?
2,154,110
<p>I want to check if an email is in my database in Appengine, and if not: then enter it into the datastore. </p> <p>I am new to python. <strong>Why is this simple code not working?</strong> (Also If there is a better way/more efficient way to write this, please tell me)</p> <p>(I get the error: BadArgumentError: Unu...
3
2010-01-28T11:32:37Z
2,154,162
<p>You don't need to use quotes when binding a parameter to the query:</p> <pre><code>query = db.GqlQuery("SELECT * FROM EmailDatabase WHERE emailaddress = :1", self.request.get('emailaddress')) </code></pre> <p>Otherwise it will read it as a string and actually only return objects that have <code>:1</code> as their ...
6
2010-01-28T11:41:57Z
[ "python", "google-app-engine", "gql" ]
Parsing a range of integers in a list
2,154,116
<p>I've just began learning Python and I've ran into a small problem. I need to parse a text file, more specifically an HTML file (but it's syntax is so weird - divs after divs after divs, the result of a Google's 'View as HTML' for a certain PDF i can't seem to extract the text because it has a messy table done in m$ ...
1
2010-01-28T11:33:32Z
2,154,124
<p>Don't use regular expressions to parse HTML. <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> will make light work of this.</p> <p>As for your specific problem, it might be that you are missing a colon at the end of the first line:</p> <pre><code>for o in re.finditer('left:1...
1
2010-01-28T11:36:08Z
[ "python", "regex", "parsing", "syntax-error" ]
PyQt and Bespin (KDE style)
2,154,225
<p>What tab widget decorate by Bespin Tabs? I tried QTabWidget, QTabBar, KTabWidget, KTabBar, bau no effect. What Im doing wrong? All KDE apps and SMPlayer decorate by Bespin, but acetoneiso and PyQt apps have regular tabs=(</p> <p>I mean this Bespin: <a href="http://kde-look.org/content/show.php/Bespin?content=63928"...
2
2010-01-28T11:52:59Z
13,487,945
<p>That is a bit strange. It should have automatically decorated your application with the style Bespin. However you can force it decorate the application with a specific style.</p> <pre><code># Check the available styles with qt sf = QStyleFactory() print list( sf.keys() ) </code></pre> <p>That should list all the s...
0
2012-11-21T06:59:23Z
[ "python", "qt4", "pyqt4", "kde4" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,154,312
<p>This doesn't use a standard function - it just iiterates over the input, but it should work:</p> <pre><code>def myfunc(l): r = [] p = q = None for x in l + [-1]: if x - 1 == q: q += 1 else: if p: if q &gt; p: r.append('%s-%s' % (p...
3
2010-01-28T12:05:57Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,154,409
<p>Assuming your list is sorted:</p> <pre><code>&gt;&gt;&gt; from itertools import groupby &gt;&gt;&gt; def ranges(lst): pos = (j - i for i, j in enumerate(lst)) t = 0 for i, els in groupby(pos): l = len(list(els)) el = lst[t] t += l yield range(el, el+l) &gt;&gt;&gt; lst ...
7
2010-01-28T12:21:30Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,154,437
<p><strong>EDIT 2: To answer the OP new requirement</strong></p> <pre><code>ranges = [] for key, group in groupby(enumerate(data), lambda (index, item): index - item): group = map(itemgetter(1), group) if len(group) &gt; 1: ranges.append(xrange(group[0], group[-1])) else: ranges.append(grou...
71
2010-01-28T12:26:12Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,154,741
<p>The "naive" solution which I find somewhat readable atleast.</p> <pre><code>x = [2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 22, 25, 26, 28, 51, 52, 57] def group(L): first = last = L[0] for n in L[1:]: if n - 1 == last: # Part of the group, bump the end last = n else: # Not part of the...
10
2010-01-28T13:21:51Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,154,829
<p>Here's the answer I came up with. I'm writing the code for other people to understand, so I'm fairly verbose with variable names and comments.</p> <p>First a quick helper function:</p> <pre><code>def getpreviousitem(mylist,myitem): '''Given a list and an item, return previous item in list''' for position, ...
1
2010-01-28T13:37:23Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
2,155,283
<p>Here it is something that should work, without any import needed:</p> <pre><code>def myfunc(lst): ret = [] a = b = lst[0] # a and b are range's bounds for el in lst[1:]: if el == b+1: b = el # range grows else: # r...
6
2010-01-28T14:47:28Z
[ "python", "list", "range", "continuous" ]
Identify groups of continuous numbers in a list
2,154,249
<p>I'd like to identify groups of continuous numbers in a list, so that:</p> <pre><code>myfunc([2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 20]) </code></pre> <p>Returns:</p> <pre><code>[(2,5), (12,17), 20] </code></pre> <p>And was wondering what the best way to do this was (particularly if there's something inbuilt into P...
42
2010-01-28T11:57:15Z
30,336,492
<p>Please note that the code using <code>groupby</code> doesn't work as given in Python 3 so use this.</p> <pre><code>for k, g in groupby(enumerate(data), lambda x:x[0]-x[1]): group = list(map(itemgetter(1), g)) ranges.append((group[0], group[-1])) </code></pre>
1
2015-05-19T21:29:30Z
[ "python", "list", "range", "continuous" ]
Screen Capture Under Win7 of JOGL Applet
2,154,448
<p>I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine.<br> A few examples of...
2
2010-01-28T12:28:57Z
2,203,629
<p>Unless you are trying to automate it, I would just use a Firefox extension for this. There are a number of them returned from <a href="https://addons.mozilla.org/en-US/firefox/search?q=screenshot" rel="nofollow">a search for "screenshot"</a> that can take a screenshot of the entire browser page including the scrolla...
0
2010-02-04T22:12:21Z
[ "python", "gdi", "jogl" ]
Screen Capture Under Win7 of JOGL Applet
2,154,448
<p>I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine.<br> A few examples of...
2
2010-01-28T12:28:57Z
2,280,520
<p>Here is one way to do it by disabling dwm (Desktop Window Manager) composition before taking the screen shot, but this causes the whole screen to blink whenever its enabled/disabled.</p> <pre><code>from ctypes import WinDLL from time import sleep import win32gui as wg import win32ui as wu import win32con d...
0
2010-02-17T12:28:22Z
[ "python", "gdi", "jogl" ]
Screen Capture Under Win7 of JOGL Applet
2,154,448
<p>I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine.<br> A few examples of...
2
2010-01-28T12:28:57Z
2,570,706
<p>Grabbing an OpenGL window may be quite hard in some cases, since the OpenGL is being rendered by the GPU directly into its frame buffer. The same applies to DirectX windows and Video overlay windows.</p>
0
2010-04-03T08:51:26Z
[ "python", "gdi", "jogl" ]
Screen Capture Under Win7 of JOGL Applet
2,154,448
<p>I'm trying to take a screen shot of an applet running inside a browser. The applet is using JOGL (OpenGL for Java) to display 3D models. (1) The screen shots always come out either black or white.The current solution uses the usual GDI calls. Screen shots of applets not running OpenGL are fine.<br> A few examples of...
2
2010-01-28T12:28:57Z
4,367,473
<p>Why not using the Screenshot class of JOGL?? com.jogamp.opengl.util.awt.Screenshot in JOGL 2.0 beta</p>
0
2010-12-06T14:37:46Z
[ "python", "gdi", "jogl" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,154,958
<p>Here's a <a href="http://www.algorithm.co.il/blogs/index.php/programming/python/lru-cache-solution-a-case-for-linked-lists-in-python/">blog post</a> sharing your pain. It includes an implementation of a linked list and a performance comparison.</p> <hr> <p>Perhaps <code>blist</code> would be better, though (from <...
9
2010-01-28T13:58:23Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,155,002
<p>Python's <a href="http://docs.python.org/library/collections.html#collections.deque" rel="nofollow"><code>deque</code></a> class is 0(1) for insertion and deletion at the beginning and end of the list.</p>
3
2010-01-28T14:04:54Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,155,625
<p>There's a single-linked list <a href="http://books.google.com/books?id=yhfdQgq8JF4C&amp;pg=PA533&amp;lpg=PA533&amp;dq=martelli+python+linked+list&amp;source=bl&amp;ots=-5pjCzgP0_&amp;sig=y6iUN6XR2LRjJi-uTkijeRHhkxA&amp;hl=en&amp;ei=BqlhS9hXhoazA-O88bID&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=6&amp;ved=0...
6
2010-01-28T15:29:21Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,155,794
<p>Python lists are <a href="http://wiki.python.org/moin/TimeComplexity">O(1) for operations at the end of the list</a>. If you'll be doing all your inserting in a semi-sequential fashion--by analogy to C, only keeping a single pointer into the middle of the list as a "cursor" of sorts--you could save yourself a lot of...
7
2010-01-28T15:51:09Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,157,591
<p>" I will iterate over the list forwards (one by one), using a visitor on each entry, starting from the beginning or a position found by a binary search. When an entry matching a predicate is found it is removed from the list, and then, another binary search is performed on a subset of the list beginning from the rem...
3
2010-01-28T20:05:54Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,158,029
<p>Your requirements are still (after the edit) unclear. You say that you are doing a binary search on a <strong>linked</strong> list. Please pardon my ignorance, but I was under the impression that a binary search required direct access to list components via a calculated integer index. Perhaps your "linked list" is r...
1
2010-01-28T21:19:42Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,159,288
<p>It's puzzling that everyone demands justification to need a linked list. Linked lists are one of the most elementary data structures for a reason: they have properties that the other major data structures lack, and if you need those properties, you need a linked list or one of its close relatives. If you don't und...
5
2010-01-29T01:20:53Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
2,166,548
<p>Here's an idea, that would require a little coding, but may give you hugely better performance. It may or may not be suitable for your use case.</p> <p>You can splice a new list into your list by replacing a single element. To insert the list [6, 7, 8] into [1, 2, 3, 4, 5] at index 2, you would end up with</p> <p...
0
2010-01-30T02:15:35Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
4,052,959
<p>For large data, keep a sorted list is a trick. Don't insert but append new items at the end and then sort it. Don't delet item but replace with a special value, sort them to the end and then pop out. For finding, a sorted list also has very quick performance with bisection method. As for small data, iterate old li...
1
2010-10-29T14:49:52Z
[ "python", "algorithm", "list", "linked-list" ]
Python linked list O(1) insert/remove
2,154,946
<p>I am looking for a linked list and related algorithms implementation for Python. Everyone I ask just recommends using built in Python lists, but performance measurements indicate that list insertion and removal is a bottleneck for our application. It's trivial to implement a simple linked list, but I wonder if there...
4
2010-01-28T13:55:37Z
11,073,440
<p>I recently had the need for a circular and doubly linked list. Since I am very familiar with the Linux kernel's linked list. I wrote a copycat linked list in Python. It provides O(1) random insertion and deletion. It is much faster than Python's list when you are doing random insertion and deletion on a big list. Th...
0
2012-06-17T17:40:34Z
[ "python", "algorithm", "list", "linked-list" ]