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
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
407,000
<p>Python is not a one-trick pony. Therefore, there's no single "central framework" for it. Many people first heard of Python as "another nice OO language" or through one of the many uses to which it has been put.</p> <p>To be fair, Ruby is not a one-trick pony either. It's just that many people regarded Rails as the ...
1
2009-01-02T15:02:40Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
407,003
<p>As I see it, Rails put Ruby on the map. The simple fact is that before Rails, Ruby was a minor esoteric language, with very little adoption. Ruby owes its success to Rails. As such, Rails has a central place in the Ruby ecosystem. As slim points out, there are other web frameworks, but it's going to be very diffi...
35
2009-01-02T15:03:40Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
407,260
<p>I agree with Ned. I'd bet that more than 90% of Ruby installations are for no other purpose than running Rails. Rails dominates Ruby - there is no single application that dominates Python, mainly because the Python community is somewhat bigger than the Ruby community. </p>
5
2009-01-02T16:07:34Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
407,543
<p>Would ruby be less popular without Rails? absolutely.</p> <p>Would Python be more popular with one true framework? You mean as opposed to several? May be, who knows. In any case most agree Django is a very good framework.</p> <p>Why, historically, did it happen to Ruby? Because DHH chose Ruby after doing his own r...
2
2009-01-02T17:51:17Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
408,146
<p>The real technical answer is that there are three major approaches to web-development in Python: one is CGI-based, where the application is built just like an old one-off Perl application to run through CGI or FastCGI, e.g. <a href="http://trac.edgewall.org/" rel="nofollow">Trac</a>; then there is <a href="http://zo...
7
2009-01-02T22:08:20Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
408,756
<p>I'd have to agree that Django is basically the "Rails for Python" equivalent. Why did it take so long? The simple answer is too many options.</p> <p>In Python, there are many request/response systems, url rewriters, ORMs, templating languages, etc. that you could build a web stack in dozens of different configura...
2
2009-01-03T07:33:13Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
412,947
<p>If you followed the news, you have read that Merb and Rails will merge. This is a good move IMHO. I think it's because of the common goal that the developers have: They want a simple framework for webdev, which comes with a OR mapper, routing, template language, etc which fits for most tasks..</p>
0
2009-01-05T12:19:03Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
Why does Ruby have Rails while Python has no central framework?
406,907
<p>This is a(n) historical question, not a comparison-between-languages question:</p> <p><a href="http://tomayko.com/writings/no-rails-for-python">This article from 2005</a> talks about the lack of a single, central framework for Python. For Ruby, this framework is clearly Rails. <strong>Why, historically speaking, di...
8
2009-01-02T14:26:57Z
2,864,532
<p>Check out this article on <a href="http://blog.ianbicking.org/what-really-makes-rails-work.html" rel="nofollow">why we'll never see Python-on-Rails</a>. The author gives some of the basic reasons why Python has never had <strong>and will never have</strong> a central framework. I might add, myself, that Java doesn't...
0
2010-05-19T10:09:31Z
[ "python", "ruby-on-rails", "ruby", "frameworks", "history" ]
How to intercept special (alt / ctrl) key press?
406,933
<p>How can I catch key combinations like <kbd>ALT</kbd>+<kbd>K</kbd> or <kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>H</kbd> in python <code>curses</code>?</p>
8
2009-01-02T14:34:45Z
407,022
<p>A terminal converts the control key in combination with a letter key to a normal ASCII code. This can be read from the <a href="http://www.opengroup.org/onlinepubs/007908799/xcurses/wgetch.html">getch</a>() function like any other key press.</p> <pre><code>CTRL-A: getch() returns 1 CTRL-B: getch() returns 2 ... CTR...
10
2009-01-02T15:09:56Z
[ "python", "curses" ]
PyQt: getting widgets to resize automatically in a QDialog
406,939
<p>I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself is resized.</p> <p>In the following program, the textarea resizes automatically if you resize the main window. However, the textarea within the dialog stays the same size when the dialog is resized.</p> <p>Is there any...
7
2009-01-02T14:39:30Z
406,982
<p>QMainWindow has special behavior for the central widget that a QDialog does not. To achieve the desired behavior you need to create a <a href="http://doc.trolltech.com/3.3/layout.html" rel="nofollow">layout</a>, add the text area to the layout and assign the layout to the dialog.</p>
3
2009-01-02T14:56:35Z
[ "python", "qt", "pyqt", "qdialog" ]
PyQt: getting widgets to resize automatically in a QDialog
406,939
<p>I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself is resized.</p> <p>In the following program, the textarea resizes automatically if you resize the main window. However, the textarea within the dialog stays the same size when the dialog is resized.</p> <p>Is there any...
7
2009-01-02T14:39:30Z
407,309
<p>I had looked at using a QLayout before but had no luck. I was trying to do something like</p> <pre><code>dialog.setLayout(some_layout) </code></pre> <p>but I couldn't get that approach to work so I gave up.</p> <p>My mistake was that I was trying to pass the layout to the dialog when I should have been passing t...
2
2009-01-02T16:21:56Z
[ "python", "qt", "pyqt", "qdialog" ]
PyQt: getting widgets to resize automatically in a QDialog
406,939
<p>I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself is resized.</p> <p>In the following program, the textarea resizes automatically if you resize the main window. However, the textarea within the dialog stays the same size when the dialog is resized.</p> <p>Is there any...
7
2009-01-02T14:39:30Z
4,453,751
<p>Check out <a href="https://sourceforge.net/projects/pyqtresize/" rel="nofollow">Python QT Automatic Widget Resizer</a> It's suppose to work well.</p>
1
2010-12-15T19:01:07Z
[ "python", "qt", "pyqt", "qdialog" ]
PyQt: getting widgets to resize automatically in a QDialog
406,939
<p>I'm having difficulty getting widgets in a QDialog resized automatically when the dialog itself is resized.</p> <p>In the following program, the textarea resizes automatically if you resize the main window. However, the textarea within the dialog stays the same size when the dialog is resized.</p> <p>Is there any...
7
2009-01-02T14:39:30Z
13,209,797
<p>Just to add a little note about this - I was trying to have a child window spawned from an application, which is a <code>QDialog</code>, containing a single <code>QTextEdit</code> as a child/content - and I wanted the <code>QTextEdit</code> to resize automatically whenever the <code>QDialog</code> window size change...
1
2012-11-03T13:52:18Z
[ "python", "qt", "pyqt", "qdialog" ]
How to synchronize the same object on client and server side in client-server application? Is small messages framework good for this job?
407,464
<p>I'm making a game engine in c++ and python. I'm using OGRE for 3D rendering, OpenAL for sound, ODE for physics, OIS for input, HawkNL for networking and boost.python for embedded python interpreter. Every subsystem (library) is wrapped by a class - manager and every manager is singleton. Now, I have a class - Object...
1
2009-01-02T17:22:29Z
407,478
<p>It sounds like you would be sending a lot of tiny messages. The UDP and IP headers will add 28 bytes of overhead (20 bytes for the IPv4 header or 40 for IPv6 plus 8 bytes for the UDP header). So, <strong>I would suggest combining multiple messages to be dispatched together at a perioidic rate.</strong></p> <p>You m...
7
2009-01-02T17:27:09Z
[ "c++", "python", "oop" ]
Python urllib2 file upload problems
407,468
<p>I'm currently trying to initiate a file upload with urllib2 and the <a href="http://fabien.seisen.org/python/urllib2_multipart.html" rel="nofollow">urllib2_file</a> library. Here's my code:</p> <pre><code>import sys import urllib2_file import urllib2 URL='http://aquate.us/upload.php' d = [('uploaded', open(sys.arg...
6
2009-01-02T17:23:55Z
407,545
<p>If you're using Python 2.5 or newer, <code>urllib2_file</code> is both unnecessary and unsupported, so check which version you're using (and perhaps upgrade).</p> <p>If you're using Python 2.3 or 2.4 (the only versions supported by <code>urllib2_file</code>), try running <a href="http://fabien.seisen.org/python/tes...
2
2009-01-02T17:52:22Z
[ "python", "post", "upload", "urllib2" ]
Python urllib2 file upload problems
407,468
<p>I'm currently trying to initiate a file upload with urllib2 and the <a href="http://fabien.seisen.org/python/urllib2_multipart.html" rel="nofollow">urllib2_file</a> library. Here's my code:</p> <pre><code>import sys import urllib2_file import urllib2 URL='http://aquate.us/upload.php' d = [('uploaded', open(sys.arg...
6
2009-01-02T17:23:55Z
407,557
<p>First, there's a third way to run Python programs.</p> <p>From cmd.exe, type <code>python myprogram.py</code>. You get a nice log. You don't have to type stuff one line at a time.</p> <p>Second, check the <a href="http://www.python.org/doc/2.5.2/lib/module-urllib2.html" rel="nofollow">urrlib2</a> documentation. ...
0
2009-01-02T17:56:42Z
[ "python", "post", "upload", "urllib2" ]
Python urllib2 file upload problems
407,468
<p>I'm currently trying to initiate a file upload with urllib2 and the <a href="http://fabien.seisen.org/python/urllib2_multipart.html" rel="nofollow">urllib2_file</a> library. Here's my code:</p> <pre><code>import sys import urllib2_file import urllib2 URL='http://aquate.us/upload.php' d = [('uploaded', open(sys.arg...
6
2009-01-02T17:23:55Z
4,019,389
<p>If you're still on Python2.5, what worked for me was to download the code here:</p> <p><a href="http://peerit.blogspot.com/2007/07/multipartposthandler-doesnt-work-for.html" rel="nofollow">http://peerit.blogspot.com/2007/07/multipartposthandler-doesnt-work-for.html</a></p> <p>and save it as MultipartPostHandler.py...
0
2010-10-25T22:29:34Z
[ "python", "post", "upload", "urllib2" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,619
<p>What version of Python are you using? First off, Python uses white space not semicolon's, so to start it should look something like this...</p> <pre><code> def bitsoncount(x): b=0 while(x &gt; 0): x &amp;= x - 1 b+=1 return b </code></pre>
4
2009-01-02T18:18:54Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,650
<p>The direct translation of your C algorithm is as follows:</p> <pre><code>def bitsoncount(x): b = 0 while x &gt; 0: x &amp;= x - 1 b += 1 return b </code></pre>
3
2009-01-02T18:31:19Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,672
<p>Maybe this is what you mean?</p> <pre><code>def bits_on_count(x): b = 0 while x != 0: if x &amp; 1: # Last bit is a 1 b += 1 x &gt;&gt;= 1 # Shift the bits of x right return b </code></pre> <p>There's also a way to do it simply in Python 3.0:</p> <pre><code>def bits_on_coun...
2
2009-01-02T18:40:29Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,674
<p>what you're looking for is called the <a href="http://en.wikipedia.org/wiki/Hamming_weight">Hamming Weight</a>.</p> <p>in python 2.6/3.0 it can be found rather easily with:</p> <pre><code>bits = sum( b == '1' for b in bin(x)[2:] ) </code></pre>
8
2009-01-02T18:42:26Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,736
<p>Try this module:</p> <pre><code>import sys if sys.maxint &lt; 2**32: msb2= 2**30 else: msb2= 2**62 BITS=[-msb2*2] # not converted into long while msb2: BITS.append(msb2) msb2 &gt;&gt;= 1 def bitcount(n): return sum(1 for b in BITS if b&amp;n) </code></pre> <p>This should work for machine integ...
0
2009-01-02T19:06:26Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
407,758
<p>Python 2.6 or 3.0:</p> <pre><code>def bitsoncount(x): return bin(x).count('1') </code></pre> <p>Example:</p> <pre><code>&gt;&gt;&gt; x = 123 &gt;&gt;&gt; bin(x) '0b1111011' &gt;&gt;&gt; bitsoncount(x) 6 </code></pre> <p>Or </p> <p><a href="http://stackoverflow.com/questions/109023/best-algorithm-to-count-t...
29
2009-01-02T19:12:55Z
[ "python", "bit-manipulation" ]
Python: Set Bits Count (popcount)
407,587
<p>Few blob's have been duplicated in my database(oracle 11g), performed XOR operations on the blob using UTL_RAW.BIT_XOR. After that i wanted to count the number of set bits in the binary string, so wrote the code above.</p> <p>During a small experiment, i wanted to see what is the hex and the integer value produced...
13
2009-01-02T18:09:07Z
1,040,157
<p>How do you like this one:</p> <pre><code>def bitsoncount(x): b = 0 bit = 1 while bit &lt;= x: b += int(x &amp; bit &gt; 0) bit = bit &lt;&lt; 1 return b </code></pre> <p>Basically, you use a test bit that starts right and gets shifted all the way through up to the bit length of y...
0
2009-06-24T18:41:03Z
[ "python", "bit-manipulation" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
407,755
<p>Um, <a href="http://docs.python.org/library/queue.html#Queue.PriorityQueue">Queue.PriorityQueue</a> ? Recall that Python isn't strongly typed, so you can save anything you like: just make a tuple of (priority,thing) and you're set.</p>
31
2009-01-02T19:11:31Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
407,759
<p>Did you look at the <a href="http://docs.python.org/_sources/library/heapq.txt" rel="nofollow">"Show Source" link</a> on the heapq page? There's an example a little less than halfway down of using a heap with a list of (int, char) tuples as a priority queue.</p>
7
2009-01-02T19:13:33Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
407,868
<p>I've not used it, but you could try <a href="http://hkn.eecs.berkeley.edu/~dyoo/python/">PyHeap</a>. It's written in C so hopefully it is fast enough for you. </p> <p>Are you positive heapq/PriorityQueue won't be fast enough? It might be worth going with one of them to start, and then profiling to see if it really ...
6
2009-01-02T19:57:30Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
407,922
<p>I ended up implementing a wrapper for <code>heapq</code>, adding a dict for maintaining the queue's elements unique. The result should be quite efficient for all operators:</p> <pre><code>class PriorityQueueSet(object): """ Combined priority queue and set data structure. Acts like a priority queue, ex...
16
2009-01-02T20:19:36Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
7,736,473
<p>You can use heapq for non-integer elements (tuples)</p> <pre><code>from heapq import * heap = [] data = [(10,"ten"), (3,"three"), (5,"five"), (7,"seven"), (9, "nine"), (2,"two")] for item in data: heappush(heap, item) sorted = [] while heap: sorted.append(heappop(heap)) print sorted data.sort() print data ...
5
2011-10-12T07:11:32Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
9,967,786
<p>This is efficient and works for strings or any type input as well -:)</p> <pre><code>pq = [] # list of entries arranged in a heap entry_finder = {} # mapping of tasks to entries REMOVED = '&lt;removed-task&gt;' # placeholder for a removed task counter = itertools.count() ...
1
2012-04-01T19:57:11Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
26,786,269
<p>I've got a priority queue / fibonacci heap at <a href="https://pypi.python.org/pypi/fibonacci-heap-mod" rel="nofollow">https://pypi.python.org/pypi/fibonacci-heap-mod</a></p> <p>It's not fast (large constant c on delete-min, which is O(c*logn)). But find-min, insert, decrease-key and merge are all O(1) - IOW, it's...
1
2014-11-06T18:01:32Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
34,863,948
<blockquote> <p>I can either use a <code>(priority, object)</code> as Charlie Martin suggests, or just implement <code>__cmp__</code> for my object.</p> </blockquote> <p>If you want inserted objects to be prioritized by a specific rule, I found it very helpful to write a simple subclass of <code>PriorityQueue</code>...
0
2016-01-18T20:57:50Z
[ "python", "queue" ]
A generic priority queue for Python
407,734
<p>I need to use a priority queue in my Python code. Looking around for something efficient, I came upon <a href="http://docs.python.org/library/heapq.html">heapq</a>. It looks good, but seems to be specified only for integers. I suppose it works with any objects that have comparison operators, but it doesn't specify w...
33
2009-01-02T19:05:54Z
37,008,050
<p>Another option for a priority queue which also supports decrease-key operation is <a href="https://github.com/DanielStutzbach/heapdict" rel="nofollow">this</a> implementation by Daniel Stutzbach worked perfectly for me with Python 3.5.</p> <pre><code>from heapdict import heapdict hd = heapdict() hd["two"] = 2 hd["...
-1
2016-05-03T15:18:23Z
[ "python", "queue" ]
Prevent Python subprocess from passing fds on Windows?
408,039
<p>Python's subprocess module by default passes all open file descriptors to any child processes it spawns. This means that if the parent process is listening on a port, and is killed, it cannot restart and begin listening again (even using SO_REUSEADDR) because the child is still in possession of that descriptor. I ...
1
2009-01-02T21:08:42Z
408,049
<p>I don't have a windows box around, so this is untested, but I'd be tempted to try the os.dup and os.dup2 methods; duplicate the file descriptors and use those instead of the parent ones.</p>
-2
2009-01-02T21:15:14Z
[ "python", "windows", "subprocess", "popen" ]
Prevent Python subprocess from passing fds on Windows?
408,039
<p>Python's subprocess module by default passes all open file descriptors to any child processes it spawns. This means that if the parent process is listening on a port, and is killed, it cannot restart and begin listening again (even using SO_REUSEADDR) because the child is still in possession of that descriptor. I ...
1
2009-01-02T21:08:42Z
408,270
<p>What seems to be the most relevant information that I can find: <a href="http://msdn.microsoft.com/en-us/library/ms724935%28VS.85%29.aspx" rel="nofollow">SetHandleInformation</a>, referenced in <a href="http://msdn.microsoft.com/en-us/library/ms682499%28VS.85%29.aspx" rel="nofollow">this</a> article, should give you...
2
2009-01-02T23:11:48Z
[ "python", "windows", "subprocess", "popen" ]
Python Outlook 2007 COM primer
408,046
<p>I've been inspired by <a href="http://stackoverflow.com/questions/405724/modifying-microsoft-outlook-contacts-from-python">Modifying Microsoft Outlook contacts from Python</a> -- I'm looking to try scripting some of my more annoying Outlook uses with the <code>win32com</code> package. I'm a Linux user trapped in a W...
8
2009-01-02T21:12:50Z
408,073
<p>To answer your question about documentation. Here are two links that I regularly visit when developing Outlook macros. While the sites are primarily focused on development with MS technologies most of the code can be pretty easily translated to python once you understand how to use COM.</p> <ul> <li><a href="http...
6
2009-01-02T21:26:31Z
[ "python", "com", "outlook", "outlook-2007" ]
Python Outlook 2007 COM primer
408,046
<p>I've been inspired by <a href="http://stackoverflow.com/questions/405724/modifying-microsoft-outlook-contacts-from-python">Modifying Microsoft Outlook contacts from Python</a> -- I'm looking to try scripting some of my more annoying Outlook uses with the <code>win32com</code> package. I'm a Linux user trapped in a W...
8
2009-01-02T21:12:50Z
408,117
<p>In general, older references to the object model are probably still valid given the attention Microsoft pays to backwards-compatability.</p> <p>As for whether or not you will be able to use win32com in python for Outlook, yes, you should be able to use that to make late-bound calls to the Outlook object model. Her...
6
2009-01-02T21:50:56Z
[ "python", "com", "outlook", "outlook-2007" ]
Python Outlook 2007 COM primer
408,046
<p>I've been inspired by <a href="http://stackoverflow.com/questions/405724/modifying-microsoft-outlook-contacts-from-python">Modifying Microsoft Outlook contacts from Python</a> -- I'm looking to try scripting some of my more annoying Outlook uses with the <code>win32com</code> package. I'm a Linux user trapped in a W...
8
2009-01-02T21:12:50Z
9,816,622
<p>This was my implementation from a couple years ago. I used it to automate the receiving and sending of email. Not sure if this will work with 2010. It depends on Redemption as well.</p> <pre><code>import win32com.client,os,re from utils.autoencode import autoencode generated='2D5E2D34-BED5-4B9F-9793-A31E26E6806Ex0...
1
2012-03-22T04:52:47Z
[ "python", "com", "outlook", "outlook-2007" ]
In Windows, how can I enumerate and get text from another window's controls?
408,334
<p>More particularly - I have a window handle of another running application. This application contains a <code>TListControl.UnicodeClass</code> control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from a...
1
2009-01-02T23:49:34Z
408,386
<p>You want EnumWindows and EnumChildWindows for the enumeration. See <a href="http://support.microsoft.com/kb/183009" rel="nofollow">here</a> for examples and usage info/warnings.</p> <p>For window text, once you have the appropriate HWND, you want <a href="http://msdn.microsoft.com/en-us/library/ms633520(VS.85).aspx...
4
2009-01-03T00:27:24Z
[ "python", "windows", "winapi", "controls" ]
In Windows, how can I enumerate and get text from another window's controls?
408,334
<p>More particularly - I have a window handle of another running application. This application contains a <code>TListControl.UnicodeClass</code> control somewhere (I know this from Winspector). How can I, using the Windows API and that window handle, go through all the items in that list control and get the text from a...
1
2009-01-02T23:49:34Z
409,110
<p>Above answers are completely wrong and don't even know what is a PAS. This has been answered hundreds of times for 20 years on Usenet. You must use IPC of course (RPM)</p> <p>ask on news://comp.os.ms-windows.programmer.win32 for code.</p>
2
2009-01-03T14:37:35Z
[ "python", "windows", "winapi", "controls" ]
How to produce a 303 Http Response in Django?
408,541
<p>Last couple of days we were discussing at <a href="http://stackoverflow.com/questions/401191/how-to-return-random-items-restfully">another question</a> the best to manage randomness in a RESTful way; today I went to play a little bit with some ideas in Django only to find that there is no easy standard way of return...
17
2009-01-03T03:20:07Z
408,549
<p>You could just override HttpResponse, like the other Responses do:</p> <pre><code>class HttpResponseSeeOther(HttpResponseRedirect): status_code = 303 return HttpResponseSeeOther('/other-url/') </code></pre>
23
2009-01-03T03:25:12Z
[ "python", "django", "http", "rest" ]
How to produce a 303 Http Response in Django?
408,541
<p>Last couple of days we were discussing at <a href="http://stackoverflow.com/questions/401191/how-to-return-random-items-restfully">another question</a> the best to manage randomness in a RESTful way; today I went to play a little bit with some ideas in Django only to find that there is no easy standard way of return...
17
2009-01-03T03:20:07Z
408,572
<p>The generic HttpResponse object lets you specify any status code you want:</p> <pre><code>response = HttpResponse(content="", status=303) response["Location"] = "http://example.com/redirect/here/" </code></pre> <p>If you need something re-usable then Gerald's answer is definitely valid; simply create your own Http...
19
2009-01-03T03:54:35Z
[ "python", "django", "http", "rest" ]
Convert CVS/SVN to a Programming Snippets Site
408,621
<p>I use cvs to maintain all my python snippets, notes, c, c++ code. As the hosting provider provides a public web- server also, I was thinking that I should convert the cvs automatically to a programming snippets website. </p> <ol> <li><a href="http://www.freebsd.org/projects/cvsweb.html" rel="nofollow">cvsweb</a> is...
2
2009-01-03T04:53:31Z
408,644
<p>Run <a href="http://trac.edgewall.org/" rel="nofollow">Trac</a> on the server linked to the (svn) repository. The Trac wiki can conveniently refer to files and changesets. You get TODO tickets, too.</p>
3
2009-01-03T05:14:15Z
[ "python", "svn", "web-applications", "rest", "cvs" ]
Convert CVS/SVN to a Programming Snippets Site
408,621
<p>I use cvs to maintain all my python snippets, notes, c, c++ code. As the hosting provider provides a public web- server also, I was thinking that I should convert the cvs automatically to a programming snippets website. </p> <ol> <li><a href="http://www.freebsd.org/projects/cvsweb.html" rel="nofollow">cvsweb</a> is...
2
2009-01-03T04:53:31Z
408,662
<p>enscript or pygmentize (part of pygments) can be used to convert code to HTML. You can use a custom header or footer to link to the actual code for download.</p>
1
2009-01-03T05:32:58Z
[ "python", "svn", "web-applications", "rest", "cvs" ]
Convert CVS/SVN to a Programming Snippets Site
408,621
<p>I use cvs to maintain all my python snippets, notes, c, c++ code. As the hosting provider provides a public web- server also, I was thinking that I should convert the cvs automatically to a programming snippets website. </p> <ol> <li><a href="http://www.freebsd.org/projects/cvsweb.html" rel="nofollow">cvsweb</a> is...
2
2009-01-03T04:53:31Z
430,829
<p>I finally settled for <a href="http://www.voidspace.org.uk/python/rest2web/" rel="nofollow">rest2web</a>. I had to do the following. </p> <ol> <li>Use a separate python script to recursively copy the files in the CVS to a separate directory.</li> <li>Added extra files index.txt and template.txt to all the directori...
0
2009-01-10T10:22:30Z
[ "python", "svn", "web-applications", "rest", "cvs" ]
Catch MainLoop exceptions and displaying them in MessageDialogs
408,810
<p>I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I've tried to make this work by wrapping my app.MainLoop() call in a try/except statement.</p> <p>The code below works for the init code in my MainWindow frame...
1
2009-01-03T09:22:50Z
409,266
<p>Don't know if this will work for a wxPython application, but in the sys module you can overwrite the excepthook attribute, which is a function called with 3 arguments, <code>(type, value, traceback)</code>, when an uncaugth exception is caught. You can install your own function in there that handles only the excepti...
2
2009-01-03T16:04:33Z
[ "python", "exception-handling", "wxpython", "wxwidgets" ]
Catch MainLoop exceptions and displaying them in MessageDialogs
408,810
<p>I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I've tried to make this work by wrapping my app.MainLoop() call in a try/except statement.</p> <p>The code below works for the init code in my MainWindow frame...
1
2009-01-03T09:22:50Z
409,537
<p>Perhaps <a href="http://stackoverflow.com/questions/166198/how-can-i-capture-all-exceptions-from-a-wxpython-application">this</a> question might be of some use, it tries to capture all exceptions.</p>
0
2009-01-03T18:24:54Z
[ "python", "exception-handling", "wxpython", "wxwidgets" ]
Catch MainLoop exceptions and displaying them in MessageDialogs
408,810
<p>I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I've tried to make this work by wrapping my app.MainLoop() call in a try/except statement.</p> <p>The code below works for the init code in my MainWindow frame...
1
2009-01-03T09:22:50Z
517,555
<p>I coded something like this for <a href="http://chandlerproject.org/" rel="nofollow">Chandler</a>, where any unhandled exceptions pop up a window with the stack and other info, and users can put in additional comments (what did they do when it happened etc.) and submit it for Chandler developers. A bit like the <a h...
1
2009-02-05T19:36:01Z
[ "python", "exception-handling", "wxpython", "wxwidgets" ]
Catch MainLoop exceptions and displaying them in MessageDialogs
408,810
<p>I have a wxPython application that relies on an external config file. I want provide friendly message dialogs that show up if there are any config errors. I've tried to make this work by wrapping my app.MainLoop() call in a try/except statement.</p> <p>The code below works for the init code in my MainWindow frame...
1
2009-01-03T09:22:50Z
12,109,646
<p>Posting the solution that worked for me with a very similar problem.</p> <pre><code>import wx import sys import traceback class Frame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None) panel = wx.Panel(self) m_close = wx.Button(panel, -1, "Error") m_close.Bind(wx.EVT_B...
0
2012-08-24T12:44:48Z
[ "python", "exception-handling", "wxpython", "wxwidgets" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
408,864
<p>You haven't stated weather you'd like to use SQL or if your reading the data into an application before doing so. From sounds of things your looking for a code based solution?</p> <p>In .NET you would make a class implement the ICompare interface and write your own method to to compare two values that would either ...
0
2009-01-03T10:30:03Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
408,875
<p>This is basic set theory. Intersect the two sets and if the result is the same as the original then the result is "match". Otherwise its not.</p> <p>You can apply this principle using many languages. Most have libraries for doing things with sets. You can even do this using SQL.</p>
0
2009-01-03T10:44:04Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
408,893
<p>Given that you are using PostgreSQL, you could use its <a href="http://www.postgresql.org/docs/8.2/static/functions-array.html" rel="nofollow">array</a> datatype and its contains/overlaps operators.</p> <p>Of course this would tie your app to PostgreSQL tightly, which may not be desired. On the other hand, it may s...
3
2009-01-03T10:54:49Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
408,944
<p>If I understood it right, its something like a:</p> <p><code>Post-&gt; posttags &lt;-tags</code></p> <p>kindof schema.</p> <p>I wonder why are you doing it this way? </p> <p>Is it a problem you have reached because you are using an ORM which retrieves data in objects and other lazy loaded associated objects.</p>...
1
2009-01-03T11:32:13Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
408,971
<p>Looks to me like the <code>issubset()</code> method of <a href="http://docs.python.org/library/sets.html" rel="nofollow">sets</a> is what you are looking for:</p> <pre><code>tags(1, 2, 3).issubset(q(1, 2, 3, 4)) </code></pre> <p>If both <code>tags</code> and <code>q</code> are subclasses of the <code>set</code> cl...
0
2009-01-03T12:13:02Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
409,607
<p>You're making a common mistake in database design, by storing a comma-separated list of tag id's. It's not a surprise that performing efficient queries against this is a blocker for you.</p> <p>What you need is to model the mapping between objects and tags in a separate table.</p> <pre><code>CREATE TABLE Tagged (...
3
2009-01-03T19:09:27Z
[ "python", "postgresql" ]
How to compare and search list of integers efficiently?
408,855
<p>I have a database populated with 1 million objects. Each object has a 'tags' field - set of integers.</p> <p>For example:</p> <pre><code>object1: tags(1,3,4) object2: tags(2) object3: tags(3,4) object4: tags(5) </code></pre> <p>and so on.</p> <p>Query parameter is a set on integers, lets try q(3,4,5)</p> <pre><...
4
2009-01-03T10:23:46Z
410,803
<p>I'm sorry. Looks like it was hard to me to explain the problem well :)</p> <p>The 'postgresql' tag here os lot more meaningful than 'python'. Self joined TAG table with IS NULL condition is what I really need.</p> <p>SQLalchemy is also good advise.</p> <p>Thank you all.</p>
0
2009-01-04T10:35:55Z
[ "python", "postgresql" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
408,889
<p>For simple cases pprint() and eval() come to mind.</p> <p>Using your example:</p> <pre><code>&gt;&gt;&gt; d = {'age': 27, ... 'name': 'Joe', ... 'numbers': [1, ... 2, ... 3, ... 4, ... 5], ... 'subdict': { ... 'first': 1, ... 'seco...
11
2009-01-03T10:52:05Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
408,912
<p>If its <strong>just</strong> Python list, dictionary and tuple object. - <strong>JSON</strong> is the way to go. Its human readable, very easy to handle and language independent too. </p> <p>Caution: Tuples will be converted to lists in simplejson.</p> <pre><code>In [109]: simplejson.loads(simplejson.dumps({'d':(1...
12
2009-01-03T11:04:55Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
408,915
<p>To use simplejson first <strong>easy_install simplejson</strong>:</p> <pre><code>import simplejson my_structure = {"name":"Joe", "age":27, "numbers":[1,2,3,4,5], "subdict":{"first":1, "second":2, "third": 3}} json = simplejson.dumps(my_structure) </code></pre> <p>results in json being:</p> <pre><code>{"age": 27, ...
2
2009-01-03T11:05:32Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
415,152
<p>If you're after more representations than are covered by JSON, I highly recommend checking out <a href="http://code.google.com/p/pyon/wiki/GettingStarted" rel="nofollow">PyON</a> (Python Object Notation)...although I believe it's restricted to 2.6/3.0 and above, as it relies on the <strong>ast</strong> module. It ha...
2
2009-01-06T01:50:05Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
2,350,046
<p>You should check out jsonpickle (http://code.google.com/p/jsonpickle/). It will write out any python object into a json file. You can then read that file back into a python object. The nice thing is the inbetween file is very readable because it's json.</p>
1
2010-02-28T04:05:10Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
29,450,743
<p>There is <a href="http://intellimath.bitbucket.org/axon" rel="nofollow">AXON</a> (textual) format that combine the <strong>best</strong> of JSON, XML and YAML. AXON format is quite readable and relatively compact.</p> <p>The python (2.7/3.3/3.4) module <a href="https://pypi.python.org/pypi/pyaxon" rel="nofollow">p...
-1
2015-04-04T19:46:32Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python human readable object serialization
408,866
<p>i need to store Python structures made of lists / dictionaries, tuples into a human readable format. The idea is like using something similar to <a href="http://docs.python.org/library/pickle.html">pickle</a>, but pickle is not human-friendly. Other options that come to my mind are <a href="http://en.wikipedia.org/w...
15
2009-01-03T10:30:40Z
29,450,916
<p>What do you mean this is not human-readable??? ;)</p> <pre><code>&gt;&gt;&gt; d = {'age': 27, ... 'name': 'Joe', ... 'numbers': [1,2,3,4,5], ... 'subdict': {'first':1, 'second':2, 'third':3} ... } &gt;&gt;&gt; &gt;&gt;&gt; import pickle &gt;&gt;&gt; p = pickle.dumps(d) &gt;&gt;&gt; p "(dp0\nS'age'\np1...
1
2015-04-04T20:06:59Z
[ "python", "json", "yaml", "serialization", "pickle" ]
Python mailbox encoding errors
409,217
<p>First, let me say that I'm a complete beginner at Python. I've never learned the language, I just thought "how hard can it be" when Google turned up nothing but Python snippets to solve my problem. :)</p> <p>I have a bunch of mailboxes in Maildir format (a backup from the mail server on my old web host), and I need...
6
2009-01-03T15:32:56Z
409,431
<p>Try it in Python 2.5 or 2.6 instead of 3.0. 3.0 has completely different Unicode handling and this module may not have been updated for 3.0. </p>
4
2009-01-03T17:32:09Z
[ "python", "encoding", "email-formats" ]
Python mailbox encoding errors
409,217
<p>First, let me say that I'm a complete beginner at Python. I've never learned the language, I just thought "how hard can it be" when Google turned up nothing but Python snippets to solve my problem. :)</p> <p>I have a bunch of mailboxes in Maildir format (a backup from the mail server on my old web host), and I need...
6
2009-01-03T15:32:56Z
409,486
<p>Note </p> <ol> <li><p>@Jimmy2Times could be very True in saying that this module may not be updated for 3.0.</p></li> <li><p>This is not an answer particularly rather a probable explanation of what is going on, why, how to reproduce it, other people can benefit from this. I am trying further to complete this answer...
4
2009-01-03T18:01:10Z
[ "python", "encoding", "email-formats" ]
Cocoa client/server application
409,354
<p>Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?</p> <p>I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The syste...
10
2009-01-03T16:57:11Z
409,446
<p>Generally, the ideas of all other client/server frameworks are applicable.</p> <p>Take a look at this link: <a href="http://developer.apple.com/internet/webservices/webservicescoreandcfnetwork.html" rel="nofollow">http://developer.apple.com/internet/webservices/webservicescoreandcfnetwork.html</a></p>
1
2009-01-03T17:39:43Z
[ "python", "cocoa", "web-services", "client-server", "pyobjc" ]
Cocoa client/server application
409,354
<p>Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?</p> <p>I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The syste...
10
2009-01-03T16:57:11Z
409,451
<p>Look at the api's for <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html" rel="nofollow">NSConnection</a> and <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSURLDownload_Class/Reference/Reference.h...
-1
2009-01-03T17:45:45Z
[ "python", "cocoa", "web-services", "client-server", "pyobjc" ]
Cocoa client/server application
409,354
<p>Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?</p> <p>I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The syste...
10
2009-01-03T16:57:11Z
409,806
<p>Cocoa has <a href="http://en.wikipedia.org/wiki/Portable_Distributed_Objects" rel="nofollow">Portable Distributed Objects</a>, which let you build a client / server application in pure Objective-C and Cocoa which can communicate across processes or across a network. </p> <p>Unfortunately it's one of the harder thin...
2
2009-01-03T20:48:13Z
[ "python", "cocoa", "web-services", "client-server", "pyobjc" ]
Cocoa client/server application
409,354
<p>Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?</p> <p>I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The syste...
10
2009-01-03T16:57:11Z
409,925
<p>If you have control of both the client and server, and you can limit the client to OS X only, I second Marc's answer. Cocoa's distributed objects are an amazing technology and make RPC-style client-server apps very easy.</p> <p>If the requirements above are too restrictive for you, you still have many options avail...
5
2009-01-03T21:51:49Z
[ "python", "cocoa", "web-services", "client-server", "pyobjc" ]
Cocoa client/server application
409,354
<p>Is there a way in Cocoa that is currently considered best practice for creating a multi-tier or client server application?</p> <p>I'm an experienced web developer and I really love Python. I'm new to Cocoa though. The application I'm toying with writing is a patient management system for a large hospital. The syste...
10
2009-01-03T16:57:11Z
829,539
<p>I have written a server and a client class for use in Cocoa. Using these classes makes it very easy to produce a server or client application without the knowledge about sockets and that C-stuff Just have a look at <a href="http://www.1-more-thing.de/code/simpleserver" rel="nofollow">my website</a> or at the <a href...
0
2009-05-06T13:25:52Z
[ "python", "cocoa", "web-services", "client-server", "pyobjc" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,394
<p>If I understand your question correctly, the following code should do the job:</p> <pre><code>l = [ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7',...
3
2009-01-03T17:17:32Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,416
<p>If you assigned it to var "a"...</p> <p>#1: </p> <pre><code>a.sort(lambda x,y: cmp(x[1], y[1])) </code></pre> <p>#2: </p> <pre><code>filter(lambda x: x[3]=="2somename", a) </code></pre>
5
2009-01-03T17:26:37Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,420
<blockquote> <p>Use a function to reorder the list so that I can group by each item in the list. For example I'd like to be able to group by the second column (so that all the 21's are together)</p> </blockquote> <p>Lists have a built in sort method and you can provide a function that extracts the sort key.</p> <pr...
1
2009-01-03T17:27:29Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,423
<p>For the first question, the first thing you should do is sort the list by the second field:</p> <pre><code>x = [ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:...
37
2009-01-03T17:29:07Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,442
<p>If you'll be doing a lot of sorting and filtering, you may like some helper functions.</p> <pre><code>m = [ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'],...
1
2009-01-03T17:37:59Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,478
<p>It looks a lot like you're trying to use a list as a database.</p> <p>Nowadays Python includes sqlite bindings in the core distribution. If you don't need persistence, it's really easy to create an in-memory sqlite database (see <a href="http://stackoverflow.com/questions/304393/how-do-i-create-a-sqllite3-in-memory...
1
2009-01-03T17:56:59Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,514
<p>For part (2), with x being your array, I think you want,</p> <pre><code>[y for y in x if y[3] == '2somename'] </code></pre> <p>Which will return a list of just your data lists that have a fourth value being '2somename'... Although it seems Kamil is giving you the best advice with going for SQL...</p>
2
2009-01-03T18:15:03Z
[ "python" ]
Sorting and Grouping Nested Lists in Python
409,370
<p>I have the following data structure (a list of lists)</p> <pre><code>[ ['4', '21', '1', '14', '2008-10-24 15:42:58'], ['3', '22', '4', '2somename', '2008-10-24 15:22:03'], ['5', '21', '3', '19', '2008-10-24 15:45:45'], ['6', '21', '1', '1somename', '2008-10-24 15:45:49'], ['7', '22', '3', '2somename', '200...
23
2009-01-03T17:05:30Z
409,684
<p>You're simply creating indexes on your structure, right?</p> <pre><code>&gt;&gt;&gt; from collections import defaultdict &gt;&gt;&gt; def indexOn( things, pos ): ... inx= defaultdict(list) ... for t in things: ... inx[t[pos]].append(t) ... return inx ... &gt;&gt;&gt; a=[ ... ['4', '21', '1...
1
2009-01-03T19:39:45Z
[ "python" ]
Loop function parameters for sanity check
409,449
<p>I have a Python function in which I am doing some sanitisation of the input parameters:</p> <pre><code>def func(param1, param2, param3): param1 = param1 or '' param2 = param2 or '' param3 = param3 or '' </code></pre> <p>This caters for the arguments being passed as <em>None</em> rather than empty strin...
3
2009-01-03T17:41:09Z
409,467
<pre><code>def func(x='', y='', z='hooray!'): print x, y, z In [2]: f('test') test hooray! In [3]: f('test', 'and') test and hooray! In [4]: f('test', 'and', 'done!') test and done! </code></pre>
-2
2009-01-03T17:51:38Z
[ "python", "function", "parameters", "arguments", "sanitization" ]
Loop function parameters for sanity check
409,449
<p>I have a Python function in which I am doing some sanitisation of the input parameters:</p> <pre><code>def func(param1, param2, param3): param1 = param1 or '' param2 = param2 or '' param3 = param3 or '' </code></pre> <p>This caters for the arguments being passed as <em>None</em> rather than empty strin...
3
2009-01-03T17:41:09Z
409,527
<p>You could do some list manipulation:</p> <pre><code>def func(param1, param2, param3): param1, param2, param3 = map(lambda x: x or '', (param1, param2, param3)) </code></pre> <p>but I'm not sure that's better than just writing out the nine lines, since once you get to nine parameters, that's a heinously long li...
2
2009-01-03T18:19:10Z
[ "python", "function", "parameters", "arguments", "sanitization" ]
Loop function parameters for sanity check
409,449
<p>I have a Python function in which I am doing some sanitisation of the input parameters:</p> <pre><code>def func(param1, param2, param3): param1 = param1 or '' param2 = param2 or '' param3 = param3 or '' </code></pre> <p>This caters for the arguments being passed as <em>None</em> rather than empty strin...
3
2009-01-03T17:41:09Z
409,564
<p>This looks like a good job for a decorator. How about this:</p> <pre><code>def sanitized(func): def sfunc(*args, **kwds): return func(*[arg or '' for arg in args], **dict((k, v or '') for k,v in kwds.iteritems())) sfunc.func_name = func.func_name sfunc.func_doc = func.func_do...
7
2009-01-03T18:43:01Z
[ "python", "function", "parameters", "arguments", "sanitization" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
409,538
<p>The clue is in the name - exceptions should be exceptional.</p> <p>If you always expect the item will exist then use <code>get</code>, but if you expect it not to exist a reasonable proportion of the time (i.e. it not existing is an expected result rather than an exceptional result) then I'd suggest using <code>fil...
5
2009-01-03T18:25:14Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
409,542
<p>The answer will depend on the intent of the code. (I'm not sure what your code sample was meant to do, the pass in the exceptional case is confusing, what will the rest of the code do with <code>object</code> variable to work with?)</p> <p>Whether to use exceptions or to use a method which treat the case as non-ex...
2
2009-01-03T18:26:10Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
409,545
<p>I agree with the other answer but I wanted to add that exception passing like this is going to give you a very noticeable performance hit. Highly recommended that you check to see if the result exists (if that's what filter does) instead of passing on exceptions.</p> <p><hr /></p> <p>Edit:</p> <p>In response to ...
3
2009-01-03T18:27:19Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
409,586
<p>Aversion to excpetions is a matter of opinion - however, if there's reason to believe that a function or method is going to be called many times or called rapidly, exceptions will cause a significant slowdown. I learned this from my <a href="http://stackoverflow.com/questions/395599/java-graphic-library-for-multico...
2
2009-01-03T18:57:31Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
409,704
<p>There's a big schism in programming languages around the use of exceptions.</p> <ul> <li><p>The majority view is that <strong>exceptions should be exceptional</strong>. In most languages with exceptions, transfer of control by exception is considerably more expensive than by procedure return, for example.</p></li>...
7
2009-01-03T19:52:37Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
410,115
<p>Believe it or not, this actually is an issue that is a bit different in each language. In Python, exceptions are regularly thrown for events that aren't exceptional by the language itself. Thus I think that the "you should only throw exceptions under exceptional circumstances" rule doesn't quite apply. I think th...
8
2009-01-03T23:57:18Z
[ "python", "django", "exception" ]
Avoid exceptions?
409,529
<p>This particular example relates to Django in Python, but should apply to any language supporting exceptions:</p> <pre><code>try: object = ModelClass.objects.get(search=value) except DoesNotExist: pass if object: # do stuff </code></pre> <p>The Django model class provides a simple method <em>get</em> w...
8
2009-01-03T18:19:50Z
411,070
<p>I disagree with the above comments that an exception is inefficient in this instance, especially since it's being used in an I/O bound operation.</p> <p>Here's a more realistic example using Django with an in-memory sqlite database. Each of a 100 different queries was run, then averaged for each of a 100 runs. Al...
2
2009-01-04T14:35:42Z
[ "python", "django", "exception" ]
What versions of Python and wxPython correspond to each version of OSX?
409,677
<p>I'd like to know what versions of Python and wxPython correspond to each version of OSX. I'm interested to know exactly how far back some of my apps will remain compatible on a mac before having to install newer versions of Python and wxPython.</p>
0
2009-01-03T19:37:41Z
409,702
<p>Tiger shipped with Python 2.3.5 and wxPython 2.5.3, Leopard ships with python 2.5.1 and wxPython 2.8.4.</p> <p>wxPython was not shipped with previous versions.</p> <hr> <p>OSX Lion has 2.7.1</p>
3
2009-01-03T19:49:20Z
[ "python", "osx", "wxpython", "compatibility" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
409,744
<p>If you only have one reference to the list, the following may be easier:</p> <pre><code>bool_list = [False] * len(bool_list) </code></pre> <p>This creates a new list populated with <code>False</code> elements.</p> <p>See my answer to <a href="http://stackoverflow.com/questions/369898/python-dictionary-clear#36992...
13
2009-01-03T20:13:14Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
409,745
<p>I wouldn't use the range and len. It's a lot cleaner to use enumerate()</p> <pre><code>for i, v in enumerate(bool_list): #i, v = index and value bool_list[i] = False </code></pre> <p>It's left with an unused variable in this case, but it still looks cleaner in my opinion. There's no noticeable change in perfor...
3
2009-01-03T20:13:52Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
409,746
<p>For value types such as int, bool and string, your 2nd example is about as pretty as its going to get. Your first example will work on any reference types like classes, dicts, or other lists.</p>
0
2009-01-03T20:14:17Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
409,759
<p>If you're willing to use <a href="http://numpy.scipy.org/" rel="nofollow">numpy</a> arrays, it's actually really easy to do things like this using array slices.</p> <pre><code>import numpy bool_list = numpy.zeros((100,), dtype=numpy.bool) # do something interesting with bool_list as if it were a normal list bool...
4
2009-01-03T20:26:03Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
409,764
<p>Here's another version:</p> <pre><code>bool_list = [False for item in bool_list] </code></pre>
13
2009-01-03T20:30:42Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
410,017
<p>I think </p> <pre><code>bool_list = [False for element in bool_list] </code></pre> <p>is as pythonic as it gets. Using lists like this should generaly be faster then a for loop in python too.</p>
0
2009-01-03T22:39:19Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
410,067
<pre><code>bool_list[:] = [False] * len(bool_list) </code></pre> <p>or</p> <pre><code>bool_list[:] = [False for item in bool_list] </code></pre>
11
2009-01-03T23:11:59Z
[ "python", "coding-style" ]
Python: Alter elements of a list
409,732
<p>I have a list of booleans where occasionally I reset them all to false. After first writing the reset as:</p> <pre><code>for b in bool_list: b = False </code></pre> <p>I found it doesn't work. I spent a moment scratching my head, then remembered that of course it won't work since I'm only changing a reference ...
15
2009-01-03T20:07:28Z
410,213
<p><strong>Summary</strong> Performance-wise, numpy or a list multiplication are clear winners, as they are 10-20x faster than other approaches.</p> <p>I did some performance testing on the various options proposed. I used Python 2.5.2, on Linux (Ubuntu 8.10), with a 1.5 Ghz Pentium M.</p> <p><strong>Original:</stron...
12
2009-01-04T01:09:25Z
[ "python", "coding-style" ]
Parsing fixed-format data embedded in HTML in python
409,769
<p>I am using google's appengine api</p> <pre><code>from google.appengine.api import urlfetch </code></pre> <p>to fetch a webpage. The result of</p> <pre><code>result = urlfetch.fetch("http://www.example.com/index.html") </code></pre> <p>is a string of the html content (in result.content). The problem is the data...
0
2009-01-03T20:32:20Z
409,780
<p>Only suggestion I can think of is to parse it as if it has fixed width columns. Newlines are not taken into consideration for HTML. </p> <p>If you have control of the source data, put it into a text file rather than HTML.</p>
2
2009-01-03T20:36:30Z
[ "python", "html", "google-app-engine", "parsing", "html-content-extraction" ]
Parsing fixed-format data embedded in HTML in python
409,769
<p>I am using google's appengine api</p> <pre><code>from google.appengine.api import urlfetch </code></pre> <p>to fetch a webpage. The result of</p> <pre><code>result = urlfetch.fetch("http://www.example.com/index.html") </code></pre> <p>is a string of the html content (in result.content). The problem is the data...
0
2009-01-03T20:32:20Z
409,844
<p>I understand that the format of the document is the one you have posted. In that case, I agree that a parser like <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> may not be a good solution.</p> <p>I assume that you are already getting the interesting data (between the BODY ...
2
2009-01-03T21:13:07Z
[ "python", "html", "google-app-engine", "parsing", "html-content-extraction" ]
Parsing fixed-format data embedded in HTML in python
409,769
<p>I am using google's appengine api</p> <pre><code>from google.appengine.api import urlfetch </code></pre> <p>to fetch a webpage. The result of</p> <pre><code>result = urlfetch.fetch("http://www.example.com/index.html") </code></pre> <p>is a string of the html content (in result.content). The problem is the data...
0
2009-01-03T20:32:20Z
410,142
<p>Once you have the body text as a single, long string, you can break it up as follows. This presumes that each record is 26 characters.</p> <pre><code>body= "AAA 123 888 2008-10-30 ABCBBB 987 2009-01-02 JSE...A4A 288 AAA" for i in range(0,len(body),26): line= body[i:i+26] # parse the line ...
1
2009-01-04T00:18:04Z
[ "python", "html", "google-app-engine", "parsing", "html-content-extraction" ]