title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
Regex for extraction in Python | 1,528,016 | <p>I have a string like this:</p>
<pre><code>"a word {{bla|123|456}} another {{bli|789|123}} some more text {{blu|789}} and more".
</code></pre>
<p>I would like to get this as an output:</p>
<pre><code>(("bla", 123, 456), ("bli", 789, 123), ("blu", 789))
</code></pre>
<p>I haven't been able to find the proper pytho... | 0 | 2009-10-06T20:45:35Z | 1,528,109 | <p>We might be able to get fancy and do everything in a single complicated regular expression, but that way lies madness. Let's do one regexp that grabs the groups, and then split the groups up. We could use a regexp to split the groups, but we can just use str.split(), so let's do that.</p>
<pre><code>import re
pat... | 0 | 2009-10-06T21:08:03Z | [
"python",
"regex"
] |
Regex for extraction in Python | 1,528,016 | <p>I have a string like this:</p>
<pre><code>"a word {{bla|123|456}} another {{bli|789|123}} some more text {{blu|789}} and more".
</code></pre>
<p>I would like to get this as an output:</p>
<pre><code>(("bla", 123, 456), ("bli", 789, 123), ("blu", 789))
</code></pre>
<p>I haven't been able to find the proper pytho... | 0 | 2009-10-06T20:45:35Z | 1,528,137 | <p>Assuming your actual format is <code>{{[a-z]+|[0-9]+|[0-9]+}}</code>, here's a complete program with conversion to ints.</p>
<pre><code>import re
s = "a word {{bla|123|456}} another {{bli|789|123}} some more text {{blu|789}} and more"
result = []
for match in re.finditer('{{.*?}}', s):
# Split on pipe (|) and... | 0 | 2009-10-06T21:14:40Z | [
"python",
"regex"
] |
Regex for extraction in Python | 1,528,016 | <p>I have a string like this:</p>
<pre><code>"a word {{bla|123|456}} another {{bli|789|123}} some more text {{blu|789}} and more".
</code></pre>
<p>I would like to get this as an output:</p>
<pre><code>(("bla", 123, 456), ("bli", 789, 123), ("blu", 789))
</code></pre>
<p>I haven't been able to find the proper pytho... | 0 | 2009-10-06T20:45:35Z | 1,528,581 | <p>Is pyparsing overkill for this? Maybe, but without too much suffering, it <em>does</em> deliver the desired output, without a thicket of backslashes to escape the '{', '|', or '}' characters. Plus, there's no need for post-parse conversions of integers and whatnot - the parse actions take care of this kind of stu... | 0 | 2009-10-06T23:09:24Z | [
"python",
"regex"
] |
How can I handle exceptions in a list comprehension in Python? | 1,528,237 | <p>I have some a list comprehension in Python in which each iteration can throw an exception. </p>
<p><strong>For instance</strong>, if I have:</p>
<pre><code>eggs = (1,3,0,3,2)
[1/egg for egg in eggs]
</code></pre>
<p>I'll get a <code>ZeroDivisionError</code> exception in the 3rd element.</p>
<p>How can I handle... | 35 | 2009-10-06T21:36:06Z | 1,528,244 | <p>You can use</p>
<pre><code>[1/egg for egg in eggs if egg != 0]
</code></pre>
<p>this will simply skip elements that are zero.</p>
| 17 | 2009-10-06T21:38:18Z | [
"python",
"exception-handling",
"list-comprehension"
] |
How can I handle exceptions in a list comprehension in Python? | 1,528,237 | <p>I have some a list comprehension in Python in which each iteration can throw an exception. </p>
<p><strong>For instance</strong>, if I have:</p>
<pre><code>eggs = (1,3,0,3,2)
[1/egg for egg in eggs]
</code></pre>
<p>I'll get a <code>ZeroDivisionError</code> exception in the 3rd element.</p>
<p>How can I handle... | 35 | 2009-10-06T21:36:06Z | 1,528,286 | <p>No there's not a better way. In a lot of cases you can use avoidance like Peter does</p>
<p>Your other option is to not use comprehensions</p>
<pre><code>eggs = (1,3,0,3,2)
result=[]
for egg in eggs:
try:
result.append(egg/0)
except ZeroDivisionError:
# handle division by zero error
... | 6 | 2009-10-06T21:50:01Z | [
"python",
"exception-handling",
"list-comprehension"
] |
How can I handle exceptions in a list comprehension in Python? | 1,528,237 | <p>I have some a list comprehension in Python in which each iteration can throw an exception. </p>
<p><strong>For instance</strong>, if I have:</p>
<pre><code>eggs = (1,3,0,3,2)
[1/egg for egg in eggs]
</code></pre>
<p>I'll get a <code>ZeroDivisionError</code> exception in the 3rd element.</p>
<p>How can I handle... | 35 | 2009-10-06T21:36:06Z | 1,528,375 | <p>There is no built-in expression in Python that lets you ignore an exception (or return alternate values &c in case of exceptions), so it's impossible, literally speaking, to "handle exceptions in a list comprehension" because a list comprehension is an expression containing other expression, nothing more (i.e., ... | 38 | 2009-10-06T22:10:27Z | [
"python",
"exception-handling",
"list-comprehension"
] |
How can I handle exceptions in a list comprehension in Python? | 1,528,237 | <p>I have some a list comprehension in Python in which each iteration can throw an exception. </p>
<p><strong>For instance</strong>, if I have:</p>
<pre><code>eggs = (1,3,0,3,2)
[1/egg for egg in eggs]
</code></pre>
<p>I'll get a <code>ZeroDivisionError</code> exception in the 3rd element.</p>
<p>How can I handle... | 35 | 2009-10-06T21:36:06Z | 8,915,613 | <p>I realize this question is quite old, but you can also create a general function to make this kind of thing easier:</p>
<pre><code>def catch(func, handle=lambda e : e, *args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
return handle(e)
</code></pre>
<p>Then, in your ... | 30 | 2012-01-18T18:48:01Z | [
"python",
"exception-handling",
"list-comprehension"
] |
Does Python have a "compile only" switch like Perl's -c? | 1,528,346 | <p>Perl has the <code>-c</code> switch to compile the code without running it. This is convenient for debugging compile errors in Perl.</p>
<p>Does Python have a similar switch?</p>
| 13 | 2009-10-06T22:03:19Z | 1,528,351 | <p>You can say</p>
<pre><code>python -m py_compile script_to_check.py
</code></pre>
<p>However, this will have the side effect of creating a compiled <code>script_to_check.pyc</code> file in the same directory as your script. This feature is designed to speed up later uses of a module rather than to make sure that y... | 15 | 2009-10-06T22:05:11Z | [
"python",
"compiler-construction"
] |
Does Python have a "compile only" switch like Perl's -c? | 1,528,346 | <p>Perl has the <code>-c</code> switch to compile the code without running it. This is convenient for debugging compile errors in Perl.</p>
<p>Does Python have a similar switch?</p>
| 13 | 2009-10-06T22:03:19Z | 1,528,362 | <p>Through 2.6, there's <a href="http://docs.python.org/library/compiler.html" rel="nofollow">the compiler package</a>. That page doesn't say if there is a replacement in 3.0, or if you just can't do that any more.</p>
| 0 | 2009-10-06T22:08:22Z | [
"python",
"compiler-construction"
] |
Does Python have a "compile only" switch like Perl's -c? | 1,528,346 | <p>Perl has the <code>-c</code> switch to compile the code without running it. This is convenient for debugging compile errors in Perl.</p>
<p>Does Python have a similar switch?</p>
| 13 | 2009-10-06T22:03:19Z | 1,528,456 | <p>Even better is to run <a href="http://divmod.org/trac/wiki/DivmodPyflakes">pyflakes</a>, <a href="http://pychecker.sourceforge.net/">pychecker</a> or maybe <a href="http://www.logilab.org/857">pylint</a> at the code. They catch some common errors that compiling won't.</p>
| 8 | 2009-10-06T22:36:35Z | [
"python",
"compiler-construction"
] |
Why can't I save an object in Django? | 1,528,656 | <pre><code>thechan = Score.objects.filter(content=44)[0:1]
thechan[0].custom_score = 2
thechan[0].save()
</code></pre>
<p>I do print statements, and it shows everything fine. However, it's not SAVING!</p>
<p>I go into my database, and I run a simple SELECT statement..and it's not changed!</p>
<pre><code>select custo... | 1 | 2009-10-06T23:29:48Z | 1,528,712 | <p>Fixed.</p>
<pre><code>thechan = Score.objects.get(content=44)
thechan.custom_score = 2
thechan.save()
</code></pre>
| 0 | 2009-10-06T23:42:16Z | [
"python",
"django",
"frameworks"
] |
Why can't I save an object in Django? | 1,528,656 | <pre><code>thechan = Score.objects.filter(content=44)[0:1]
thechan[0].custom_score = 2
thechan[0].save()
</code></pre>
<p>I do print statements, and it shows everything fine. However, it's not SAVING!</p>
<p>I go into my database, and I run a simple SELECT statement..and it's not changed!</p>
<pre><code>select custo... | 1 | 2009-10-06T23:29:48Z | 1,528,801 | <p>What's going on here is that Score.objects.filter() doesn't return a regular list, but a <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/">QuerySet</a>. QuerySets behave like lists in some ways, but every time you slice one you get a new QuerySet instance, and everytime you index into one, you ge... | 11 | 2009-10-07T00:05:45Z | [
"python",
"django",
"frameworks"
] |
Idiomatic way to do list/dict in Cython? | 1,528,691 | <p>My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. </p>
<p>I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use ... | 32 | 2009-10-06T23:37:44Z | 1,547,009 | <p>You can take a look at the standard <a href="http://docs.python.org/library/array.html" rel="nofollow"><code>array</code></a> module for Python if this is appropriate for your Cython setting. I'm not sure since I have never used Cython.</p>
| 2 | 2009-10-10T03:57:11Z | [
"c++",
"python",
"c",
"cython"
] |
Idiomatic way to do list/dict in Cython? | 1,528,691 | <p>My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. </p>
<p>I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use ... | 32 | 2009-10-06T23:37:44Z | 1,547,069 | <p>There is no way to get native Python lists/dicts up to the speed of a C++ map/vector or even anywhere close. It has nothing to do with allocation or type declaration but rather paying the interpreter overhead. The example you mention (numpy) is a C extension and is written in C for precisely this reason. </p>
| 1 | 2009-10-10T04:38:32Z | [
"c++",
"python",
"c",
"cython"
] |
Idiomatic way to do list/dict in Cython? | 1,528,691 | <p>My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. </p>
<p>I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use ... | 32 | 2009-10-06T23:37:44Z | 2,699,569 | <p>Doing similar operations in Python as in C++ can often be slower. <code>list</code> and <code>dict</code> are actually implemented very well, but you gain a lot of overhead using Python objects, which are more abstract than C++ objects and require a lot more lookup at runtime.</p>
<p>Incidentally, <code>std::vector... | 24 | 2010-04-23T14:58:39Z | [
"c++",
"python",
"c",
"cython"
] |
Idiomatic way to do list/dict in Cython? | 1,528,691 | <p>My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. </p>
<p>I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use ... | 32 | 2009-10-06T23:37:44Z | 6,139,683 | <p>C++ is fast not just because of the static declarations of the vector and the elements that go into it, but crucially because using templates/generics one specifies that the vector will <em>only</em> contain elements of a certain type, e.g. vector with tuples of three elements. Cython can't do this last thing and it... | 7 | 2011-05-26T13:55:00Z | [
"c++",
"python",
"c",
"cython"
] |
Idiomatic way to do list/dict in Cython? | 1,528,691 | <p>My problem: I've found that processing large data sets with raw C++ using the STL map and vector can often be considerably faster (and with lower memory footprint) than using Cython. </p>
<p>I figure that part of this speed penalty is due to using Python lists and dicts, and that there might be some tricks to use ... | 32 | 2009-10-06T23:37:44Z | 8,508,658 | <p>Cython now has template support, and comes with declarations for some of the STL containers.</p>
<p>See <a href="http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#standard-library">http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html#standard-library</a></p>
<p>Here's the example they give:</p>
... | 23 | 2011-12-14T17:09:26Z | [
"c++",
"python",
"c",
"cython"
] |
reading lines 2 at a time | 1,528,711 | <p>Is there a better way to read lines two at a time from a file in python than:</p>
<pre><code>with open(fn) as f:
for line in f:
try:
line2 = f.next()
except StopIteration:
line2 = ''
print line, line2 # or something more interesting
</code></pre>
<p>I'm in 2.5.4.... | 10 | 2009-10-06T23:42:02Z | 1,528,769 | <pre><code>import itertools
with open(fn) as f:
for line, line2 in itertools.izip_longest(f, f, fillvalue=''):
print line, line2
</code></pre>
<p>Alas, <code>izip_longest</code> requires Python 2.6 or better; 2.5 only has <code>izip</code>, which would truncate the last line if <code>f</code> has an odd number ... | 14 | 2009-10-06T23:57:23Z | [
"python"
] |
reading lines 2 at a time | 1,528,711 | <p>Is there a better way to read lines two at a time from a file in python than:</p>
<pre><code>with open(fn) as f:
for line in f:
try:
line2 = f.next()
except StopIteration:
line2 = ''
print line, line2 # or something more interesting
</code></pre>
<p>I'm in 2.5.4.... | 10 | 2009-10-06T23:42:02Z | 1,528,846 | <p>for small to medium sized files, </p>
<pre><code>>>> data=open("file").readlines()
>>> for num,line in enumerate(data[::2]):
... print ''.join(data[num:num+2])
</code></pre>
| 1 | 2009-10-07T00:16:27Z | [
"python"
] |
reading lines 2 at a time | 1,528,711 | <p>Is there a better way to read lines two at a time from a file in python than:</p>
<pre><code>with open(fn) as f:
for line in f:
try:
line2 = f.next()
except StopIteration:
line2 = ''
print line, line2 # or something more interesting
</code></pre>
<p>I'm in 2.5.4.... | 10 | 2009-10-06T23:42:02Z | 1,528,856 | <p>You could possibly make it more clear with a generator:</p>
<pre><code>def read2(f):
for line in f:
try:
line2 = f.next()
except StopIteration:
line2 = ''
yield line, line2
with open(fn) as f:
for line1, line2 in read2(f):
print line1
print l... | 2 | 2009-10-07T00:18:53Z | [
"python"
] |
How to write an empty indentation block in Python? | 1,528,903 | <p>The runtime keeps telling me:</p>
<blockquote>
<p>expected an indented block</p>
</blockquote>
<p>But I don't want write nothing inside my except block, I just want it to catch and swallow the exception.</p>
| 24 | 2009-10-07T00:34:09Z | 1,528,905 | <p>Just write</p>
<pre><code>pass
</code></pre>
<p>as in</p>
<pre><code>try:
# Do something illegal.
...
except:
# Pretend nothing happened.
pass
</code></pre>
<p>EDIT: @swillden brings up a good point, viz., this is a terrible idea in general. You should, at the least, say</p>
<pre><code>except Ty... | 64 | 2009-10-07T00:34:35Z | [
"python",
"syntax",
"try-catch",
"indentation"
] |
How to write an empty indentation block in Python? | 1,528,903 | <p>The runtime keeps telling me:</p>
<blockquote>
<p>expected an indented block</p>
</blockquote>
<p>But I don't want write nothing inside my except block, I just want it to catch and swallow the exception.</p>
| 24 | 2009-10-07T00:34:09Z | 1,529,193 | <p>I've never done this in more permanent code, but I frequently do it as a placeholder</p>
<pre><code>if some_expression:
True
else:
do_something(blah)
</code></pre>
<p>Just sticking a True in there will stop the error. Not sure if there's anything bad about this.</p>
| 0 | 2009-10-07T02:27:33Z | [
"python",
"syntax",
"try-catch",
"indentation"
] |
Using callback function in pyevent | 1,528,915 | <p>I want to detect pressing the "snapshot" button on the top of a webcam in linux. The button has this entry in /dev:
/dev/input/by-id/usb-PixArt_Imaging_Inc._USB2.0_UVC_VGA-event-if00</p>
<p>I am using the "rel" wrapper, at the moment, because it handles exceptions better. Before the following code executes, self... | 0 | 2009-10-07T00:37:43Z | 1,531,141 | <p>Never used <code>pyevent</code>, but would try rescheduling the event at the end of the handler:</p>
<pre><code>def snap(self):
# ... code ...
rel.read(self.s.cam_btn, self.snap)
return False
</code></pre>
| 0 | 2009-10-07T11:48:56Z | [
"python"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,528,939 | <p>I don't know if there's a built-in way to do it, but you can always define a class like this:</p>
<pre><code>class InlineClass(object):
def __init__(self, dict):
self.__dict__ = dict
obj = InlineClass({'propertyName' : 'propertyValue'})
</code></pre>
| 10 | 2009-10-07T00:47:01Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,528,978 | <p>I like <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/1528939#1528939">Smashery's</a> idea, but Python seems content to let you modify classes on your own:</p>
<pre><code>>>> class Inline(object):
... pass
...
>>> obj = Inline()
>&... | 4 | 2009-10-07T01:00:48Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,528,993 | <pre><code>obj = type('obj', (object,), {'propertyName' : 'propertyValue'})
</code></pre>
<p>there are <a href="http://docs.python.org//library/functions.html#type">two kinds of <code>type</code> function uses</a>.</p>
| 47 | 2009-10-07T01:04:15Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,529,041 | <p>Peter's answer</p>
<pre><code>obj = lambda: None
obj.propertyName = 'propertyValue'
</code></pre>
| 12 | 2009-10-07T01:23:07Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,529,145 | <pre><code>class test:
def __setattr__(self,key,value):
return value
myObj = test()
myObj.mykey = 'abc' # set your property and value
</code></pre>
| 0 | 2009-10-07T02:04:35Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 1,529,890 | <p>It is easy in Python to declare a class with an <code>__init__()</code> function that can set up the instance for you, with optional arguments. If you don't specify the arguments you get a blank instance, and if you specify some or all of the arguments you initialize the instance.</p>
<p>I explained it <a href="ht... | 2 | 2009-10-07T06:39:34Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 27,931,360 | <p>Python 3.3 added the <a href="https://docs.python.org/3.3/library/types.html#types.SimpleNamespace" rel="nofollow"><code>SimpleNamespace</code></a> class for that exact purpose:</p>
<pre><code>>>> from types import SimpleNamespace
>>> obj = SimpleNamespace(propertyName='propertyValue')
>>&g... | 2 | 2015-01-13T20:58:16Z | [
"python",
"instantiation",
"dynamic-languages"
] |
How to create inline objects with properties in Python? | 1,528,932 | <p>In Javascript it would be:</p>
<pre><code>var newObject = { 'propertyName' : 'propertyValue' };
</code></pre>
<p>How to do it in Python?</p>
| 23 | 2009-10-07T00:43:55Z | 37,155,671 | <p>Another viable option is to use <a href="https://docs.python.org/2/library/collections.html#collections.namedtuple" rel="nofollow">namedtuple</a>:</p>
<pre><code>from collections import namedtuple
message = namedtuple('Message', ['propertyName'], verbose=True)
messages = [
message('propertyValueOne'),
mess... | 0 | 2016-05-11T07:19:13Z | [
"python",
"instantiation",
"dynamic-languages"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 1,529,187 | <p><code>itertools</code> does much more than <em>just</em> combinations and permutations, so (while it would surely be nice to have all of <code>itertools</code> when coding Java;-) you can get away with much less.</p>
<p>For example, for permutations, see <a href="https://web.archive.org/web/20120217153017/http://ww... | 3 | 2009-10-07T02:26:21Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 2,044,586 | <p>Cartesian product is available here:
<a href="http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Sets.html#cartesianProduct%28java.util.Set...%29">http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/collect/Sets.html#cartesianProduct%28java.util.Set...%29</a></p>
| 5 | 2010-01-11T20:09:41Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 4,616,789 | <p>Here you find something that might cover your combinatorial needs bundled in a library:</p>
<p><a href="http://code.google.com/p/combinatoricslib/" rel="nofollow">http://code.google.com/p/combinatoricslib/</a></p>
| 2 | 2011-01-06T15:53:08Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 5,767,853 | <p>I'm actually making a port of itertools to java: it's called <a href="http://code.google.com/p/neoitertools/">neoitertools</a></p>
<p>Any feedback appreciated as it still in beta. Missing the "product" function yet, and some intensive tests.</p>
| 10 | 2011-04-24T00:22:34Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 9,474,013 | <p>I'm just throwing this out there, but shouldn't it be possible to use Python's itertools implementation directly from Java using Jython? Is it a C-based api?</p>
<p>[one Google later]</p>
<p><a href="http://www.jython.org/javadoc/org/python/modules/itertools.html" rel="nofollow">itertools (Jython API documentation... | 1 | 2012-02-27T23:25:41Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Is there an equivalent of Python's itertools for Java? | 1,528,966 | <p>I'm searching for a library (preferably generic) that generates iterable combinations and permutations of data contained in collections. Cartesian product would also be nice.</p>
<p>The best way of describing what I want would be "itertools for Java".</p>
| 14 | 2009-10-07T00:57:24Z | 39,439,426 | <p>Few years later, <a href="https://github.com/dpaukov/combinatoricslib" rel="nofollow">combinatorics</a> seems to fit your needs. Taken from the readme:</p>
<pre><code>Simple permutations
Permutations with repetitions
Simple combinations
Combinations with repetitions
Subsets
Integer Partitions
List Partitions
Intege... | 0 | 2016-09-11T18:41:27Z | [
"java",
"python",
"combinatorics",
"itertools"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 1,529,012 | <p>This is (IMO) one of the fundamental limitations with Python - you can't re-open classes. I believe the actual problem, though, is caused by the fact that classes implemented in C can't be modified at runtime... subclasses can, but not the base classes.</p>
| 0 | 2009-10-07T01:12:03Z | [
"python",
"attributes",
"language-design"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 1,529,027 | <p>It's because object is a "type", not a class. In general, all classes that are defined in C extensions (like all the built in datatypes, and stuff like numpy arrays) do not allow addition of arbitrary attributes.</p>
| 1 | 2009-10-07T01:16:32Z | [
"python",
"attributes",
"language-design"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 1,529,029 | <p>So, investigating my own question, I discovered this about the Python language: you can inherit from things like int, and you see the same behaviour:</p>
<pre><code>>>> class MyInt(int):
pass
>>> x = MyInt()
>>> print x
0
>>> x.hello = 4
>>> print x.hello
4
>&... | 1 | 2009-10-07T01:16:57Z | [
"python",
"attributes",
"language-design"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 1,529,099 | <p>An instance of <code>object</code> does <strong>not</strong> carry around a <code>__dict__</code> -- if it did, before the horrible circular dependence problem (since <code>dict</code>, like most everything else, inherits from <code>object</code>;-), this would saddle <em>every</em> object in Python with a dict, whi... | 88 | 2009-10-07T01:47:26Z | [
"python",
"attributes",
"language-design"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 1,529,237 | <p>It is simply due to optimization.</p>
<p>Dicts are relatively large.</p>
<pre><code>>>> import sys
>>> sys.getsizeof((lambda:1).__dict__)
140
</code></pre>
<p>Most (maybe all) classes that are defined in C do not have a dict for optimization.</p>
<p>If you look at the <a href="http://svn.python... | 5 | 2009-10-07T02:45:56Z | [
"python",
"attributes",
"language-design"
] |
Can't set attributes of object class | 1,529,002 | <p>So, I was playing around with Python while answering <a href="http://stackoverflow.com/questions/1528932/how-to-create-inline-objects-with-properties-in-python/">this question</a>, and I discovered that this is not valid:</p>
<pre><code>o = object()
o.attr = 'hello'
</code></pre>
<p>due to an <code>AttributeError:... | 53 | 2009-10-07T01:07:55Z | 22,966,774 | <p>As other answerers have said, an <code>object</code> does not have a <code>__dict__</code>. <code>object</code> is the base class of <strong>all</strong> types, including <code>int</code> or <code>str</code>. Thus whatever is provided by <code>object</code> will be a burden to them as well. Even something as simple ... | 15 | 2014-04-09T15:09:53Z | [
"python",
"attributes",
"language-design"
] |
Can a WIN32 program authenticate into Django authentication system, using MYSQL? | 1,529,128 | <p>I have a web service with Django Framework.<br />
My friend's project is a WIN32 program and also a MS-sql server.</p>
<p>The Win32 program currently has a login system that talks to a MS-sql for authentication.</p>
<p>However, we would like to INTEGRATE this login system as one.</p>
<p>Please answer the 2 things... | 1 | 2009-10-07T01:59:57Z | 1,529,146 | <p>If the only thing the WIN32 app uses the MS-SQL Server for is Authentication/Authorization then you could write a new Authentication/Authorization provider that uses a set of Web Services (that you would have to create) that expose the Django provider.</p>
| 0 | 2009-10-07T02:05:25Z | [
"python",
"windows",
"django",
"authentication",
"frameworks"
] |
Can a WIN32 program authenticate into Django authentication system, using MYSQL? | 1,529,128 | <p>I have a web service with Django Framework.<br />
My friend's project is a WIN32 program and also a MS-sql server.</p>
<p>The Win32 program currently has a login system that talks to a MS-sql for authentication.</p>
<p>However, we would like to INTEGRATE this login system as one.</p>
<p>Please answer the 2 things... | 1 | 2009-10-07T01:59:57Z | 1,529,161 | <p>Either provide a view where your win32 client can post to the django server and get a response that means "good login" or "bad login". This will require you to modify the win32 client and create a very simple django view.</p>
<p>Or provide your own <a href="http://docs.djangoproject.com/en/dev/topics/auth/#specifyi... | 2 | 2009-10-07T02:17:34Z | [
"python",
"windows",
"django",
"authentication",
"frameworks"
] |
why is urllib2 missing table fields which I can see in the Firefox source? | 1,529,234 | <p>the html that I am receiving from urllib2 is missing dozens of fields of data that I can see when I view the source of the URL in Firefox. Any advice would be much appreciated. Here is what it looks like: </p>
<p>from FireFox view source: </p>
<pre><code># ...<td class=td6>as</td></tr></thead&... | 0 | 2009-10-07T02:45:32Z | 1,529,364 | <p>It seems from a cursory check that the page you're getting has a <strong>lot</strong> of Javascript; perhaps that Javascript cooperates in building the information that you see at the end in Firefox (at least some of it is actively altering the page's contents). If you need to scrape JS-rich pages, your best bet is... | 2 | 2009-10-07T03:43:09Z | [
"python",
"html",
"field",
"urllib2"
] |
why is urllib2 missing table fields which I can see in the Firefox source? | 1,529,234 | <p>the html that I am receiving from urllib2 is missing dozens of fields of data that I can see when I view the source of the URL in Firefox. Any advice would be much appreciated. Here is what it looks like: </p>
<p>from FireFox view source: </p>
<pre><code># ...<td class=td6>as</td></tr></thead&... | 0 | 2009-10-07T02:45:32Z | 1,529,381 | <p>The extra content you're seeing is generated by JavaScript. It is not part of the raw HTML document, and hence won't be present with a plain HTTP fetcher such as urllib2.</p>
| 0 | 2009-10-07T03:48:52Z | [
"python",
"html",
"field",
"urllib2"
] |
Help to solve my problems with python LIST? | 1,529,307 | <pre><code>author_A = [['book_x',1,10],['book_y',2,20],['book_z',3,30]]
author_B = [['book_s',5,10],['book_t',2,20],['book_z',3,30]]
author_A AND author_B = ['book_z',3,30]
author_A = [['book_x',1,10],['book_y',2,20]]
author_B = [['book_s',5,10],['book_t',2,20]]
-----------------... | 0 | 2009-10-07T03:15:20Z | 1,529,346 | <p>You can find the intersections and exclusive ones like this...</p>
<pre><code>A_and_B = [a for a in author_A if a in author_B]
only_A = [a for a in author_A if a not in author_B]
only_B = [b for b in author_B if b not in author_A]
</code></pre>
<p>then it is only a matter of printing them...</p>
<pre><code>print ... | 1 | 2009-10-07T03:36:19Z | [
"python"
] |
Help to solve my problems with python LIST? | 1,529,307 | <pre><code>author_A = [['book_x',1,10],['book_y',2,20],['book_z',3,30]]
author_B = [['book_s',5,10],['book_t',2,20],['book_z',3,30]]
author_A AND author_B = ['book_z',3,30]
author_A = [['book_x',1,10],['book_y',2,20]]
author_B = [['book_s',5,10],['book_t',2,20]]
-----------------... | 0 | 2009-10-07T03:15:20Z | 1,529,348 | <pre><code>author_A = [['book_x',1,10],['book_y',2,20],['book_z',3,30]]
author_B = [['book_s',5,10],['book_t',2,20],['book_z',3,30]]
def present(A, B):
Aset = set(tuple(x) for x in A)
Bset = set(tuple(x) for x in B)
both = Aset & Bset
justA = Aset - both
justB = Bset - both
totals = [0, 0]
print "%-1... | 6 | 2009-10-07T03:36:42Z | [
"python"
] |
Help to solve my problems with python LIST? | 1,529,307 | <pre><code>author_A = [['book_x',1,10],['book_y',2,20],['book_z',3,30]]
author_B = [['book_s',5,10],['book_t',2,20],['book_z',3,30]]
author_A AND author_B = ['book_z',3,30]
author_A = [['book_x',1,10],['book_y',2,20]]
author_B = [['book_s',5,10],['book_t',2,20]]
-----------------... | 0 | 2009-10-07T03:15:20Z | 1,529,531 | <pre><code>books = {
'A':[['book_x',1,10],['book_y',2,20]],
'B':[['book_s',5,10],['book_t',2,20]],
'A & B':[['book_z',3,30]],
}
for key in books:
quantity = []
amount = []
for item in books[key]:
quantity.append(item[1])
amount.append(item[2])
print ("%s\t%s\t%s") % (key,... | 0 | 2009-10-07T04:52:22Z | [
"python"
] |
Python sqlite3 "unable to open database file" on windows | 1,529,527 | <p>I am working on a windows vista machine in python 3.1.1. I am trying to insert a large number of rows into a SQLite3 db. The file exists, and my program properly inserts <em>some</em> rows into the db. However, at some point in the insertion process, the program dies with this message:
sqlite3.OperationalErro... | 6 | 2009-10-07T04:50:37Z | 1,529,642 | <p>SQLite does not have record locking; it uses a simple locking mechanism that locks the entire database file briefly during a write. It sounds like you are running into a lock that hasn't cleared yet.</p>
<p>The author of SQLite recommends that you create a transaction prior to doing your inserts, and then complete... | 1 | 2009-10-07T05:26:10Z | [
"python",
"sqlite",
"windows-vista"
] |
Python sqlite3 "unable to open database file" on windows | 1,529,527 | <p>I am working on a windows vista machine in python 3.1.1. I am trying to insert a large number of rows into a SQLite3 db. The file exists, and my program properly inserts <em>some</em> rows into the db. However, at some point in the insertion process, the program dies with this message:
sqlite3.OperationalErro... | 6 | 2009-10-07T04:50:37Z | 2,127,838 | <p>same error here on windows 7 (python 2.6, django 1.1.1 and sqllite) after some records inserted correctly: sqlite3.OperationalError: unable to open database file</p>
<p>I ran my script from Eclipse different times and always got that error. But as I ran it from the command line (after setting PYTHONPATH and DJANGO_... | 0 | 2010-01-24T16:43:24Z | [
"python",
"sqlite",
"windows-vista"
] |
Print extremely large long in scientific notation in python | 1,529,569 | <p>Is there a way to get python to print extremely large longs in scientific notation? I am talking about numbers on the order of 10^1000 or larger, at this size the standard print "%e" % num fails.</p>
<p>For example:</p>
<pre>
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help",... | 12 | 2009-10-07T05:03:35Z | 1,529,607 | <p><a href="http://code.google.com/p/gmpy/">gmpy</a> to the rescue...:</p>
<pre><code>>>> import gmpy
>>> x = gmpy.mpf(10**1000)
>>> x.digits(10, 0, -1, 1)
'1.e1000'
</code></pre>
<p>I'm biased, of course, as the original author and still a committer of <code>gmpy</code>, but I do think it ... | 15 | 2009-10-07T05:14:12Z | [
"python"
] |
Print extremely large long in scientific notation in python | 1,529,569 | <p>Is there a way to get python to print extremely large longs in scientific notation? I am talking about numbers on the order of 10^1000 or larger, at this size the standard print "%e" % num fails.</p>
<p>For example:</p>
<pre>
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help",... | 12 | 2009-10-07T05:03:35Z | 2,330,992 | <p>No need to use a third party library. Here's a solution in Python3, that works for large integers.</p>
<pre><code>def ilog(n, base):
"""
Find the integer log of n with respect to the base.
>>> import math
>>> for base in range(2, 16 + 1):
... for n in range(1, 1000):
.... | 4 | 2010-02-25T01:37:07Z | [
"python"
] |
how to create new file using python | 1,529,584 | <p>how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"</p>
<p>thanks in advance</p>
| 1 | 2009-10-07T05:07:44Z | 1,529,596 | <p>It probably failed because /var/log has user set to root and group set to wheel. Try running your python code as root and it will probably work.</p>
| 1 | 2009-10-07T05:11:17Z | [
"python",
"osx",
"osx-leopard"
] |
how to create new file using python | 1,529,584 | <p>how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"</p>
<p>thanks in advance</p>
| 1 | 2009-10-07T05:07:44Z | 1,529,612 | <p>Only root can write in <code>/var/log/</code> on Mac OS X...:</p>
<pre><code>$ ls -ld /var/log
drwxr-xr-x 60 root wheel 2040 Oct 6 17:00 /var/log
</code></pre>
<p>Maybe consider using the <code>syslog</code> module in the standard library...</p>
| 6 | 2009-10-07T05:16:10Z | [
"python",
"osx",
"osx-leopard"
] |
how to create new file using python | 1,529,584 | <p>how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get "permission denied"</p>
<p>thanks in advance</p>
| 1 | 2009-10-07T05:07:44Z | 1,529,652 | <p>You can create the log file as root and then change the owner to the user your script is run as</p>
<pre><code># touch /var/log/mylogfile
# chown myuser /var/log/mylogfile
</code></pre>
<p>where mylogfile is your logfile and myuser is the user the script will be run as</p>
<p>also look into logrotate</p>
| 1 | 2009-10-07T05:29:02Z | [
"python",
"osx",
"osx-leopard"
] |
How to change the foreground or background colour of a Tkinter Button on Mac OS X? | 1,529,847 | <p>I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:</p>
<pre... | 7 | 2009-10-07T06:28:57Z | 1,530,913 | <p>I think the answer is that the buttons on the mac simply don't support changing the background and foreground colors. As you've seen, this isn't unique to Tk.</p>
| 10 | 2009-10-07T10:58:11Z | [
"python",
"osx",
"tkinter"
] |
How to change the foreground or background colour of a Tkinter Button on Mac OS X? | 1,529,847 | <p>I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:</p>
<pre... | 7 | 2009-10-07T06:28:57Z | 9,543,342 | <p>
For anyone else who happens upon this question as I did, the solution is to use the <a href="http://docs.python.org/library/ttk.html" rel="nofollow">ttk</a> module, which is available by default on OS X 10.7. Unfortunately, setting the background color still doesn't work out of the box, but text color does.</p>
<p... | 8 | 2012-03-03T04:04:44Z | [
"python",
"osx",
"tkinter"
] |
How to change the foreground or background colour of a Tkinter Button on Mac OS X? | 1,529,847 | <p>I've been working through the Tkinter chapters in Programming Python and encountered a problem where the foreground and background colours of a button will not change. I am working on a Mac OS X 10.6 system with Python 2.6.1. The colours of a label will change, but not the colours of a button. For example:</p>
<pre... | 7 | 2009-10-07T06:28:57Z | 34,762,619 | <p>I was looking as to why this doesn't work as well. I found a quick way to try and fix it is to have a label and then bind a click with the label. Then have the label change colors for a short time to mimic clicking. Here is an example.</p>
<pre class="lang-python prettyprint-override"><code>def buttonPress(*args):
... | 0 | 2016-01-13T09:16:49Z | [
"python",
"osx",
"tkinter"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,917 | <p>Seems like the problem here is that your environment (Visual Studio) doesn't support these languages, not that these languages don't support debuggers in general.</p>
<p>Perl, Python, and Ruby all have fully-featured debuggers; you can find other IDEs that help you, too. For Ruby, there's <a href="http://www.jetbra... | 4 | 2009-10-07T06:47:28Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,918 | <p>Here's a <a href="http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/" rel="nofollow">screencast</a> on ruby debugging with ruby-debug.</p>
| 6 | 2009-10-07T06:47:48Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,926 | <p>If you're working with Python then you can find a list of debugging tools <a href="http://stackoverflow.com/questions/477193/suggestions-for-python-debugging-tools">here</a> to which I just want to add <a href="http://eclipse.org/" rel="nofollow">Eclipse</a> with the <a href="http://pydev.org/" rel="nofollow">Pydev ... | 2 | 2009-10-07T06:49:50Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,931 | <p>Script languages have no differences compared with other languages in the sense that you still have to break your problems into manageable pieces -- that is, functions. So, instead of testing the whole script after finishing the whole script, I prefer to test those small functions before integrating them. TDD alway... | 2 | 2009-10-07T06:50:14Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,953 | <p>There is a nice gentle introduction to the Python debugger <a href="http://pythonconquerstheuniverse.wordpress.com/category/the-python-debugger/" rel="nofollow">here</a></p>
| 3 | 2009-10-07T06:56:44Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,529,996 | <p>Your sequence seems entirely backwards to me. Here's how I do it:</p>
<ol>
<li>I write a test for the functionality I want.</li>
<li>I start writing the script, executing bits and verifying test results.</li>
<li>I review what I'd done to document and publish.</li>
</ol>
<p>Specifically, I execute <em>before</em>... | 10 | 2009-10-07T07:09:05Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,530,310 | <p>There's a SO question on Ruby IDEs <a href="http://stackoverflow.com/questions/59968/best-editor-or-ide-for-ruby">here</a> - and searching for "ruby IDE" offers more.</p>
<blockquote>
<p>I complete a large script</p>
</blockquote>
<p>That's what caught my eye: "complete", to me, means "done", "finished", "releas... | 0 | 2009-10-07T08:38:02Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,530,557 | <p>You can debug your Python scripts using the included pdb module. If you want a visual debugger, you can download <a href="http://winpdb.org/" rel="nofollow">winpdb</a> - don't be put off by that "win" prefix, winpdb is cross-platform.</p>
| 0 | 2009-10-07T09:39:48Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,530,723 | <p>My question is, is there any better way of debugging?"</p>
<p>Yes.</p>
<p>Your approach, "1. I complete a large script, 2. Comment everything but the portion I want to check, 3. Execute the script" is not really the best way to write any software in any language (sorry, but that's the truth.)</p>
<p>Do not write ... | 2 | 2009-10-07T10:20:23Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,531,112 | <p>The debugging method you described is perfect for a static language like C++, but given that the language is so different, the coding methods are similarly different. One of the big very important things in a dynamic language such as Python or Ruby is the interactive toplevel (what you get by typing, say <code>pytho... | 0 | 2009-10-07T11:43:16Z | [
"python",
"ruby",
"scripting-language"
] |
Debugging a scripting language like ruby | 1,529,896 | <p>I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python.</p>
<p>I am wondering how to do debugging.
At present the steps I follow is, </p>
<ul>
<li>I complete a large script,</li>
<li>Comment everything but the portion I
want to check</li>
<li... | 6 | 2009-10-07T06:41:49Z | 1,533,469 | <p>There's a lot of good advice here, i recommend going through some best practices:</p>
<p><a href="http://github.com/edgecase/ruby%5Fkoans" rel="nofollow">http://github.com/edgecase/ruby%5Fkoans</a></p>
<p><a href="http://blog.rubybestpractices.com/" rel="nofollow">http://blog.rubybestpractices.com/</a></p>
<p><a ... | 1 | 2009-10-07T18:47:44Z | [
"python",
"ruby",
"scripting-language"
] |
Ruby methods equivalent of "if a in list" in python? | 1,529,986 | <p>In python I can use this to check if the element in list <code>a</code>:</p>
<pre><code>>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
</code></pre>
<p>How this can be done in Ruby?</p>
| 16 | 2009-10-07T07:05:15Z | 1,529,991 | <p>Use the <code><a href="http://www.ruby-doc.org/docs/ProgrammingRuby/html/ref%5Fc%5Farray.html#Array.include%5Fqm">include?()</a></code> method:</p>
<pre><code>(1..10).include?(5) #=>true
(1..10).include?(16) #=>false
</code></pre>
<p>EDIT:
<code>(1..10)</code> is <a href="http://ruby-doc.org/core/classes/Ran... | 25 | 2009-10-07T07:07:30Z | [
"python",
"ruby",
"syntax"
] |
Ruby methods equivalent of "if a in list" in python? | 1,529,986 | <p>In python I can use this to check if the element in list <code>a</code>:</p>
<pre><code>>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
</code></pre>
<p>How this can be done in Ruby?</p>
| 16 | 2009-10-07T07:05:15Z | 1,530,866 | <p>Range has the === method, which checks whether the argument is part of the range.</p>
<p>You use it like this:</p>
<pre><code>(1..10) === 5 #=> true
(1..10) === 15 #=> false
</code></pre>
<p>or as you wrote it:</p>
<pre><code>a= (1..10)
a === 5 #=> true
a === 16 #=> false
</code></pre>
<p>You must... | 10 | 2009-10-07T10:50:48Z | [
"python",
"ruby",
"syntax"
] |
Cannot shuffle list in Python | 1,530,161 | <p>This is my list:</p>
<pre><code>biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ]
print random.shuffle(biglist)
</code></pre>
<p>that doesn't work! It returns none.</p>
| 3 | 2009-10-07T07:53:55Z | 1,530,164 | <p><code>random.shuffle</code> shuffles the list, it does not return a new list. So check <code>biglist</code>, not the result of <code>random.shuffle</code>.</p>
<p>Documentation for the <code>random</code> module: <a href="http://docs.python.org/library/random.html">http://docs.python.org/library/random.html</a></p>... | 16 | 2009-10-07T07:55:35Z | [
"python",
"list",
"random"
] |
In Django, the HTML code is shown instead of the actual text | 1,530,178 | <p>& g t ; Welcome</p>
<p>How do I show the actual symbol instead? Is it a template filter?</p>
<p>Thanks.</p>
| 1 | 2009-10-07T08:02:01Z | 1,530,196 | <p>Bit hard to know without more details. If it's from data that you're passing in from the view, you might want to use <code>mark_safe</code>.</p>
<pre><code>from django.utils.safestring import mark_safe
def your_view(request):
...
foo = '&gt;'
mark_safe(foo)
...
</code></pre>
<p>Otherwise, you ... | 5 | 2009-10-07T08:07:35Z | [
"python",
"django"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,530,257 | <p>Try <a href="http://en.wikipedia.org/wiki/Garbage%5Fcollection%5F%28computer%5Fscience%29">reading</a> up on it.</p>
| 12 | 2009-10-07T08:23:19Z | [
"c++",
"python",
"garbage-collection"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,530,262 | <p>That means that python user doesn't need to clean his dynamic created objects, like you're obligated to do it in C/C++.</p>
<p>Example in C++:</p>
<pre><code>char *ch = new char[100];
ch[0]='a';
ch[1]='b';
//....
// somewhere else in your program you need to release the alocated memory.
delete [] ch;
// use *dele... | 8 | 2009-10-07T08:24:03Z | [
"c++",
"python",
"garbage-collection"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,530,267 | <p>It basically means the way they handle memory resources. When you need memory you usually ask for it to the OS and then return it back.</p>
<p>With python you don't need to worry about returning it, with C++ you need to track what you asked and return it back, one is easier, the other performant, you choose your to... | 2 | 2009-10-07T08:24:56Z | [
"c++",
"python",
"garbage-collection"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,530,291 | <p>From Wikipedia <a href="http://en.wikipedia.org/wiki/Garbage%5Fcollection%5F%28computer%5Fscience%29" rel="nofollow">http://en.wikipedia.org/wiki/Garbage_collection_%28computer_science%29</a>:</p>
<p>...</p>
<p><em>Garbage collection frees the programmer from manually dealing with memory allocation and deallocatio... | 4 | 2009-10-07T08:33:27Z | [
"c++",
"python",
"garbage-collection"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,530,379 | <p>Others already answered the main question, but I'd like to add that garbage collection is possible in C++. It's not that automatic like Python's, but it's doable.</p>
<p>Smart pointers are probably the simplest form of C++ garbage collecting - <a href="http://www.cplusplus.com/reference/std/memory/auto%5Fptr/" rel=... | 3 | 2009-10-07T08:56:46Z | [
"c++",
"python",
"garbage-collection"
] |
I heard that Python has automated "garbage collection" , but C++ does not. What does that mean? | 1,530,245 | <p>I heard that Python has automated "garbage collection" , but C++ does not. What does that mean?</p>
| 2 | 2009-10-07T08:21:31Z | 1,532,646 | <p>As you have got your answer, now it's better to know the cons of automated garbage collection:
it requires large amounts of extra memory and not suitable for hard real-time deadline applications.</p>
| 0 | 2009-10-07T16:15:44Z | [
"c++",
"python",
"garbage-collection"
] |
How do I change my float into a two decimal number with a comma as a decimal point separator in python? | 1,530,430 | <p>I have a float: 1.2333333</p>
<p>How do I change it into a two decimal number with a comma as a decimal point separator, eg 1,23?</p>
| 6 | 2009-10-07T09:06:12Z | 1,530,440 | <p>To get two decimals, use</p>
<pre><code>'%.2f' % 1.2333333
</code></pre>
<p>To get a comma, use <code>replace()</code>:</p>
<pre><code>('%.2f' % 1.2333333).replace('.', ',')
</code></pre>
<p>A second option would be to <a href="http://docs.python.org/library/locale.html" rel="nofollow">change the locale</a> to s... | 4 | 2009-10-07T09:09:49Z | [
"python",
"floating-point",
"decimal"
] |
How do I change my float into a two decimal number with a comma as a decimal point separator in python? | 1,530,430 | <p>I have a float: 1.2333333</p>
<p>How do I change it into a two decimal number with a comma as a decimal point separator, eg 1,23?</p>
| 6 | 2009-10-07T09:06:12Z | 1,530,519 | <p>If you don't want to mess with the locale, you can of course do the formatting yourself. This might serve as a starting point:</p>
<pre><code>def formatFloat(value, decimals = 2, sep = ","):
return "%s%s%0*u" % (int(value), sep, decimals, (10 ** decimals) * (value - int(value)))
</code></pre>
<p>Note that this w... | 0 | 2009-10-07T09:29:11Z | [
"python",
"floating-point",
"decimal"
] |
How do I change my float into a two decimal number with a comma as a decimal point separator in python? | 1,530,430 | <p>I have a float: 1.2333333</p>
<p>How do I change it into a two decimal number with a comma as a decimal point separator, eg 1,23?</p>
| 6 | 2009-10-07T09:06:12Z | 1,530,644 | <p>The <a href="http://docs.python.org/library/locale.html">locale module</a> can help you with reading and writing numbers in the locale's format.</p>
<pre><code>>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
'sv_SE.UTF-8'
>>> locale.format("%f", 2.2)
'2,200000'
>>> loca... | 7 | 2009-10-07T10:03:22Z | [
"python",
"floating-point",
"decimal"
] |
How to clear cookies using python 2.6.x cookielib | 1,530,464 | <p>It seems my previous description was not clear, so rewriting it. </p>
<p>Using python urllib2, I am automating fileupload task in my webapp. And am using Cookielib to store session information, and also I could able to successfully automate the fileupload task. Problem is, when I change the login credentials and di... | 1 | 2009-10-07T09:17:44Z | 1,553,712 | <p>you need to install the opener that you have built, otherwise it will just keep using the default</p>
| 0 | 2009-10-12T10:01:35Z | [
"python",
"cookies"
] |
How to clear cookies using python 2.6.x cookielib | 1,530,464 | <p>It seems my previous description was not clear, so rewriting it. </p>
<p>Using python urllib2, I am automating fileupload task in my webapp. And am using Cookielib to store session information, and also I could able to successfully automate the fileupload task. Problem is, when I change the login credentials and di... | 1 | 2009-10-07T09:17:44Z | 1,587,662 | <p>Instead of relying on cookies, I am restricting page access based response headers. Now, I could able to stop the file upload process when wrong credentials supplied. Thanks guys.</p>
| 0 | 2009-10-19T09:10:55Z | [
"python",
"cookies"
] |
Definition of mathematical operations (sinâ¦) on NumPy arrays containing objects | 1,530,598 | <p>I would like to provide "all" mathematical functions for the number-like objects created by a module (the <a href="http://pypi.python.org/pypi/uncertainties/" rel="nofollow"><code>uncertainties.py</code></a> module, which performs calculations with error propagation)âthese objects are numbers with uncertainties.</... | 1 | 2009-10-07T09:51:46Z | 1,542,399 | <p>It looks like following what NumPy itself does keeps things clean: "extended" mathematical operations (sinâ¦) that work on new objects can be put in a separate name space. Thus, NumPy has <code>numpy.sin</code>, etc. These operations are mostly compatible with those from <code>math</code>, but also work on NumPy ... | 0 | 2009-10-09T07:46:38Z | [
"python",
"arrays",
"numpy",
"operations"
] |
Don't touch my shebang! | 1,530,702 | <p>One thing I hate about <a href="http://docs.python.org/distutils/"><em>distutils</em></a> (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>gets magically convert... | 20 | 2009-10-07T10:15:31Z | 1,530,768 | <p>I have no solution to your problem, but I do see some rationale for the current behaviour of <em>distutils</em>.</p>
<p><code>#!/usr/bin/env python</code> executes the system's default Python version. That is fine as long as your code is compatible with said version. When the default version is updated (from 2.5 to... | 1 | 2009-10-07T10:29:42Z | [
"python",
"distutils",
"virtualenv"
] |
Don't touch my shebang! | 1,530,702 | <p>One thing I hate about <a href="http://docs.python.org/distutils/"><em>distutils</em></a> (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>gets magically convert... | 20 | 2009-10-07T10:15:31Z | 1,530,808 | <p>Of course you can move the development directory around. Distutils changes the paths to the python that you should run with when you run it. It's in Grok run when you run the buildout. Move and re-run the bootstrap and the buildout. Done!</p>
<p>Distutils changes the path to the Python you use to run distutils with... | 13 | 2009-10-07T10:37:09Z | [
"python",
"distutils",
"virtualenv"
] |
Don't touch my shebang! | 1,530,702 | <p>One thing I hate about <a href="http://docs.python.org/distutils/"><em>distutils</em></a> (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>gets magically convert... | 20 | 2009-10-07T10:15:31Z | 1,719,991 | <p>Distutils will automatically replace the shebang with the location of the Python binary that was used to execute setup.py. To override this behavior you have two options:</p>
<p><strong>Option 1: Manually</strong></p>
<p>You may pass the flag <strong>--executable=/path/to/my/python</strong> to setup.py. Arguments... | 8 | 2009-11-12T05:01:14Z | [
"python",
"distutils",
"virtualenv"
] |
Don't touch my shebang! | 1,530,702 | <p>One thing I hate about <a href="http://docs.python.org/distutils/"><em>distutils</em></a> (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>gets magically convert... | 20 | 2009-10-07T10:15:31Z | 10,486,563 | <p>In one of the latest versions of <strong>distutils</strong>, there is a flag <strong>--no-autoreq</strong> that have worked for me:</p>
<pre><code>--no-autoreq do not automatically calculate dependencies
</code></pre>
<p>In my case, I was creating RPM files with python2.4 executable, in a server with both ... | 1 | 2012-05-07T17:41:58Z | [
"python",
"distutils",
"virtualenv"
] |
Don't touch my shebang! | 1,530,702 | <p>One thing I hate about <a href="http://docs.python.org/distutils/"><em>distutils</em></a> (I guess he is the evil who does this) is that it changes the shebang line. In other words, the more rational and environment-vars decided scripture</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>gets magically convert... | 20 | 2009-10-07T10:15:31Z | 33,345,596 | <p>had the same issue. tried to find a way to prevent the touching altogether by default. here is the solution. essentially we override the default script copy routine (build_scripts).</p>
<p>in setup.py add</p>
<pre><code>from distutils.command.build_scripts import build_scripts
# don't touch my shebang
class BSCom... | 1 | 2015-10-26T12:18:26Z | [
"python",
"distutils",
"virtualenv"
] |
how do I sign data with pyme? | 1,530,797 | <p>I just installed <code>pyme</code> on my ubuntu system. it was easy (thanks apt-get) and I can reproduce the example code (encrypting using a public key in my keyring). now I would like to <em>sign</em> some data and I didn't manage to find any example code nor much documentation.</p>
<p>this is what I've been do... | 0 | 2009-10-07T10:34:35Z | 1,531,189 | <p>You can follow example from pyme doc and modify it a bit:</p>
<pre><code>import pyme.core
import pyme.pygpgme
plaintext = pyme.core.Data('this is a test message')
ciphertext = pyme.core.Data()
ctx = pyme.core.Context()
ctx.set_armor(1)
name = 'me@office.com'
ctx.op_keylist_start(name, 0)
key = ctx.op_keylist_next(... | 0 | 2009-10-07T11:56:06Z | [
"python",
"encryption",
"gnupg",
"gpgme",
"pyme"
] |
Incrementally building a numpy array and measuring memory usage | 1,530,960 | <p>I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:</p>
<ul>
<li>As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array... | 11 | 2009-10-07T11:08:36Z | 1,534,233 | <p>There's no way to ensure you can grow the array in place other than creating an empty array (numpy.empty) of the maximum possible size and then using a view of that at the end. You can't start small because there's no guarantee that you can expand whatever memory the map is without clobbering some other data. (And... | 7 | 2009-10-07T21:14:40Z | [
"python",
"numpy",
"memory-management"
] |
Incrementally building a numpy array and measuring memory usage | 1,530,960 | <p>I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:</p>
<ul>
<li>As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array... | 11 | 2009-10-07T11:08:36Z | 1,534,340 | <p>On possible option is to do a single pass through the file first to count the number of rows, without loading them.</p>
<p>The other option is to double your table size each time, which has two benefits:</p>
<ol>
<li>You will only re-alloc memory log(n) times where n is the number of rows.</li>
<li>You only need 5... | 1 | 2009-10-07T21:32:59Z | [
"python",
"numpy",
"memory-management"
] |
Incrementally building a numpy array and measuring memory usage | 1,530,960 | <p>I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:</p>
<ul>
<li>As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array... | 11 | 2009-10-07T11:08:36Z | 4,666,155 | <p>Have you tried using memmap file? You can iterate through your input file (in chunks if possible) and convert the incoming data and insert them as rows into a memory-mapped numpy array. The downside is incurring more disk i/o in case there is insufficient main memory and paging from swap becomes necessary.</p>
<p>S... | 2 | 2011-01-12T07:05:17Z | [
"python",
"numpy",
"memory-management"
] |
Incrementally building a numpy array and measuring memory usage | 1,530,960 | <p>I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question:</p>
<ul>
<li>As the number of rows is unknown at the beginning of the loading, how can
a very large numpy array... | 11 | 2009-10-07T11:08:36Z | 14,831,202 | <p>The problem is essentially the text file. When your input data is stored in a more advanced from, such problems can be avoided. Take for example a look at the <a href="http://code.google.com/p/h5py/" rel="nofollow">h5py project</a>. It is worth the trouble to first convert your data to HDF5 files and then run analys... | 0 | 2013-02-12T11:13:06Z | [
"python",
"numpy",
"memory-management"
] |
Django: apply "same parent" constraint to ManyToManyField mapping to self | 1,531,065 | <p>I have a model where tasks are pieces of work that each may depend on some number of other tasks to complete before it can start. Tasks are grouped into jobs, and I want to disallow dependencies between jobs. This is the relevant subset of my model:</p>
<pre><code>class Job(models.Model):
name = models.CharFiel... | 3 | 2009-10-07T11:32:11Z | 1,531,900 | <p>There are two separate issues here.</p>
<p>If you want to enforce this constraint at the model level, you might have to define an explicit "through" model and override its save() method (you can't just override Task.save() as that isn't necessarily invoked for adding entries to an M2M). Django 1.2 will have a fulle... | 3 | 2009-10-07T14:12:45Z | [
"python",
"django",
"orm",
"constraints"
] |
For list unless empty in python | 1,531,402 | <p>I've been writing a lot of constructs like this the past couple of days:</p>
<pre><code>list = get_list()
if list:
for i in list:
pass # do something with the list
else:
pass # do something if the list was empty
</code></pre>
<p>Lot of junk and I assign the list to a real variable (keeping it in me... | 12 | 2009-10-07T12:43:07Z | 1,531,476 | <pre><code>def do_something_with_maybe_list(maybe_list):
if maybe_list:
for x in list:
do_something(x)
else:
do_something_else()
do_something_with_maybe_list(get_list())
</code></pre>
<p>You could even extract the actions to be done:</p>
<pre><code>def do_something_with_maybe_list... | 2 | 2009-10-07T12:56:27Z | [
"for-loop",
"python"
] |
For list unless empty in python | 1,531,402 | <p>I've been writing a lot of constructs like this the past couple of days:</p>
<pre><code>list = get_list()
if list:
for i in list:
pass # do something with the list
else:
pass # do something if the list was empty
</code></pre>
<p>Lot of junk and I assign the list to a real variable (keeping it in me... | 12 | 2009-10-07T12:43:07Z | 1,531,505 | <p>Slighty more terse is:</p>
<pre><code>for i in my_list:
# got a list
if not my_list:
# not a list
</code></pre>
<p>assuming you are not changing the length of the list in the loop. </p>
<p>Edit from Oli: To compensate my worries of memory use, it would want <code>with</code>ing:</p>
<pre><code>with get_l... | 4 | 2009-10-07T13:02:12Z | [
"for-loop",
"python"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.