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 |
|---|---|---|---|---|---|---|---|---|---|
Python - Subprocess - How to call a Piped command in Windows? | 1,046,474 | <p>How do I run this command with subprocess?</p>
<p>I tried:</p>
<pre><code>proc = subprocess.Popen(
'''ECHO bosco|"C:\Program Files\GNU\GnuPG\gpg.exe" --batch --passphrase-fd 0 --output "c:\docume~1\usi\locals~1\temp\tmptlbxka.txt" --decrypt "test.txt.gpg"''',
stdin=subprocess.PIPE,
stdout=subprocess.PI... | 5 | 2009-06-25T22:04:16Z | 5,942,470 | <p>You were right, the ECHO is the problem. Without the shell=True option the ECHO command cannot be found.</p>
<p>This fails with the error you saw:</p>
<pre><code>subprocess.call(["ECHO", "Ni"])
</code></pre>
<p>This passes: prints Ni and a 0</p>
<pre><code>subprocess.call(["ECHO", "Ni"], shell=True)
</code></pre... | 4 | 2011-05-09T21:02:49Z | [
"python",
"subprocess",
"pipe",
"echo",
"popen"
] |
Unable to put a variable in Python's print | 1,046,584 | <p><strong>My code:</strong></p>
<pre><code>year=[51-52,53,55,56,58,59,60,61]
photo=[{70,72,73},{64,65,68},{79,80,81,82},{74,77,78},{60,61,62},{84,85,87},{57,58,59},{53,54,55,56}]
for i in range(7):
print "<img src=\"http://files.getdropbox.com/u/100000/Akuja/",year,"/P10104",photo,".JPG\">"
</code></pre>
... | 0 | 2009-06-25T22:41:31Z | 1,046,593 | <p>Braces are used to indicate a dictionary (associative array). You want to use square brackets, which indicates a list.</p>
<p>Also you probably don't want 51-52 in that first line, as that will evaluate to -1. You should put "51-52" to ensure that it is a string.</p>
<p>Then to get the indexing that you seem to ... | 3 | 2009-06-25T22:47:37Z | [
"python"
] |
Unable to put a variable in Python's print | 1,046,584 | <p><strong>My code:</strong></p>
<pre><code>year=[51-52,53,55,56,58,59,60,61]
photo=[{70,72,73},{64,65,68},{79,80,81,82},{74,77,78},{60,61,62},{84,85,87},{57,58,59},{53,54,55,56}]
for i in range(7):
print "<img src=\"http://files.getdropbox.com/u/100000/Akuja/",year,"/P10104",photo,".JPG\">"
</code></pre>
... | 0 | 2009-06-25T22:41:31Z | 1,046,611 | <p>So here is your simple solution to your simple problem</p>
<pre><code>year=['51-52', '53', '55' , '56' , '58', '59', '60', '61']
photo=[[70,72,73], [64,65,68],[79,80,81,82],[74,77,78],[60,61,62],[84,85,87],[57,58,59],[53,54,55,56]]
for i in range(len(year)):
for j in range(len(photo[i])):
print '<img ... | 2 | 2009-06-25T22:56:20Z | [
"python"
] |
Unable to put a variable in Python's print | 1,046,584 | <p><strong>My code:</strong></p>
<pre><code>year=[51-52,53,55,56,58,59,60,61]
photo=[{70,72,73},{64,65,68},{79,80,81,82},{74,77,78},{60,61,62},{84,85,87},{57,58,59},{53,54,55,56}]
for i in range(7):
print "<img src=\"http://files.getdropbox.com/u/100000/Akuja/",year,"/P10104",photo,".JPG\">"
</code></pre>
... | 0 | 2009-06-25T22:41:31Z | 1,046,642 | <p>Since you are trying to iterate over years and print photos for that year I would do it this way:</p>
<pre><code>year=["51-52","53","55","56","58","59","60","61"]
photo=[(70,72,73),(64,65,68),(79,80,81,82),(74,77,78),(60,61,62),
(84,85,87),(57,58,59),(53,54,55,56)]
# this dictionary will be generated with t... | 1 | 2009-06-25T23:07:17Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,046,655 | <p>You need to add the path to the currently executing module to the sys.path variable. Since you called it on the command line, the path to the script will always be in sys.argv[0].</p>
<pre><code>import sys
import os
sys.path.append(os.path.split(sys.argv[0])[0])
</code></pre>
<p>Now when import searches for the m... | 6 | 2009-06-25T23:11:48Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,046,825 | <p>There are several ways to add things to the <code>PYTHONPATH</code>.</p>
<p>Read <a href="http://docs.python.org/library/site.html" rel="nofollow">http://docs.python.org/library/site.html</a></p>
<ol>
<li><p>Set the <code>PYTHONPATH</code> environment variable prior to running your script.</p>
<p>You can do this ... | 4 | 2009-06-26T00:23:12Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,046,837 | <p>Actually your example works because checks.py is in the same directory as agent.py, but say checks.py was in the preceeding directory, eg;</p>
<pre><code>agent/agent.py
checks.py
</code></pre>
<p>Then you could do the following:</p>
<pre><code>path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
... | 22 | 2009-06-26T00:26:27Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,047,208 | <p><strong>You should NOT need to fiddle with sys.path.</strong> To quote from the Python 2.6 docs for sys.path:</p>
<blockquote>
<p>As initialized upon program startup, the first item of this list,
path[0], is the directory containing the script that was used to
invoke the Python interpreter. If the script dire... | 6 | 2009-06-26T03:44:21Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,048,255 | <p>I think you should consider making the agent directory into a proper Python package. Then you place this package anywhere on the python path, and you can import checks as </p>
<pre><code>from agent import checks
</code></pre>
<p>See <a href="http://docs.python.org/tutorial/modules.html" rel="nofollow">http://docs.... | 1 | 2009-06-26T09:43:23Z | [
"python"
] |
Importing Python modules from different working directory | 1,046,628 | <p>I have a Python script that uses built-in modules but also imports a number of custom modules that exist in the same directory as the main script itself.</p>
<p>For example, I would call</p>
<pre><code>python agent.py
</code></pre>
<p>and agent.py has a number of imports, including:</p>
<pre><code>import checks
... | 21 | 2009-06-25T23:03:09Z | 1,085,084 | <p>If you know full path to check.py use this recipe (<a href="http://code.activestate.com/recipes/159571/" rel="nofollow">http://code.activestate.com/recipes/159571/</a>)</p>
<p>If you want to add directory to system path -- this recipe (<a href="http://code.activestate.com/recipes/52662/" rel="nofollow">http://code.... | 1 | 2009-07-05T23:38:20Z | [
"python"
] |
An integer is required? open() | 1,046,656 | <p>I have a very simple python script that <strong>should</strong> scan a text file, which contains lines formatted as <em>id</em>='<em>value</em>' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:</p>
<pre><code>import os,sys
from os import *
from sys import... | 22 | 2009-06-25T23:11:49Z | 1,046,674 | <p>Because you did <code>from os import *</code>, you are (accidenally) using os.open, which indeed requires an integer flag instead of a textual "r" or "w". Take out that line and you'll get past that error.</p>
| 38 | 2009-06-25T23:16:56Z | [
"python",
"file-io",
"integer",
"argv"
] |
An integer is required? open() | 1,046,656 | <p>I have a very simple python script that <strong>should</strong> scan a text file, which contains lines formatted as <em>id</em>='<em>value</em>' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:</p>
<pre><code>import os,sys
from os import *
from sys import... | 22 | 2009-06-25T23:11:49Z | 1,046,706 | <p>Don't do <code>import * from wherever</code> without a good reason (and there aren't many).</p>
<p>Your code is picking up the os.open() function instead of the built-in open() function. If you really want to use os.open(), do <code>import os</code> then call <code>os.open(....)</code>. Whichever open you want to c... | 7 | 2009-06-25T23:31:22Z | [
"python",
"file-io",
"integer",
"argv"
] |
An integer is required? open() | 1,046,656 | <p>I have a very simple python script that <strong>should</strong> scan a text file, which contains lines formatted as <em>id</em>='<em>value</em>' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:</p>
<pre><code>import os,sys
from os import *
from sys import... | 22 | 2009-06-25T23:11:49Z | 1,046,794 | <p>Also of note is that starting with Python 2.6 the built-in function open() is now an alias for the io.open() function. It was even considered removing the built-in open() in Python 3 and requiring the usage of io.open, in order to avoid accidental namespace collisions resulting from things such as "from blah import ... | 5 | 2009-06-26T00:10:37Z | [
"python",
"file-io",
"integer",
"argv"
] |
An integer is required? open() | 1,046,656 | <p>I have a very simple python script that <strong>should</strong> scan a text file, which contains lines formatted as <em>id</em>='<em>value</em>' and put them into a dict. the python module is called chval.py and the input file is in.txt. here's the code:</p>
<pre><code>import os,sys
from os import *
from sys import... | 22 | 2009-06-25T23:11:49Z | 34,353,572 | <p>From <a href="http://www.tutorialspoint.com/python/os_open.htm" rel="nofollow">http://www.tutorialspoint.com/python/os_open.htm</a> you could also keep your import and use </p>
<p>file = os.open( "foo.txt", mode )</p>
<p>and the mode could be :</p>
<pre><code>os.O_RDONLY: open for reading only
os.O_WRONLY: open f... | 0 | 2015-12-18T10:34:04Z | [
"python",
"file-io",
"integer",
"argv"
] |
Does Python's heapify() not play well with list comprehension and slicing? | 1,046,683 | <p>I found an interesting bug in a program that I implemented somewhat lazily, and wondered if I'm comprehending it correctly. The short version is that <a href="http://docs.python.org/library/heapq.html" rel="nofollow">Python's <code>heapq</code> implementation</a> doesn't actually order a list, it merely groks the li... | 2 | 2009-06-25T23:21:02Z | 1,046,689 | <p>A heap is not a sorted list (it's a representation of a partially sorted binary tree).</p>
<p>So yes, you're right, if you expect a heapified list to behave like a sorted list, you'll be disappointed. The only sorting assumption you can make about a heap is that <code>heap[0]</code> is always its smallest element.... | 8 | 2009-06-25T23:23:49Z | [
"python",
"heap",
"list-comprehension"
] |
Does Python's heapify() not play well with list comprehension and slicing? | 1,046,683 | <p>I found an interesting bug in a program that I implemented somewhat lazily, and wondered if I'm comprehending it correctly. The short version is that <a href="http://docs.python.org/library/heapq.html" rel="nofollow">Python's <code>heapq</code> implementation</a> doesn't actually order a list, it merely groks the li... | 2 | 2009-06-25T23:21:02Z | 1,046,702 | <blockquote>
<p>The result: Any slicing and list
comprehension operations on a
heapified list will yield non-ordered
results.</p>
<p>Is this true, and is this always true?</p>
</blockquote>
<p>If you just want to get a one-time sorted list, use:</p>
<pre><code>myList.sort()
</code></pre>
<p>Priority que... | 0 | 2009-06-25T23:30:05Z | [
"python",
"heap",
"list-comprehension"
] |
Does Python's heapify() not play well with list comprehension and slicing? | 1,046,683 | <p>I found an interesting bug in a program that I implemented somewhat lazily, and wondered if I'm comprehending it correctly. The short version is that <a href="http://docs.python.org/library/heapq.html" rel="nofollow">Python's <code>heapq</code> implementation</a> doesn't actually order a list, it merely groks the li... | 2 | 2009-06-25T23:21:02Z | 1,046,796 | <p>"""I was expecting heapify() to result in an ordered list that facilitated list comprehension in an ordered fashion.""": If this expectation was based on a reading of the manual, you should raise a docs bug report.</p>
<p>""" The result: Any slicing and list comprehension operations on a heapified list will yield n... | 0 | 2009-06-26T00:11:15Z | [
"python",
"heap",
"list-comprehension"
] |
Does Python's heapify() not play well with list comprehension and slicing? | 1,046,683 | <p>I found an interesting bug in a program that I implemented somewhat lazily, and wondered if I'm comprehending it correctly. The short version is that <a href="http://docs.python.org/library/heapq.html" rel="nofollow">Python's <code>heapq</code> implementation</a> doesn't actually order a list, it merely groks the li... | 2 | 2009-06-25T23:21:02Z | 1,047,287 | <p>" The result: Any slicing and list comprehension operations on a heapified list will yield non-ordered results. Is this true, and is this always true?" No, it is not always true. Although it will be non-ordered most of the time, it is possible for it to be ordered. heapify() produces a list that satisfies the "heap ... | 0 | 2009-06-26T04:13:54Z | [
"python",
"heap",
"list-comprehension"
] |
Accessing a PHP-set memcache key from Python | 1,046,847 | <p>I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing "local variable 'val' referenced before assignment".</p>
<p>I'm sure I'm looking for the same key, and there's only one mc serve... | 1 | 2009-06-26T00:28:10Z | 1,046,859 | <p>By default, the PHP client stores keys in PHP's serialized format (which Python won't understand by default). If the Python client does something similar (using its own serialization format), that'd be your problem.</p>
<p>You can always use telnet/netcat to see what exactly is getting stored.</p>
| 4 | 2009-06-26T00:31:34Z | [
"php",
"python",
"memcached"
] |
Accessing a PHP-set memcache key from Python | 1,046,847 | <p>I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing "local variable 'val' referenced before assignment".</p>
<p>I'm sure I'm looking for the same key, and there's only one mc serve... | 1 | 2009-06-26T00:28:10Z | 4,357,288 | <p>You could serialise the "data" into json, which I've done once.</p>
| 0 | 2010-12-05T03:55:38Z | [
"php",
"python",
"memcached"
] |
Accessing a PHP-set memcache key from Python | 1,046,847 | <p>I'm storing a value in memcached using PHP's Memcache extension and trying to retrieve it in a daemon written in Python sitting behind my webapp. But, it keeps returning None or throwing "local variable 'val' referenced before assignment".</p>
<p>I'm sure I'm looking for the same key, and there's only one mc serve... | 1 | 2009-06-26T00:28:10Z | 8,503,973 | <p>Not sure if you found a solution to this, or if it's still important to you. But check out my answer on <a href="http://stackoverflow.com/questions/8490312/sharing-memcache-with-php-and-python">Sharing Memcache with PHP and Python</a></p>
<p>But to give an extra pointer, use Wireshark to see what messages are being... | 0 | 2011-12-14T11:48:30Z | [
"php",
"python",
"memcached"
] |
Can a slow network cause a Python app to use *more* CPU? | 1,046,873 | <p>Let's say we have a system like this:</p>
<pre><code> ______
{ application instances ---network--- (______)
{ application instances ---network--- | |
requests ---> load balancer { ... | 4 | 2009-06-26T00:40:38Z | 1,046,901 | <p>The key is to launch the application instances in separate processes. Otherwise multi-threading issues seem to be likely to follow.</p>
| 1 | 2009-06-26T00:57:07Z | [
"python",
"multithreading"
] |
Can a slow network cause a Python app to use *more* CPU? | 1,046,873 | <p>Let's say we have a system like this:</p>
<pre><code> ______
{ application instances ---network--- (______)
{ application instances ---network--- | |
requests ---> load balancer { ... | 4 | 2009-06-26T00:40:38Z | 1,046,910 | <p>No this is not the case. Stop spreading the FUD.</p>
<p>If your python app is blocked on a C API call ex. blocking sockets or file read, it probably released the GIL.</p>
| 1 | 2009-06-26T01:02:37Z | [
"python",
"multithreading"
] |
Can a slow network cause a Python app to use *more* CPU? | 1,046,873 | <p>Let's say we have a system like this:</p>
<pre><code> ______
{ application instances ---network--- (______)
{ application instances ---network--- | |
requests ---> load balancer { ... | 4 | 2009-06-26T00:40:38Z | 1,047,044 | <blockquote>
<p>Something about the Global Interpreter Lock and the multiple threads supposedly causes Python to spend all its time switching between threads, checking to see if any of them have an answer yet from the database. </p>
</blockquote>
<p>That is completely baseless. If all threads are blocked on I/O, Py... | 1 | 2009-06-26T02:12:37Z | [
"python",
"multithreading"
] |
Can a slow network cause a Python app to use *more* CPU? | 1,046,873 | <p>Let's say we have a system like this:</p>
<pre><code> ______
{ application instances ---network--- (______)
{ application instances ---network--- | |
requests ---> load balancer { ... | 4 | 2009-06-26T00:40:38Z | 1,047,088 | <p>In theory, no, in practice, its possible; it depends on what you're doing.</p>
<p>There's a full <a href="http://blip.tv/file/2232410" rel="nofollow">hour-long video</a> and <a href="http://www.dabeaz.com/python/GIL.pdf" rel="nofollow">pdf about it</a>, but essentially it boils down to some unforeseen consequences ... | 6 | 2009-06-26T02:36:54Z | [
"python",
"multithreading"
] |
What to do after starting simple_server? | 1,046,980 | <p>For some quick background, I'm an XHTML/CSS guy with some basic PHP knowledge. I'm trying to dip my feet into the Python pool, and so far understand how to start simple_server and access a simple Hello World return in the same .py file. This is the extent of what I understand though, heh.</p>
<p>How do I integrate ... | 1 | 2009-06-26T01:40:57Z | 1,047,024 | <p>Take a look at <a href="http://www.cherrypy.org/" rel="nofollow">CherryPy</a>. It's a nice http framework.</p>
| 1 | 2009-06-26T02:04:57Z | [
"python"
] |
What to do after starting simple_server? | 1,046,980 | <p>For some quick background, I'm an XHTML/CSS guy with some basic PHP knowledge. I'm trying to dip my feet into the Python pool, and so far understand how to start simple_server and access a simple Hello World return in the same .py file. This is the extent of what I understand though, heh.</p>
<p>How do I integrate ... | 1 | 2009-06-26T01:40:57Z | 1,047,240 | <p>It depends on what you want to achieve, </p>
<p>a) do you want to just write a web application without worrying too much abt what goes in the background, how request are being handled, or templates being rendered than go for a goo webframework, there are many choices simple http server is NOT one of them. e.g. use ... | 0 | 2009-06-26T03:58:40Z | [
"python"
] |
What to do after starting simple_server? | 1,046,980 | <p>For some quick background, I'm an XHTML/CSS guy with some basic PHP knowledge. I'm trying to dip my feet into the Python pool, and so far understand how to start simple_server and access a simple Hello World return in the same .py file. This is the extent of what I understand though, heh.</p>
<p>How do I integrate ... | 1 | 2009-06-26T01:40:57Z | 1,047,373 | <p>I would recommend <a href="http://www.djangoproject.com/" rel="nofollow">Django</a>.</p>
| 3 | 2009-06-26T04:39:32Z | [
"python"
] |
What to do after starting simple_server? | 1,046,980 | <p>For some quick background, I'm an XHTML/CSS guy with some basic PHP knowledge. I'm trying to dip my feet into the Python pool, and so far understand how to start simple_server and access a simple Hello World return in the same .py file. This is the extent of what I understand though, heh.</p>
<p>How do I integrate ... | 1 | 2009-06-26T01:40:57Z | 1,047,429 | <p>The other answers give good recommendations for what you probably want to do towards your "eventual goal", but, if you first want to persist with <code>wsgiref.simple_server</code> for an instructive while, you can do that too. WSGI is the crucial "glue" between web servers (not just the simple one in <code>wsgiref<... | 3 | 2009-06-26T04:59:28Z | [
"python"
] |
What to do after starting simple_server? | 1,046,980 | <p>For some quick background, I'm an XHTML/CSS guy with some basic PHP knowledge. I'm trying to dip my feet into the Python pool, and so far understand how to start simple_server and access a simple Hello World return in the same .py file. This is the extent of what I understand though, heh.</p>
<p>How do I integrate ... | 1 | 2009-06-26T01:40:57Z | 1,049,416 | <p><strong>"Obviously with PHP, you simply make sure its installed on your server and you start writing the code."</strong></p>
<p>Not true with Python. Python is just a language, not an Apache plug-in like PHP.</p>
<p>Generally, you can use something like <a href="http://code.google.com/p/modwsgi/" rel="nofollow">m... | 1 | 2009-06-26T14:22:06Z | [
"python"
] |
Overriding "+=" in Python? (__iadd__() method) | 1,047,021 | <p>Is it possible to override += in Python?</p>
| 25 | 2009-06-26T02:04:24Z | 1,047,034 | <p>Yes, override the <a href="https://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex"><code>__iadd__</code></a> method. Example:</p>
<pre><code>def __iadd__(self, other):
self.number += other.number
return self
</code></pre>
| 61 | 2009-06-26T02:08:45Z | [
"python",
"operators",
"override"
] |
Overriding "+=" in Python? (__iadd__() method) | 1,047,021 | <p>Is it possible to override += in Python?</p>
| 25 | 2009-06-26T02:04:24Z | 1,047,036 | <p><a href="http://docs.python.org/reference/datamodel.html#emulating-numeric-types" rel="nofollow">http://docs.python.org/reference/datamodel.html#emulating-numeric-types</a></p>
<blockquote>
<p>For instance, to execute the statement
x += y, where x is an instance of a
class that has an __iadd__() method,
x._... | 4 | 2009-06-26T02:09:16Z | [
"python",
"operators",
"override"
] |
Overriding "+=" in Python? (__iadd__() method) | 1,047,021 | <p>Is it possible to override += in Python?</p>
| 25 | 2009-06-26T02:04:24Z | 1,047,068 | <p>In addition to overloading <code>__iadd__</code> (remember to return self!), you can also fallback on <code>__add__</code>, as x += y will work like x = x + y. (This is one of the pitfalls of the += operator.)</p>
<pre><code>>>> class A(object):
... def __init__(self, x):
... self.x = x
... def __a... | 9 | 2009-06-26T02:26:01Z | [
"python",
"operators",
"override"
] |
Overriding "+=" in Python? (__iadd__() method) | 1,047,021 | <p>Is it possible to override += in Python?</p>
| 25 | 2009-06-26T02:04:24Z | 31,546,707 | <p>In addition to what's correctly given in answers above, it is worth explicitly clarifying that when <code>__iadd__</code> is overriden, the <code>x += y</code> operation does NOT end with the end of <code>__iadd__</code> method.</p>
<p>Instead, it ends with <code>x = x.__iadd__(y)</code>. In other words, Python ass... | 6 | 2015-07-21T18:18:05Z | [
"python",
"operators",
"override"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,328 | <p>If you want to save it in an easy to read JSON-like format, use <code>repr</code> to serialize the object and <code>eval</code> to deserialize it.</p>
<blockquote>
<p><code>repr(object) -> string</code> </p>
<p>Return the canonical string representation of the object.
For most object types, <code>eval(... | 3 | 2009-06-26T04:26:38Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,335 | <p>Use the <a href="http://docs.python.org/library/pickle.html">pickle</a> module.</p>
<pre><code>import pickle
d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
afile = open(r'C:\d.pkl', 'wb')
pickle.dump(d, afile)
afile.close()
#reload object from file
file2 = open(r'C:\d.pkl', 'rb')
new_d = pickle.load(file2)
file2.cl... | 35 | 2009-06-26T04:27:36Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,338 | <p>Take your pick: <a href="http://docs.python.org/library/persistence.html">Python Standard Library - Data Persistance</a>. Which one is most appropriate can vary by what your specific needs are.</p>
<p><a href="http://docs.python.org/library/pickle.html"><code>pickle</code></a> is probably the simplest and most cap... | 10 | 2009-06-26T04:28:03Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,353 | <p>Try the shelve module which will give you persistent dictionary, for example:</p>
<pre><code>import shelve
d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
shelf = shelve.open('shelf_file')
for key,val in d.items():
shelf[key] = val
shelf.close()
....
# reopen the shelf
shelf = shelve.open('shelf_file')
print ... | 5 | 2009-06-26T04:33:30Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,392 | <p>Just to add to the previous suggestions, if you want the file format to be easily readable and modifiable, you can also use <a href="http://pyyaml.org/" rel="nofollow">YAML</a>. It works extremely well for nested dicts and lists, but scales for more complex data structures (i.e. ones involving custom objects) as wel... | 2 | 2009-06-26T04:45:57Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,448 | <p><a href="http://json.org/" rel="nofollow">JSON</a> has faults, but when it meets your needs, it is also:</p>
<ul>
<li>simple to use</li>
<li>included in the standard library as the <a href="http://docs.python.org/library/json.html" rel="nofollow"><code>json</code> module</a></li>
<li>interface somewhat similar to <... | 2 | 2009-06-26T05:07:48Z | [
"python",
"file",
"persistence"
] |
Easiest way to persist a data structure to a file in python? | 1,047,318 | <p>Let's say I have something like this:</p>
<pre><code>d = { "abc" : [1, 2, 3], "qwerty" : [4,5,6] }
</code></pre>
<p>What's the easiest way to <strong>progammatically</strong> get that into a file that I can load from python later?</p>
<p>Can I somehow save it as python source (from within a python script, not ma... | 17 | 2009-06-26T04:22:39Z | 1,047,470 | <p>You also might want to take a look at <a href="http://www.zodb.org/en/latest/" rel="nofollow">Zope's Object Database</a> the more complex you get:-) Probably overkill for what you have, but it scales well and is not too hard to use.</p>
| 3 | 2009-06-26T05:15:03Z | [
"python",
"file",
"persistence"
] |
orbited comment server issue | 1,047,349 | <p>I tried installing orbited on vista . but I get following error when I try to run the orbited server.When I type on twisted cmd prompt orbited i get following o/p.</p>
<pre><code>C:\&gt;orbited
Traceback (most recent call last):
File "C:\Python26\scripts\orbited-script.py", line 8, in <module>
load_... | 1 | 2009-06-26T04:32:20Z | 1,047,365 | <p>Do you have write permission on the file <code>debug.log</code> (and the directory it's to be placed in, which I think is the current directory)? If not, you could try tweaking the <code>config.map</code> being used to setup the logging subsystem (about midway through this stack trace).</p>
| 1 | 2009-06-26T04:38:12Z | [
"python",
"comet",
"twisted",
"orbited"
] |
Retrieving a tuple from a collection of tuples based on a contained value | 1,047,403 | <p>I have a data structure which is a collection of tuples like this:</p>
<pre><code>things = ( (123, 1, "Floogle"), (154, 33, "Blurgle"), (156, 55, "Blarg") )
</code></pre>
<p>The first and third elements are each unique to the collection.</p>
<p>What I want to do is retrieve a specific tuple by referring to the th... | 0 | 2009-06-26T04:49:36Z | 1,047,420 | <p>If <code>things</code> is a list, and you know that the third element is uniqe, what about a list comprehension?</p>
<pre><code>>> my_thing = [x for x in things if x[2]=="Blurgle"][0]
</code></pre>
<p>Although under the hood, I assume that goes through all the values and checks them individually. If you don'... | 1 | 2009-06-26T04:54:31Z | [
"python",
"tuples"
] |
Retrieving a tuple from a collection of tuples based on a contained value | 1,047,403 | <p>I have a data structure which is a collection of tuples like this:</p>
<pre><code>things = ( (123, 1, "Floogle"), (154, 33, "Blurgle"), (156, 55, "Blarg") )
</code></pre>
<p>The first and third elements are each unique to the collection.</p>
<p>What I want to do is retrieve a specific tuple by referring to the th... | 0 | 2009-06-26T04:49:36Z | 1,047,442 | <p>A loop (or something 100% equivalent like a list comprehension or genexp) is really the only approach if your outer-level structure is a tuple, as you indicate -- tuples are, by deliberate design, an extremely light-weight container, with hardly any methods in fact (just the few special methods needed to implement i... | 4 | 2009-06-26T05:04:52Z | [
"python",
"tuples"
] |
Retrieving a tuple from a collection of tuples based on a contained value | 1,047,403 | <p>I have a data structure which is a collection of tuples like this:</p>
<pre><code>things = ( (123, 1, "Floogle"), (154, 33, "Blurgle"), (156, 55, "Blarg") )
</code></pre>
<p>The first and third elements are each unique to the collection.</p>
<p>What I want to do is retrieve a specific tuple by referring to the th... | 0 | 2009-06-26T04:49:36Z | 1,047,563 | <p>if you have to do this type of search multiple times, why don't you convert things to things_dict one time , then it will be easy and faster to search later on</p>
<pre><code>things = ( (123, 1, "Floogle"), (154, 33, "Blurgle"), (156, 55, "Blarg") )
things_dict = {}
for t in things:
things_dict[t[2]] = t
prin... | 1 | 2009-06-26T05:58:35Z | [
"python",
"tuples"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,634 | <ol>
<li>Use collections.defaultdict so that
by deafult count for anything is
zero</li>
<li>After that loop thru lines in file
using file.readline and convert
each line to int</li>
<li>increment counter for each value in
your countDict</li>
<li>at last go thru dict using for intV,
count in countDict.iteritems() and
pri... | 1 | 2009-06-26T06:29:22Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,642 | <p>Use dictionary where every line is a key, and count is value. Increment count for every line, and if there is no dictionary entry for line initialize it with 1 in except clause -- this should work with older versions of Python.</p>
<pre><code>def count_same_lines(fname):
line_counts = {}
for l in file(fnam... | 1 | 2009-06-26T06:32:19Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,649 | <p>Read the lines of the file into a list <code>l</code>, e.g.:</p>
<pre><code>l = [int(line) for line in open('filename','r')]
</code></pre>
<p>Starting with a list of values <code>l</code>, you can create a dictionary <code>d</code> that gives you for each value in the list the number of occurrences like this:</p>
... | 2 | 2009-06-26T06:33:52Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,655 | <p>I think what you call map is, in python, a dictionary.<br />
Here is some useful link on how to use it: <a href="http://docs.python.org/tutorial/datastructures.html#dictionaries" rel="nofollow">http://docs.python.org/tutorial/datastructures.html#dictionaries</a></p>
<p>For a good solution, see the answer from Steph... | 2 | 2009-06-26T06:37:23Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,676 | <pre><code>l = [10,5,-1,-1,-1,1,1,0,2]
d = {}
for x in l:
d[x] = (d[x] + 1) if (x in d) else 1
</code></pre>
<p>There will be a key in d for every distinct value in the original list, and the values of d will be the number of occurrences.</p>
| 0 | 2009-06-26T06:44:22Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,047,692 | <p>This is almost the exact same algorithm described in <a href="#1047634" rel="nofollow">Anurag Uniyal's answer</a>, except using the file as an iterator instead of <code>readline()</code>:</p>
<pre><code>from collections import defaultdict
try:
from io import StringIO # 2.6+, 3.x
except ImportError:
from StringI... | 7 | 2009-06-26T06:48:35Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,048,489 | <p>Counter is your best friend:)<br>
<a href="http://docs.python.org/dev/library/collections.html#counter-objects" rel="nofollow">http://docs.python.org/dev/library/collections.html#counter-objects</a></p>
<p>for(Python2.5 and 2.6) <a href="http://code.activestate.com/recipes/576611/" rel="nofollow">http://code.active... | 5 | 2009-06-26T10:54:28Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,048,564 | <h3>counter.py</h3>
<pre><code>#!/usr/bin/env python
import fileinput
from collections import defaultdict
frequencies = defaultdict(int)
for line in fileinput.input():
frequencies[line.strip()] += 1
print frequencies
</code></pre>
<p>Example: </p>
<pre><code>$ perl -E'say 1*(rand() < 0.5) for (1..100)' | py... | 0 | 2009-06-26T11:15:23Z | [
"python"
] |
How to use dict in python? | 1,047,614 | <pre><code>10
5
-1
-1
-1
1
1
0
2
...
</code></pre>
<p>If I want to count the number of occurrences of each number in a file, how do I use python to do it?</p>
| -2 | 2009-06-26T06:22:44Z | 1,056,894 | <p>New in Python 3.1:</p>
<pre><code>from collections import Counter
with open("filename","r") as lines:
print(Counter(lines))
</code></pre>
| 2 | 2009-06-29T06:54:47Z | [
"python"
] |
PHP Sockets or Python, Perl, Bash Sockets? | 1,047,991 | <p>I'm trying to implement a socket server that will run in most shared PHP hosting.</p>
<p>The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run o... | 2 | 2009-06-26T08:31:30Z | 1,048,024 | <p>Any server can be stopped or started by PHP under Linux. Of course, if you are running a server which accepts sockets from the internet, then you can just connect directly to the server and tell it to shutdown. No need to go via PHP!</p>
<p>As for "starting a server from PHP", well, under Linux, anything can be s... | 7 | 2009-06-26T08:38:58Z | [
"php",
"python",
"perl",
"bash",
"sockets"
] |
PHP Sockets or Python, Perl, Bash Sockets? | 1,047,991 | <p>I'm trying to implement a socket server that will run in most shared PHP hosting.</p>
<p>The requirements are that the Socket server can be installed, started and stopped from PHP automatically without the user doing anything. It doesn't matter what language the socket server is written in, as long as it will run o... | 2 | 2009-06-26T08:31:30Z | 1,592,218 | <p>It really depends on what the install requirements are. Often the easiest and most standard way to write a socket server is to write an <a href="http://en.wikipedia.org/wiki/Inetd#Creating%5Fan%5Finetd%5Fservice" rel="nofollow">inet.d service</a>. This is a standard daemon on my unix machines, and it will fork a p... | 2 | 2009-10-20T02:55:45Z | [
"php",
"python",
"perl",
"bash",
"sockets"
] |
How to sort on number of visits in Django app? | 1,048,265 | <p>In Django (1.0.2), I have 2 models: Lesson and StatLesson.</p>
<pre><code>class Lesson(models.Model):
contents = models.TextField()
def get_visits(self):
return self.statlesson_set.all().count()
class StatLesson(models.Model):
lesson = models.ForeignKey(Lesson)
datetime = models.DateTimeFie... | 2 | 2009-06-26T09:46:50Z | 1,048,364 | <p>Django 1.1 will have aggregate support.</p>
<p>On Django 1.0.x you can count automatically with an extra field:</p>
<pre><code>class Lesson(models.Model):
contents = models.TextField()
visit_count = models.IntegerField(default=0)
class StatLesson(models.Model):
lesson = models.ForeignKey(Lesson)
d... | 2 | 2009-06-26T10:22:31Z | [
"python",
"django"
] |
How to sort on number of visits in Django app? | 1,048,265 | <p>In Django (1.0.2), I have 2 models: Lesson and StatLesson.</p>
<pre><code>class Lesson(models.Model):
contents = models.TextField()
def get_visits(self):
return self.statlesson_set.all().count()
class StatLesson(models.Model):
lesson = models.ForeignKey(Lesson)
datetime = models.DateTimeFie... | 2 | 2009-06-26T09:46:50Z | 1,049,020 | <p>You'll need to do some native SQL stuff using <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none" rel="nofollow">extra</a>.</p>
<p>e.g. (very roughly)</p>
<pre>
<code>
Lesson.objects.extra(select={'visit_count': ... | 1 | 2009-06-26T13:04:25Z | [
"python",
"django"
] |
How to parse for tags with '+' in python | 1,048,541 | <p>I'm getting a "nothing to repeat" error when I try to compile this:</p>
<pre><code>search = re.compile(r'([^a-zA-Z0-9])(%s)([^a-zA-Z0-9])' % '+test', re.I)
</code></pre>
<p>The problem is the '+' sign. How should I handle that?</p>
| 3 | 2009-06-26T11:09:32Z | 1,048,556 | <pre><code>re.compile(r'([^a-zA-Z0-9])(%s)([^a-zA-Z0-9])' % '\+test', re.I)
</code></pre>
<p>The "+" is the "repeat at least once" quantifier in regular expressions. It must follow something that is repeatable, or it must be escaped if you want to match a literal "+".</p>
<p>Better is this, if you want to build your ... | 8 | 2009-06-26T11:12:46Z | [
"python",
"regex"
] |
How to parse for tags with '+' in python | 1,048,541 | <p>I'm getting a "nothing to repeat" error when I try to compile this:</p>
<pre><code>search = re.compile(r'([^a-zA-Z0-9])(%s)([^a-zA-Z0-9])' % '+test', re.I)
</code></pre>
<p>The problem is the '+' sign. How should I handle that?</p>
| 3 | 2009-06-26T11:09:32Z | 1,048,557 | <p>Escape the plus:</p>
<pre><code>r'\+test'
</code></pre>
<p>The plus has a special meaning in regexes (meaning "match the previous once or several times"). Since in your regex it appears after an open paren, there is no "previous" to match repeatedly.</p>
| 4 | 2009-06-26T11:12:54Z | [
"python",
"regex"
] |
Problem deploying Python program (packaged with py2exe) | 1,048,651 | <p>I have a problem: I used py2exe for my program, and it worked on my computer. I packaged it with Inno Setup (still worked on my computer), but when I sent it to a different computer, I got the following error when trying to run the application: "CreateProcess failed; code 14001." The app won't run.
(Note: I am using... | 1 | 2009-06-26T11:36:40Z | 1,048,714 | <p>You can ship the runtime DLLs in question with your application as a "private assembly". This simply means putting a copy of a specially-named directory containing the runtime DLLs and their manifests alongside your executable.</p>
<p>See <a href="http://stackoverflow.com/questions/787216/should-i-link-to-the-visu... | 0 | 2009-06-26T11:48:34Z | [
"python",
"deployment",
"wxpython",
"multiprocessing",
"py2exe"
] |
Problem deploying Python program (packaged with py2exe) | 1,048,651 | <p>I have a problem: I used py2exe for my program, and it worked on my computer. I packaged it with Inno Setup (still worked on my computer), but when I sent it to a different computer, I got the following error when trying to run the application: "CreateProcess failed; code 14001." The app won't run.
(Note: I am using... | 1 | 2009-06-26T11:36:40Z | 1,048,732 | <p>You should be able to install that MS redistributable thingy as a part of your InnoSetup setup exe.</p>
| 1 | 2009-06-26T11:57:06Z | [
"python",
"deployment",
"wxpython",
"multiprocessing",
"py2exe"
] |
Problem deploying Python program (packaged with py2exe) | 1,048,651 | <p>I have a problem: I used py2exe for my program, and it worked on my computer. I packaged it with Inno Setup (still worked on my computer), but when I sent it to a different computer, I got the following error when trying to run the application: "CreateProcess failed; code 14001." The app won't run.
(Note: I am using... | 1 | 2009-06-26T11:36:40Z | 1,049,296 | <p>You need to include msvcr90.dll, Microsoft.VC90.CRT.manifest, and python.exe.manifest (renamed to [yourappname].exe.manifest) in your install directory. These files will be in the Python26 directory on your system if you installed Python with the "Just for me" option.</p>
<p>Instructions for doing this <a href="htt... | 3 | 2009-06-26T13:56:26Z | [
"python",
"deployment",
"wxpython",
"multiprocessing",
"py2exe"
] |
Problem deploying Python program (packaged with py2exe) | 1,048,651 | <p>I have a problem: I used py2exe for my program, and it worked on my computer. I packaged it with Inno Setup (still worked on my computer), but when I sent it to a different computer, I got the following error when trying to run the application: "CreateProcess failed; code 14001." The app won't run.
(Note: I am using... | 1 | 2009-06-26T11:36:40Z | 1,124,797 | <p>When you run py2exe, look closely at the final messages when it's completed. It gives you a list of DLLs that it says are needed by the program, but that py2exe doesn't automatically bundle.</p>
<p>Many in the list are reliably available on any Windows install, but there will be a few that you should manually bundl... | 1 | 2009-07-14T11:27:54Z | [
"python",
"deployment",
"wxpython",
"multiprocessing",
"py2exe"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,674 | <p>I use Python with PIL (Python Image Library). Of course there are specialized programs to do this.</p>
<p>Many people use PIL to such things. Look at: <a href="http://pandemoniumillusion.wordpress.com/2008/05/04/quick-image-resizing-with-python/" rel="nofollow">Quick image resizing with python</a></p>
<p>PIL is ve... | 1 | 2009-06-26T11:39:38Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,685 | <p>Use <a href="http://www.imagemagick.org/script/perl-magick.php" rel="nofollow">PerlMagick</a>, it's an interface to the popular <a href="http://www.imagemagick.org/" rel="nofollow">ImageMagick</a> suite of command line tools to do just this kind of stuff. <a href="http://www.imagemagick.org/script/api.php#python" re... | 2 | 2009-06-26T11:41:49Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,693 | <p>do you need to just resize it or you want to resize programmatically?
If just resize use PixResizer. <a href="http://bluefive.pair.com/pixresizer.htm" rel="nofollow">http://bluefive.pair.com/pixresizer.htm</a></p>
| 0 | 2009-06-26T11:43:05Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,702 | <p>How about using mogrify, part of <a href="http://www.imagemagick.org/">ImageMagick</a>? If you really need to control this from Perl, then you could use <a href="http://search.cpan.org/dist/Image-Magick">Image::Magick</a>, <a href="http://search.cpan.org/dist/Image-Resize">Image::Resize</a> or <a href="http://search... | 11 | 2009-06-26T11:43:41Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,754 | <p>Can it be in shell?</p>
<pre><code>mkdir resized
for a in *.jpg; do convert "$a" -resize 60% resized/"$a"; done
</code></pre>
<p>If you have > 1 core, you can do it like this:</p>
<pre><code>find . -maxdepth 1 -type f -name '*.jpg' -print0 | xargs -0 -P3 -I XXX convert XXX -resize 60% resized/XXX
</code></pre>
<... | 9 | 2009-06-26T12:01:07Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Resize images in directory | 1,048,658 | <p>I have a directory full of images that I would like to resize to around 60% of their original size.</p>
<p>How would I go about doing this? Can be in either Python or Perl</p>
<p>Cheers</p>
<p>Eef</p>
| 4 | 2009-06-26T11:37:32Z | 1,048,793 | <p>If you want to do it programatically, which I assume is the case, use PIL to resize e.g.</p>
<pre><code>newIm = im.resize((newW, newH)
</code></pre>
<p>then save it to same file or a new location.</p>
<p>Go through the folder recursively and apply resize function to all images.</p>
<p>I have come up with a sampl... | 14 | 2009-06-26T12:09:34Z | [
"python",
"perl",
"image",
"resize",
"image-scaling"
] |
Python and PGP/encryption | 1,048,722 | <p>i want to make a function using python to encrypt password by the public key.
at the user end i need to install PGP software which will generate the key pair .i want to use public key only for encryption and private key for decryption.
The problem is coming with the encryption function(how to use key for encryption)... | 5 | 2009-06-26T11:55:12Z | 1,048,740 | <p>Did you check out <a href="http://www.dlitz.net/software/pycrypto/" rel="nofollow">PyCrypto</a>?</p>
| 3 | 2009-06-26T11:58:35Z | [
"python",
"encryption",
"pgp"
] |
Python and PGP/encryption | 1,048,722 | <p>i want to make a function using python to encrypt password by the public key.
at the user end i need to install PGP software which will generate the key pair .i want to use public key only for encryption and private key for decryption.
The problem is coming with the encryption function(how to use key for encryption)... | 5 | 2009-06-26T11:55:12Z | 1,048,742 | <p><a href="http://sourceforge.net/projects/pypgp/" rel="nofollow">Here</a> is an open source project for using pgp with python. I think this is what you're looking for.</p>
<p>You actually don't have to invent the algorithms yourself, they're already there.</p>
| 4 | 2009-06-26T11:59:10Z | [
"python",
"encryption",
"pgp"
] |
Display row count from another table in Django | 1,048,782 | <p>I have the following classes in my models file</p>
<pre><code>class HardwareNode(models.Model):
ip_address = models.CharField(max_length=15)
port = models.IntegerField()
location = models.CharField(max_length=50)
hostname = models.CharField(max_length=30)
def __unicode__(self):
return s... | 2 | 2009-06-26T12:07:40Z | 1,048,802 | <p>In your HardwareNode class keep a list of Subscriptions, and then either create a function that returns the length of that list or just access the variable's length through the HTML. This would be better than going through all of your subscriptions and counting the number of HardwareNodes, especially since Django ma... | 0 | 2009-06-26T12:12:05Z | [
"python",
"django",
"django-models"
] |
Display row count from another table in Django | 1,048,782 | <p>I have the following classes in my models file</p>
<pre><code>class HardwareNode(models.Model):
ip_address = models.CharField(max_length=15)
port = models.IntegerField()
location = models.CharField(max_length=50)
hostname = models.CharField(max_length=30)
def __unicode__(self):
return s... | 2 | 2009-06-26T12:07:40Z | 1,048,886 | <p>When creating a <code>foreign_key</code>, the other model gets a manager that returns all instances of the first model (see <a href="http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward" rel="nofollow">navigating backward</a>)
In your case, it would be named "<code>subscription_se... | 5 | 2009-06-26T12:30:31Z | [
"python",
"django",
"django-models"
] |
How do I link a combo box and a command button? | 1,048,831 | <p>This is my combo box code:</p>
<pre><code>self.lblname = wx.StaticText(self, -1,"Timeslot" ,wx.Point(20,150))
self.sampleList = ['09.00-10.00','10.00-11.00','11.00-12.00']
self.edithear=wx.ComboBox(self, 30, "", wx.Point(150,150 ), wx.Size(95, -1),
self.sampleList, wx.CB_DROPDOWN)
</code></pre>
<p>and this is my... | 1 | 2009-06-26T12:19:51Z | 1,049,583 | <p>If the Onclick method is in the same class you can reach your combo via self.edithear </p>
| 0 | 2009-06-26T14:56:38Z | [
"python",
"wxpython"
] |
wxPython SplitterWindow does not expand within a Panel | 1,049,070 | <p>I'm trying a simple layout and the panel divided by a SplitterWindow doesn't expand to fill the whole area, what I want is this:</p>
<pre><code>[button] <= (fixed size)
---------
TEXT AREA }
~~~~~~~~~ <= (this is the splitter) } this is a panel
TEXT AR... | 3 | 2009-06-26T13:15:43Z | 1,049,162 | <p>The Panel is probably expanding but the ScrolledWindow within the Panel is not, because you aren't using a sizer for the panel, only the frame.</p>
<p>You could also try just having the SplitterWindow be a child of the frame, without the panel.</p>
| 4 | 2009-06-26T13:35:02Z | [
"python",
"user-interface",
"wxpython",
"panel"
] |
Importing database data into Joomla | 1,049,320 | <p>How to import data from a database to Joomla CMS?</p>
<p>I have a database with lots of data I want to use in my new website. An ideal solution for me would be a Python/Perl/PHP API that would know how to do Joomla' basic routines:</p>
<ol>
<li>adding/removing a section/category/material/menu/module;</li>
<li>chan... | 2 | 2009-06-26T14:01:31Z | 1,049,517 | <p>You could try the following extensions:</p>
<ol>
<li><a href="http://extensions.joomla.org/extensions/migration-&-conversion/data-import-&-export/7243/details" rel="nofollow">Bulk Import</a></li>
<li><a href="http://extensions.joomla.org/extensions/migration-&-conversion/extensions-migration/4247/detail... | 1 | 2009-06-26T14:43:26Z | [
"python",
"database",
"api",
"content-management-system",
"joomla"
] |
Dictionaries with volatile values in Python unit tests? | 1,049,551 | <p>I need to write a unit test for a function that returns a dictionary. One of the values in this dictionary is <code>datetime.datetime.now()</code> which of course changes with every test run.</p>
<p>I want to ignore that key completely in my assert. Right now I have a dictionary comparison function but I really wan... | 2 | 2009-06-26T14:49:52Z | 1,049,563 | <p>Just delete the timestamp from the dict before doing the comparison:</p>
<pre><code>class MonkeyTester(unittest.TestCase):
def test_myfunc(self):
without_timestamp = my_func()
del without_timestamp["monkey_creation"]
self.assertEqual(without_timestamp, {'monkey_head_count': 3})
</code></... | 9 | 2009-06-26T14:52:49Z | [
"python",
"unit-testing"
] |
subprocess module: using the call method with tempfile objects | 1,049,648 | <p>I have created temporary named files, with the tempfile libraries NamedTemporaryFile method.
I have written to them flushed the buffers, and I have not closed them (or else they might go away)</p>
<p>I am trying to use the <code>subprocess</code> module to call some shell commands using these generated files.</p>
... | 2 | 2009-06-26T15:10:42Z | 1,049,684 | <p>Are you using shell=True option for subprocess?</p>
| 1 | 2009-06-26T15:16:02Z | [
"python",
"subprocess"
] |
subprocess module: using the call method with tempfile objects | 1,049,648 | <p>I have created temporary named files, with the tempfile libraries NamedTemporaryFile method.
I have written to them flushed the buffers, and I have not closed them (or else they might go away)</p>
<p>I am trying to use the <code>subprocess</code> module to call some shell commands using these generated files.</p>
... | 2 | 2009-06-26T15:10:42Z | 1,049,697 | <p>Why don't you make your <code>NamedTemporaryFile</code>s with the optional parameter <code>delete=False</code>? That way you can safely close them knowing they won't disappear, use them normally afterwards, and explicitly unlink them when you're done. This way everything will work cross-platform, too.</p>
| 3 | 2009-06-26T15:16:49Z | [
"python",
"subprocess"
] |
When I write a python script to run Devenv with configure "Debug|Win32" it does nothing | 1,049,784 | <p><strong>Update:</strong> When I use the <code>subprocess.call</code> instead of <code>subprocess.Popen</code>, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from <code>subprocess.ca... | 6 | 2009-06-26T15:31:05Z | 1,049,799 | <p>try double quoting like: 'devenv A.sln /build "Debug|Win32"'</p>
| 0 | 2009-06-26T15:35:30Z | [
"python",
"subprocess"
] |
When I write a python script to run Devenv with configure "Debug|Win32" it does nothing | 1,049,784 | <p><strong>Update:</strong> When I use the <code>subprocess.call</code> instead of <code>subprocess.Popen</code>, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from <code>subprocess.ca... | 6 | 2009-06-26T15:31:05Z | 1,049,805 | <p>Looks like Windows' shell is taking that <code>|</code> as a pipe (despite the quotes and escapes). Have you tried <code>shell=False</code> instead?</p>
| 0 | 2009-06-26T15:36:43Z | [
"python",
"subprocess"
] |
When I write a python script to run Devenv with configure "Debug|Win32" it does nothing | 1,049,784 | <p><strong>Update:</strong> When I use the <code>subprocess.call</code> instead of <code>subprocess.Popen</code>, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from <code>subprocess.ca... | 6 | 2009-06-26T15:31:05Z | 1,084,640 | <p>When <code>shell = False</code> is used, it will treat the string as a single command, so you need to pass the command/arugments as a list.. Something like:</p>
<pre><code>from subprocess import Popen, PIPE
cmd = [
r"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv", # in raw r"blah" string, you d... | 0 | 2009-07-05T19:02:02Z | [
"python",
"subprocess"
] |
When I write a python script to run Devenv with configure "Debug|Win32" it does nothing | 1,049,784 | <p><strong>Update:</strong> When I use the <code>subprocess.call</code> instead of <code>subprocess.Popen</code>, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from <code>subprocess.ca... | 6 | 2009-06-26T15:31:05Z | 1,105,047 | <p>There is a difference between <code>devenv.exe</code> and <code>devenv.com</code>, both of which are executable and live in the same directory (sigh). The command lines used in the question and some answers don't say which they want so I'm not sure which will get used.</p>
<p>If you want to call from the command li... | 4 | 2009-07-09T16:34:56Z | [
"python",
"subprocess"
] |
When I write a python script to run Devenv with configure "Debug|Win32" it does nothing | 1,049,784 | <p><strong>Update:</strong> When I use the <code>subprocess.call</code> instead of <code>subprocess.Popen</code>, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from <code>subprocess.ca... | 6 | 2009-06-26T15:31:05Z | 8,438,293 | <p>See section 17.1.5.1. in the python documentation.</p>
<p>On Windows, Python automatically adds the double quotes around the project configuration argument i.e Debug|win32 is passed as "Debug|win32" to devenv. You DON'T need to add the double quotes and you DON'T need to pass shell=True to Popen.</p>
<p>Use ProcMo... | 1 | 2011-12-08T22:00:24Z | [
"python",
"subprocess"
] |
Get remote text file, process, and update database - approach and scripting language to use? | 1,050,089 | <p>I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.</p>
<p>I think the idea would be for ... | 2 | 2009-06-26T16:39:30Z | 1,050,136 | <p>Most modern languages scripting languages allow you to do all of these things. Because of that, I think your choice of language should be based on what you and the people who read your code know. </p>
<p>In Perl I'd make use of the following modules:</p>
<p>Net::FTP to access the ftp sites.
DBI to insert data into... | 1 | 2009-06-26T16:54:08Z | [
"php",
"python",
"perl",
"parsing",
"feeds"
] |
Get remote text file, process, and update database - approach and scripting language to use? | 1,050,089 | <p>I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.</p>
<p>I think the idea would be for ... | 2 | 2009-06-26T16:39:30Z | 1,050,139 | <p>"Best" language is pretty subjective. Python is generally considered to be easy to learn and easy to read, whereas Perl is often jokingly referred to as a "write-only" language. On the other hand, Perl is use extensively for network management. Python tends to be used more for system management or programming in ... | 2 | 2009-06-26T16:54:24Z | [
"php",
"python",
"perl",
"parsing",
"feeds"
] |
Get remote text file, process, and update database - approach and scripting language to use? | 1,050,089 | <p>I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.</p>
<p>I think the idea would be for ... | 2 | 2009-06-26T16:39:30Z | 1,050,150 | <p>Kind of depends on the format of the files you're ftp'ing. If it's a crazy proprietary format, you might be stuck with whatever language already has a library managing it. If it's CSV or XML, then any language might do.</p>
<ul>
<li>FTP: <a href="http://search.cpan.org/~gbarr/libnet-1.22/Net/FTP.pm" rel="nofollow... | 3 | 2009-06-26T16:58:06Z | [
"php",
"python",
"perl",
"parsing",
"feeds"
] |
Get remote text file, process, and update database - approach and scripting language to use? | 1,050,089 | <p>I've been having to do some basic feed processing. So, get a file via ftp, process it (i.e. get the fields I care about), and then update the local database. And similarly the other direction: get data from db, create file, and upload by ftp. The scripts will be called by cron.</p>
<p>I think the idea would be for ... | 2 | 2009-06-26T16:39:30Z | 1,050,190 | <p><strong>Python</strong>.</p>
<p>1st. What format are these FTP'd files? I'll assume they're CSV.</p>
<p>2nd. How do you know when to run the FTP get? Fixed schedule? Event? I'll assume it's a fixed schedule. You'll use cron to control this.</p>
<p>You have three issues: FTP get, data extract, DB load. <... | 1 | 2009-06-26T17:08:06Z | [
"php",
"python",
"perl",
"parsing",
"feeds"
] |
webdav for wsgi/python? | 1,050,217 | <p>I want to add WebDAV to <a href="http://whiff.sourceforge.net" rel="nofollow">whiff</a>. This would be easy if I could find a simple WSGI component that implements WebDAV. I found <a href="http://pyfilesync.berlios.de/pyfileserver.html" rel="nofollow">http://pyfilesync.berlios.de/pyfileserver.html</a>, but it seems ... | 1 | 2009-06-26T17:16:49Z | 1,126,368 | <p>I recently picked up PyFileServer for further development:
<a href="http://code.google.com/p/wsgidav/" rel="nofollow">http://code.google.com/p/wsgidav/</a></p>
<p>After the config file is read, it's only a plain dictionary, that is passed to the WSGI Application object's constructor.
So it should be pretty easy... | 3 | 2009-07-14T15:57:27Z | [
"python",
"webdav",
"wsgi"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,050,835 | <p>That depends on how the data is structured, and what kind of changes you need to do.</p>
<p>One option might be to parse that into a Python data structure, it seems similar, except that you don't have quotes around the strings. That makes complex manipulation easy.</p>
<p>On the other hand, if all you need to do i... | 1 | 2009-06-26T19:33:11Z | [
"python",
"parsing",
"data-structures"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,050,862 | <p>This is a pretty similar problem to XML processing, and there's a lot of Python code to do that. So if you could somehow convert the file to XML, you could just run it through a parser from the standard library. An XML version of your example would be something like this:</p>
<pre><code><group id="Group1"> ... | 1 | 2009-06-26T19:40:14Z | [
"python",
"parsing",
"data-structures"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,050,963 | <p>The data structure basically seems to be a dict where they keys are strings and the value is either a string or another dict of the same type, so I'd recommend maybe pulling it into that sort of python structure,</p>
<p>eg:</p>
<pre><code>{'group1': {'Entry2': {}, 'Entry1': {'Title1':{'Data4': 'Member4',
'Data1': ... | 3 | 2009-06-26T19:56:16Z | [
"python",
"parsing",
"data-structures"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,050,976 | <p>If you have the grammar for the structure of your data file, or you can create it yourself, you could use a parser generator for Python, like YAPPS: <a href="http://theory.stanford.edu/~amitp/yapps/" rel="nofollow">link text</a>.</p>
| 2 | 2009-06-26T19:58:29Z | [
"python",
"parsing",
"data-structures"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,051,444 | <p>I have something similar but written in java. It parses a file with the same basic structure with a little different syntax (no '{' and '}' only indentation like in python). It is a very simple script language.</p>
<p>Basically it works like this: It uses a stack to keep track of the inner most block of instructio... | 1 | 2009-06-26T21:56:48Z | [
"python",
"parsing",
"data-structures"
] |
Parsing an unknown data structure in python | 1,050,773 | <p>I have a file containing lots of data put in a form similar to this:</p>
<pre><code>Group1 {
Entry1 {
Title1 [{Data1:Member1, Data2:Member2}]
Title2 [{Data3:Member3, Data4:Member4}]
}
Entry2 {
...
}
}
Group2 {
DifferentEntry1 {
DiffTitle1 {
... | 3 | 2009-06-26T19:19:48Z | 1,051,645 | <p>Here is a grammar.</p>
<pre><code>dict_content : NAME ':' NAME [ ',' dict_content ]?
| NAME '{' [ dict_content ]? '}' [ dict_content ]?
| NAME '[' [ list_content ]? ']' [ dict_content ]?
;
list_content : NAME [ ',' list_content ]?
| '{' [ dict_content ]? '}' [ ',... | 3 | 2009-06-26T22:59:43Z | [
"python",
"parsing",
"data-structures"
] |
Check if Python Package is installed | 1,051,254 | <p>What's a good way to check if a package is installed while within a Python script? I know it's easy from the interpreter, but I need to do it within a script. </p>
<p>I guess I could check if there's a directory on the system that's created during the installation, but I feel like there's a better way. I'm trying t... | 40 | 2009-06-26T20:54:38Z | 1,051,265 | <p>Go option #2. If <code>ImportError</code> is thrown, then the package is not installed (or not in <code>sys.path</code>).</p>
| 0 | 2009-06-26T20:59:14Z | [
"python",
"package",
"skype",
"python-import"
] |
Check if Python Package is installed | 1,051,254 | <p>What's a good way to check if a package is installed while within a Python script? I know it's easy from the interpreter, but I need to do it within a script. </p>
<p>I guess I could check if there's a directory on the system that's created during the installation, but I feel like there's a better way. I'm trying t... | 40 | 2009-06-26T20:54:38Z | 1,051,266 | <p>If you mean a python script, just do something like this:</p>
<pre><code>try:
import mymodule
except ImportError, e:
pass # module doesn't exist, deal with it.
</code></pre>
| 53 | 2009-06-26T21:00:17Z | [
"python",
"package",
"skype",
"python-import"
] |
Check if Python Package is installed | 1,051,254 | <p>What's a good way to check if a package is installed while within a Python script? I know it's easy from the interpreter, but I need to do it within a script. </p>
<p>I guess I could check if there's a directory on the system that's created during the installation, but I feel like there's a better way. I'm trying t... | 40 | 2009-06-26T20:54:38Z | 27,496,113 | <p>A better way of doing this is:</p>
<pre><code>import pip
installed_packages = pip.get_installed_distributions()
</code></pre>
<p>Why this way? Sometimes you have app name collisions. Importing from the app namespace doesn't give you the full picture of what's installed on the system.</p>
<p>As a result, you get a... | 12 | 2014-12-16T01:29:25Z | [
"python",
"package",
"skype",
"python-import"
] |
Downloading a Large Number of Files from S3 | 1,051,275 | <p>What's the Fastest way to get a large number of files (relatively small 10-50kB) from Amazon S3 from Python? (In the order of 200,000 - million files). </p>
<p>At the moment I am using boto to generate Signed URLs, and using PyCURL to get the files one by one. </p>
<p>Would some type of concurrency help? PyCurl.Cu... | 2 | 2009-06-26T21:02:04Z | 1,051,338 | <p>I don't know anything about python, but in general you would want to break the task down into smaller chunks so that they can be run concurrently. You could break it down by file type, or alphabetical or something, and then run a separate script for each portion of the break down.</p>
| 2 | 2009-06-26T21:22:02Z | [
"python",
"curl",
"amazon-s3",
"amazon-web-services",
"boto"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.