title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
python, sorting a list by a key that's a substring of each element | 440,541 | <p>Part of a programme builds this list,</p>
<pre><code>[u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
</code></pre>
<p>I'm currently trying to sort it alphabetically by the name of the evolution rather than by the... | 10 | 2009-01-13T19:58:28Z | 440,559 | <p>As you are trying to sort what is essentially custom data, I'd go with a custom sort.</p>
<p><a href="http://en.literateprograms.org/Merge_sort_(Python)" rel="nofollow">Merge sort</a><br>
<a href="http://www.codecodex.com/wiki/index.php?title=Bubble_sort#Python" rel="nofollow">Bubble sort</a><br>
<a href="http://en... | -8 | 2009-01-13T20:03:30Z | [
"python",
"list",
"sorting"
] |
python, sorting a list by a key that's a substring of each element | 440,541 | <p>Part of a programme builds this list,</p>
<pre><code>[u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
</code></pre>
<p>I'm currently trying to sort it alphabetically by the name of the evolution rather than by the... | 10 | 2009-01-13T19:58:28Z | 440,562 | <p>You have to get the "key" from the string.</p>
<pre><code>def myKeyFunc( aString ):
stuff, x, label = aString.partition(' x ')
return label
aList.sort( key= myKeyFunc )
</code></pre>
| 23 | 2009-01-13T20:04:35Z | [
"python",
"list",
"sorting"
] |
python, sorting a list by a key that's a substring of each element | 440,541 | <p>Part of a programme builds this list,</p>
<pre><code>[u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
</code></pre>
<p>I'm currently trying to sort it alphabetically by the name of the evolution rather than by the... | 10 | 2009-01-13T19:58:28Z | 440,587 | <p>Not knowing if your items are standardized at 1 digit, 1 space, 1 'x', 1 space, multiple words I wrote this up:</p>
<pre>mylist = [u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
def sort(a, b):
return cmp(" ".jo... | 2 | 2009-01-13T20:09:50Z | [
"python",
"list",
"sorting"
] |
python, sorting a list by a key that's a substring of each element | 440,541 | <p>Part of a programme builds this list,</p>
<pre><code>[u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
</code></pre>
<p>I'm currently trying to sort it alphabetically by the name of the evolution rather than by the... | 10 | 2009-01-13T19:58:28Z | 440,599 | <p>How about:</p>
<pre><code>lst.sort(key=lamdba s: s.split(' x ')[1])
</code></pre>
| 9 | 2009-01-13T20:12:33Z | [
"python",
"list",
"sorting"
] |
python, sorting a list by a key that's a substring of each element | 440,541 | <p>Part of a programme builds this list,</p>
<pre><code>[u'1 x Affinity for war', u'1 x Intellect', u'2 x Charisma', u'2 x Perception', u'3 x Population growth', u'4 x Affinity for the land', u'5 x Morale']
</code></pre>
<p>I'm currently trying to sort it alphabetically by the name of the evolution rather than by the... | 10 | 2009-01-13T19:58:28Z | 440,611 | <p>To do so, you need to implement a custom compare:</p>
<pre><code>def myCompare(x, y):
x_name = " ".join(x.split()[2:])
y_name = " ".join(y.split()[2:])
return cmp(x_name, y_name)
</code></pre>
<p>Then you use that compare definition as the input to your sort function:</p>
<pre><code>myList.sort(myCompare... | 1 | 2009-01-13T20:15:31Z | [
"python",
"list",
"sorting"
] |
Installing Python 3.0 on Cygwin | 440,547 | <h3>The Question</h3>
<p>What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?</p>
<h3>Notes</h3>
<p>I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (<code>/lib/python2.x</code>, not <code>c:\python2.x</code>).</p>
<p>Also, I would like to be able to cal... | 11 | 2009-01-13T20:00:20Z | 440,970 | <p>The standard <code>make install</code> target of the Python 3.0 sources doesn't install a python binary. Instead, make install prints at the end</p>
<pre><code>* Note: not installed as 'python'.
* Use 'make fullinstall' to install as 'python'.
* However, 'make fullinstall' is discouraged,
* as it will clobber your ... | 8 | 2009-01-13T21:55:50Z | [
"python",
"windows",
"cygwin"
] |
Installing Python 3.0 on Cygwin | 440,547 | <h3>The Question</h3>
<p>What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?</p>
<h3>Notes</h3>
<p>I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (<code>/lib/python2.x</code>, not <code>c:\python2.x</code>).</p>
<p>Also, I would like to be able to cal... | 11 | 2009-01-13T20:00:20Z | 516,953 | <p>Over in the Perl world, I always install my own, with a prefix:</p>
<pre><code>./configure --prefix=/usr/local/perl/5.10.0
</code></pre>
<p>I never want to deal with whatever perl came with my OS, as I don't want to install libraries for it and potentially mess up scripts that were written in the OS.</p>
<p>I do ... | 2 | 2009-02-05T17:34:14Z | [
"python",
"windows",
"cygwin"
] |
Installing Python 3.0 on Cygwin | 440,547 | <h3>The Question</h3>
<p>What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?</p>
<h3>Notes</h3>
<p>I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (<code>/lib/python2.x</code>, not <code>c:\python2.x</code>).</p>
<p>Also, I would like to be able to cal... | 11 | 2009-01-13T20:00:20Z | 3,281,136 | <p>To use Python 3 in a non-intrusive manner, if you don't have one already, create a file called ".bash_profile" in your user home directory.</p>
<p>Set up an alias pointing at your Python 3 install. On my Windows machine this looks like so:</p>
<pre><code>alias python3=/cygdrive/d/apps/Python31/python
export python... | 3 | 2010-07-19T12:51:03Z | [
"python",
"windows",
"cygwin"
] |
Installing Python 3.0 on Cygwin | 440,547 | <h3>The Question</h3>
<p>What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?</p>
<h3>Notes</h3>
<p>I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (<code>/lib/python2.x</code>, not <code>c:\python2.x</code>).</p>
<p>Also, I would like to be able to cal... | 11 | 2009-01-13T20:00:20Z | 11,666,901 | <p>As of yesterday (Wed 25 July 2012), <a href="http://cygwin.com/ml/cygwin/2012-07/msg00553.html">Python 3.2.3 is included in the standard Cygwin installer</a>. Just run Cygwin's <code>setup.exe</code> again (download it from <a href="http://www.cygwin.com">cygwin.com</a> again if you need to), and you should be able ... | 9 | 2012-07-26T09:59:15Z | [
"python",
"windows",
"cygwin"
] |
Installing Python 3.0 on Cygwin | 440,547 | <h3>The Question</h3>
<p>What is the correct way to install Python 3.0 alongside Python 2.x using Cygwin?</p>
<h3>Notes</h3>
<p>I already have a working copy of Cygwin, and Python 2.x is installed within Cygwin (<code>/lib/python2.x</code>, not <code>c:\python2.x</code>).</p>
<p>Also, I would like to be able to cal... | 11 | 2009-01-13T20:00:20Z | 23,507,995 | <p>instead of invoking python from the command line just invoke python3 like so:</p>
<pre><code>python3 script1.py
</code></pre>
| -2 | 2014-05-07T03:03:12Z | [
"python",
"windows",
"cygwin"
] |
Python classes from a for loop | 440,676 | <p>I've got a piece of code which contains a for loop to draw things from an XML file;</p>
<pre><code> for evoNode in node.getElementsByTagName('evolution'):
evoName = getText(evoNode.getElementsByTagName( "type")[0].childNodes)
evoId = getText(evoNode.getElementsByTagName( "typeid")[... | 2 | 2009-01-13T20:31:45Z | 440,687 | <pre><code>for evoNode in node.getElementsByTagName('evolution'):
evoName = getText(evoNode.getElementsByTagName("type")[0].childNodes)
evoId = getText(evoNode.getElementsByTagName("typeid")[0].childNodes)
evoLevel = getText(evoNode.getElementsByTagName("level")[0].childNodes)
evoCost = getText... | 3 | 2009-01-13T20:35:25Z | [
"python",
"class",
"for-loop"
] |
Python classes from a for loop | 440,676 | <p>I've got a piece of code which contains a for loop to draw things from an XML file;</p>
<pre><code> for evoNode in node.getElementsByTagName('evolution'):
evoName = getText(evoNode.getElementsByTagName( "type")[0].childNodes)
evoId = getText(evoNode.getElementsByTagName( "typeid")[... | 2 | 2009-01-13T20:31:45Z | 440,749 | <p>A list comprehension might be a little cleaner. I'd also move the parsing logic to the constructor to clean up the implemenation:</p>
<pre><code>class Evolution:
def __init__(self, node):
self.node = node
self.type = property("type")
self.typeid = property("typeid")
self.level = ... | 4 | 2009-01-13T20:51:11Z | [
"python",
"class",
"for-loop"
] |
Reading Command Line Arguments of Another Process (Win32 C code) | 440,932 | <p>I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID <em>XXX</em>. </p>
<p>I'm working on a core piece of a <a href="http://code... | 9 | 2009-01-13T21:46:40Z | 440,946 | <p>If you aren't the parent of these processes, then this is not possible using documented functions :( Now, if you're the parent, you can do your CreateRemoteThread trick, but otherwise you will almost certainly get Access Denied unless your app has admin rights.</p>
| 0 | 2009-01-13T21:50:05Z | [
"python",
"c",
"winapi"
] |
Reading Command Line Arguments of Another Process (Win32 C code) | 440,932 | <p>I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID <em>XXX</em>. </p>
<p>I'm working on a core piece of a <a href="http://code... | 9 | 2009-01-13T21:46:40Z | 440,950 | <p>The cached solution:
<a href="http://74.125.45.132/search?q=cache:-wPkE2PbsGwJ:windowsxp.mvps.org/listproc.htm+running+process+command+line&hl=es&ct=clnk&cd=1&gl=ar&client=firefox-a">http://74.125.45.132/search?q=cache:-wPkE2PbsGwJ:windowsxp.mvps.org/listproc.htm+running+process+command+line&... | 5 | 2009-01-13T21:50:42Z | [
"python",
"c",
"winapi"
] |
Reading Command Line Arguments of Another Process (Win32 C code) | 440,932 | <p>I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID <em>XXX</em>. </p>
<p>I'm working on a core piece of a <a href="http://code... | 9 | 2009-01-13T21:46:40Z | 442,034 | <p>The WMI approach mentioned in another response is probably the most <em>reliable</em> way of doing this. Looking through MSDN, I spotted what looks like another possible approach; it's documented, but its not clear whether it's fully supported. In MSDN's language, it--</p>
<blockquote>
<p>may be altered or unav... | 2 | 2009-01-14T05:44:43Z | [
"python",
"c",
"winapi"
] |
Reading Command Line Arguments of Another Process (Win32 C code) | 440,932 | <p>I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID <em>XXX</em>. </p>
<p>I'm working on a core piece of a <a href="http://code... | 9 | 2009-01-13T21:46:40Z | 447,907 | <p>To answer my own question, I finally found a CodeProject solution that does exactly what I'm looking for: </p>
<p><a href="http://www.codeproject.com/KB/threads/GetNtProcessInfo.aspx" rel="nofollow">http://www.codeproject.com/KB/threads/GetNtProcessInfo.aspx</a> </p>
<p>As @Reuben already pointed out, you can use ... | 6 | 2009-01-15T18:34:51Z | [
"python",
"c",
"winapi"
] |
Reading Command Line Arguments of Another Process (Win32 C code) | 440,932 | <p>I need to be able to list the command line arguments (if any) passed to other running processes. I have the PIDs already of the running processes on the system, so basically I need to determine the arguments passed to process with given PID <em>XXX</em>. </p>
<p>I'm working on a core piece of a <a href="http://code... | 9 | 2009-01-13T21:46:40Z | 4,229,778 | <p>By using psutil ( <a href="https://github.com/giampaolo/psutil" rel="nofollow">https://github.com/giampaolo/psutil</a> ):</p>
<pre><code>>>> import psutil, os
>>> psutil.Process(os.getpid()).cmdline()
['C:\\Python26\\python.exe', '-O']
>>>
</code></pre>
| 3 | 2010-11-19T22:00:34Z | [
"python",
"c",
"winapi"
] |
Efficient layout for a distributed python server? | 441,061 | <p>If I wanted to have Python distributed across multiple processors on multiple computers, what would my best approach be? If I have 3 eight-core servers, that would mean I would have to run 24 python processes. I would be using the <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiproc... | 2 | 2009-01-13T22:18:32Z | 441,140 | <p>I think more information would be helpful, on what sort of thing you are serving, what sort of database you'd use, what sort of latency/throughput requirements you have, etc. Lots of stuff depends on your requirements: eg. if your system is a typical server which has a lot of reads and not so many writes, and you do... | 3 | 2009-01-13T22:38:10Z | [
"python",
"multiprocessing"
] |
Efficient layout for a distributed python server? | 441,061 | <p>If I wanted to have Python distributed across multiple processors on multiple computers, what would my best approach be? If I have 3 eight-core servers, that would mean I would have to run 24 python processes. I would be using the <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiproc... | 2 | 2009-01-13T22:18:32Z | 441,166 | <p>You have two main challenges in distributing the processes:</p>
<ol>
<li>Co-ordinating the work being split up, distributed and re-collected (mapped and reduced, you might say)</li>
<li>Sharing the right live data between co-dependent processes</li>
</ol>
<p>The answer to #1 will very much depend on what sort of p... | 3 | 2009-01-13T22:45:17Z | [
"python",
"multiprocessing"
] |
Efficient layout for a distributed python server? | 441,061 | <p>If I wanted to have Python distributed across multiple processors on multiple computers, what would my best approach be? If I have 3 eight-core servers, that would mean I would have to run 24 python processes. I would be using the <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiproc... | 2 | 2009-01-13T22:18:32Z | 442,217 | <p>Seems the gist of your question is how to share objects and state. More information, particularly size, frequency, rate of change, and source of data would be very helpful.</p>
<p>For cross machine shared memory you probably want to look at <a href="http://www.danga.com/memcached/" rel="nofollow">memcached</a>. You... | 0 | 2009-01-14T07:48:08Z | [
"python",
"multiprocessing"
] |
How to add additional information to a many-to-many relation? | 441,114 | <p>I'm writing a program to manage orders and then print them.</p>
<p>An order is an object containing the ordering person, the date and the products this person orders. I'd like to add the amount of a certain product one orderer. E.g. 3 eggs, 2 breads.</p>
<p>Is there a simpler way doing this with storm (the ORM I'm... | 1 | 2009-01-13T22:32:28Z | 441,195 | <p>What's wrong with adding extra columns to the intersection table of the many-to-many relationship? </p>
<pre><code>CREATE TABLE orders (
person_id INT NOT NULL,
product_id INT NOT NULL,
quantity INT NOT NULL DEFAULT 1,
PRIMARY KEY (person_id, product_id),
FOREIGN KEY (person_id) REFERENCES persons(person... | 3 | 2009-01-13T22:55:01Z | [
"python",
"database",
"sqlite",
"orm",
"storm-orm"
] |
Using "with" statement for CSV files in Python | 441,130 | <p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p>
<pre><code>import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
</code></pre>
<p>But csv.reader doesn't provide the <code>__enter__</code> and <... | 13 | 2009-01-13T22:36:28Z | 441,167 | <p>Yes. The second way is correct.</p>
<p>As to why? Who ever knows. You're right, it's probably an easy change. It's not as high priority as other things.</p>
<p>You can easily make your own patch kit and submit it.</p>
| 3 | 2009-01-13T22:45:20Z | [
"python",
"csv",
"with-statement"
] |
Using "with" statement for CSV files in Python | 441,130 | <p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p>
<pre><code>import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
</code></pre>
<p>But csv.reader doesn't provide the <code>__enter__</code> and <... | 13 | 2009-01-13T22:36:28Z | 441,446 | <p>The primary use of <code>with</code> statement is an exception-safe cleanup of an object used in the statement. <code>with</code> makes sure that files are closed, locks are released, contexts are restored, etc.</p>
<p>Does <a href="http://docs.python.org/library/csv.html#csv.reader">csv.reader</a> have things to c... | 18 | 2009-01-14T00:24:41Z | [
"python",
"csv",
"with-statement"
] |
Using "with" statement for CSV files in Python | 441,130 | <p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p>
<pre><code>import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
</code></pre>
<p>But csv.reader doesn't provide the <code>__enter__</code> and <... | 13 | 2009-01-13T22:36:28Z | 441,656 | <p>It's easy to create what you want using a generator function:</p>
<pre><code>
import csv
from contextlib import contextmanager
@contextmanager
def opencsv(path):
yield csv.reader(open(path))
with opencsv("myfile.csv") as reader:
# do stuff with your csvreader
</code></pre>
| 0 | 2009-01-14T02:01:06Z | [
"python",
"csv",
"with-statement"
] |
Using "with" statement for CSV files in Python | 441,130 | <p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p>
<pre><code>import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
</code></pre>
<p>But csv.reader doesn't provide the <code>__enter__</code> and <... | 13 | 2009-01-13T22:36:28Z | 441,962 | <p>The problem is csv.reader doesn't really manage a context. It can accept any iterable, not just a file. Therefore it doesn't call close on its input (incidentally if it did you could use contextlib.closing). So it's not obvious what context support for csv.reader would actually do.</p>
| 2 | 2009-01-14T04:57:06Z | [
"python",
"csv",
"with-statement"
] |
Using "with" statement for CSV files in Python | 441,130 | <p>Is it possible to use the <code>with</code> statement directly with CSV files? It seems natural to be able to do something like this:</p>
<pre><code>import csv
with csv.reader(open("myfile.csv")) as reader:
# do things with reader
</code></pre>
<p>But csv.reader doesn't provide the <code>__enter__</code> and <... | 13 | 2009-01-13T22:36:28Z | 6,207,762 | <pre><code>import csv
class CSV(object):
def __init__(self,path,mode):
self.path = path
self.mode = mode
self.file = None
def __enter__(self):
self.file = open(self.path,self.mode)
if self.mode == 'r':
return csv.reader(self.file)
elif self.mode == '... | 0 | 2011-06-01T21:11:58Z | [
"python",
"csv",
"with-statement"
] |
How can I subtract a day from a Python date? | 441,147 | <p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| 330 | 2009-01-13T22:39:36Z | 441,152 | <p>You can use a <a href="http://docs.python.org/3.3/library/datetime.html?highlight=datetime#timedelta-objects">timedelta</a> object:</p>
<pre><code>from datetime import datetime, timedelta
d = datetime.today() - timedelta(days=days_to_subtract)
</code></pre>
| 535 | 2009-01-13T22:41:39Z | [
"python",
"datetime",
"date"
] |
How can I subtract a day from a Python date? | 441,147 | <p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| 330 | 2009-01-13T22:39:36Z | 441,154 | <p>Subtract <code>datetime.timedelta(days=1)</code></p>
| 47 | 2009-01-13T22:42:03Z | [
"python",
"datetime",
"date"
] |
How can I subtract a day from a Python date? | 441,147 | <p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| 330 | 2009-01-13T22:39:36Z | 24,045,285 | <p>Just to Elaborate <strong>an alternate method</strong> and a Use case for which it is helpful:</p>
<ul>
<li>Subtract 1 day from current datetime:</li>
</ul>
<blockquote>
<pre><code>from datetime import datetime, timedelta
print datetime.now() + timedelta(days=-1) # Here, I am adding a negative timedelta
</code></... | 14 | 2014-06-04T18:48:53Z | [
"python",
"datetime",
"date"
] |
How can I subtract a day from a Python date? | 441,147 | <p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| 330 | 2009-01-13T22:39:36Z | 25,427,822 | <p>If your Python datetime object is timezone-aware than you should be careful to avoid errors around DST transitions (or changes in UTC offset for other reasons):</p>
<pre><code>from datetime import datetime, timedelta
from tzlocal import get_localzone # pip install tzlocal
DAY = timedelta(1)
local_tz = get_localzon... | 17 | 2014-08-21T13:38:27Z | [
"python",
"datetime",
"date"
] |
How can I subtract a day from a Python date? | 441,147 | <p>I have a Python <a href="https://docs.python.org/library/datetime.html#datetime-objects"><code>datetime.datetime</code></a> object. What is the best way to subtract one day?</p>
| 330 | 2009-01-13T22:39:36Z | 29,104,710 | <p>Also just another nice function i like to use when i want to compute i.e. first/last day of the last month or other relative timedeltas etc. ...</p>
<p>The relativedelta function from <a href="https://dateutil.readthedocs.org/en/latest/" rel="nofollow">dateutil</a> function (a powerful extension to the datetime lib... | 4 | 2015-03-17T16:36:15Z | [
"python",
"datetime",
"date"
] |
Py2Exe - "The application configuration is incorrect." | 441,256 | <p>I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.</p>
<p>The client does not have adm... | 5 | 2009-01-13T23:11:01Z | 441,473 | <p>Give <a href="http://code.google.com/p/gui2exe/" rel="nofollow">GUI2exe</a> a shot; it's developed by Andrea Gavana who's big in the wxpython community and wraps a bunch of the freezers, including py2exe. It's likely a dll issue, try <a href="http://www.google.com/search?hl=en&client=firefox-a&rls=org.mozil... | 3 | 2009-01-14T00:39:30Z | [
"python",
"wxpython",
"compilation",
"py2exe"
] |
Py2Exe - "The application configuration is incorrect." | 441,256 | <p>I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.</p>
<p>The client does not have adm... | 5 | 2009-01-13T23:11:01Z | 441,590 | <p>I've ran into this myself and my random Googling has pointed me to several people saying to downgrade python 2.6 to 2.5, which worked for me.</p>
| 1 | 2009-01-14T01:33:58Z | [
"python",
"wxpython",
"compilation",
"py2exe"
] |
Py2Exe - "The application configuration is incorrect." | 441,256 | <p>I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.</p>
<p>The client does not have adm... | 5 | 2009-01-13T23:11:01Z | 455,160 | <p>Good that you found a workaround (downgrading python). I had the same error once (assume you are using Windows) and i think i just had to play around with the XML-manifest file which was added by py2exe. </p>
<p>You might want to post your setup.py and manifest file and i'll have a look at it. </p>
| 2 | 2009-01-18T13:50:41Z | [
"python",
"wxpython",
"compilation",
"py2exe"
] |
Py2Exe - "The application configuration is incorrect." | 441,256 | <p>I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.</p>
<p>The client does not have adm... | 5 | 2009-01-13T23:11:01Z | 929,765 | <p>I have run into similar problem few minutes ago. I couldn't run py2exe installation file, it kept saying that application configuration was incorrect. Downgrading to python 2.5 didn't work for me because I used 'with' statements through out the code and didn't want to change it. </p>
<p>I reinstalled python 2.6 and... | 0 | 2009-05-30T13:58:04Z | [
"python",
"wxpython",
"compilation",
"py2exe"
] |
Py2Exe - "The application configuration is incorrect." | 441,256 | <p>I've compiled my Python program using Py2Exe, and on the client's computer we've satisfied all the dependencies using dependency walker, but we still get "The application configuration is incorrect. Reinstalling the application may correct the problem." I'm also using wxPython.</p>
<p>The client does not have adm... | 5 | 2009-01-13T23:11:01Z | 1,299,541 | <p>Just ran into this same issue with python 2.6, PyQt and py2exe. The root cause was a missing dependency, resolved by installing <a href="http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=en" rel="nofollow">the visual studio 2008 SP1 redist(x86)</a>.</p>
| 1 | 2009-08-19T12:15:28Z | [
"python",
"wxpython",
"compilation",
"py2exe"
] |
Why am I seeing 'connection reset by peer' error? | 441,374 | <p>I am testing <a href="http://code.google.com/p/cogen/" rel="nofollow">cogen</a> on a Mac OS X 10.5 box using python 2.6.1. I have a simple echo server and client-pumper that creates 10,000 client connections as a test. 1000, 5000, etc. all work splendidly. However at around 10,000 connections, the server starts d... | 3 | 2009-01-13T23:52:10Z | 441,383 | <p>Python's socket I/O sometimes suffers from connection reset by peer. It has to do with the Global Interpreter Lock and how threads are scheduled. I <a href="http://homepage.mac.com/s_lott/iblog/architecture/C551260341/E20081031204203/index.html">blogged</a> some references on the subject.</p>
<p>The <code>time.s... | 8 | 2009-01-13T23:56:45Z | [
"python",
"sockets",
"network-programming",
"system"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 441,786 | <p>I've done this by using <a href="http://python.net/crew/mhammond/win32/Downloads.html" rel="nofollow">pywin32</a>. It's not a particularly pleasant experience, since there's not really any abstraction; it's like using VBA, but with python syntax. You can't rely on docstrings, so you'll want to have the MSDN Excel re... | 18 | 2009-01-14T03:11:30Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 445,961 | <p>For controlling Excel, use pywin32, like @igowen suggests.</p>
<p>Note that it is possible to use static dispatch. Use <code>makepy.py</code> from the pywin32 project to create a python module with the python wrappers. Using the generated wrappers simplifies development, since for instance ipython gives you tab com... | 44 | 2009-01-15T07:48:43Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 446,586 | <p>I worked on a home project last year that involves a client written as a Python Excel plug-in. The project is essentially an online database simplified for end-user access. The Excel plug-in allows users to query data out of the database to display in Excel.</p>
<p>I never got very far with the Excel plug-in and ... | 1 | 2009-01-15T12:41:21Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 10,977,701 | <p>Check out the <a href="http://datanitro.com/">DataNitro</a> project (previous name IronSpread). It is a Python plug-in for Excel.</p>
| 8 | 2012-06-11T09:43:42Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 21,675,661 | <p>I wrote python class that allows working with Excel via COM interface in Windows <a href="http://sourceforge.net/projects/excelcomforpython/" rel="nofollow">http://sourceforge.net/projects/excelcomforpython/</a></p>
<p>The class uses win32com to interact with Excel. You can use class directly or use it as example. ... | 0 | 2014-02-10T11:15:53Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 21,784,848 | <p>There is an interesting project for integrating python into excel as an in-process DLL which can be fount at:</p>
<p><a href="http://opentradingsystem.com/PythonForExcel/main.html" rel="nofollow">http://opentradingsystem.com/PythonForExcel/main.html</a></p>
<p>Another somewhat more simple project along the same id... | 0 | 2014-02-14T16:43:51Z | [
"python",
"excel",
"scripting"
] |
Driving Excel from Python in Windows | 441,758 | <p>We have various spreadsheets that employ deliciously complicated macros and third party extensions to produce complicated models. I'm working on a project that involves slightly tweaking various inputs and seeing the results. Rather than doing this by hand or writing VBA, I'd like to see if I can write a python sc... | 34 | 2009-01-14T02:53:26Z | 32,243,333 | <p>I've spent about a week, and here's my implementation (or rather proof-of-concept): <a href="https://github.com/Winand/SimplePython" rel="nofollow">https://github.com/Winand/SimplePython</a></p>
<p>Main idea is to make Python code as easy to write and call from Microsoft Office as VBA macros (i've made Add-In only ... | 0 | 2015-08-27T07:36:55Z | [
"python",
"excel",
"scripting"
] |
Pythoncard item setsize | 441,815 | <p>Below is the base class of my pythoncard application</p>
<pre><code>class MyBackground(model.Background):
def on_initialize(self, event):
# if you have any initialization
# including sizer setup, do it here
self.setLayout()
def setLayout(self):
sizer1 = wx.BoxSizer(wx.VERTI... | 2 | 2009-01-14T03:29:10Z | 1,614,385 | <p>Why 80,21?
You told it to make the item 732,220 and that's what it did.</p>
<p>Or is there something else that you didn't tell us?</p>
| 0 | 2009-10-23T15:55:26Z | [
"python",
"wxpython",
"pythoncard"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 441,830 | <p>There's no real difference between them, people just follow the conventions the creators have chosen.</p>
| -1 | 2009-01-14T03:41:23Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 441,854 | <p>Probably one reason for the different terminology is that one normally thinks of feeding the python interpreter raw human-readable source code and not worrying about bytecode and all that. </p>
<p>In Java, you have to explicitly compile to bytecode and then run just the bytecode, not source code on the VM. </p>
... | 49 | 2009-01-14T03:56:21Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 441,901 | <p>The term interpreter is a legacy term dating back to earlier shell scripting languages. As "scripting languages" have evolved into full featured languages and their corresponding platforms have become more sophisticated and sandboxed, the distinction between a virtual machine and an interpreter (in the Python sense... | 6 | 2009-01-14T04:27:47Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 441,926 | <p>Don't forget that Python has JIT compilers available for x86, further confusing the issue. (See psyco).</p>
<p>A more strict interpretation of an 'interpreted language' only becomes useful when discussing performance issues of the VM, for example, compared with Python, Ruby was (is?) considered to be slower because... | 3 | 2009-01-14T04:36:21Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 441,973 | <p>A virtual machine is a virtual computing environment with a specific set of atomic well defined instructions that are supported independent of any specific language and it is generally thought of as a sandbox unto itself. The VM is analogous to an instruction set of a specific CPU and tends to work at a more fundame... | 84 | 2009-01-14T05:06:47Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 442,146 | <p>In my humble opinion, terms like "Virtual Machine" and "Write once, run anywhere" are marketing buzz words, that just describe an interpreter environment.</p>
<p>However, one has to note that java doesn't come with a command line interpreter like python. </p>
| -1 | 2009-01-14T06:56:43Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 442,210 | <p><strong>Interpreter</strong>, translates source code into some efficient intermediate representation (code) and immediately executes this.</p>
<p><strong>Virtual Machine</strong>, explicitly executes stored pre-compiled code built by a compiler which is part of the interpreter system.</p>
<p>A very important chara... | 10 | 2009-01-14T07:44:54Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 1,732,383 | <p>In this post, "virtual machine" refers to process virtual machines, not to
system virtual machines like Qemu or Virtualbox. A process virtual machine is
simply a program which provides a general programming environment -- a program
which can be programmed. </p>
<p>Java has an interpreter as well as a virtual mach... | 75 | 2009-11-13T22:47:18Z | [
"java",
"python",
"jvm"
] |
Java "Virtual Machine" vs. Python "Interpreter" parlance? | 441,824 | <p>It's seems rare to read of a Python "virtual machine" while in Java "virtual machine" is used all the time. Both interpret byte codes, why call one a virtual machine and the other an interpreter? </p>
| 110 | 2009-01-14T03:39:32Z | 39,804,828 | <p>First of all you should understand that programming or computer science in general is not mathematics and we don't have rigorous definitions for most of the terms we use often.</p>
<p>now to your question :</p>
<p><strong>what is an Interpreter</strong> (in computer science) </p>
<p>It translates source code by s... | 0 | 2016-10-01T09:06:40Z | [
"java",
"python",
"jvm"
] |
IronPython on ASP.NET MVC | 441,838 | <p>Has anyone tried ASP.NET MVC using IronPython? Having done a lot of Python development recently, it would be nice to continue with the language as I go into a potential ASP.NET MVC project.</p>
<p>I'm especially interested in exploiting the dynamic aspects of Python with .NET features such as LINQ and want to know... | 21 | 2009-01-14T03:45:24Z | 443,078 | <p>Yes, <a href="http://www.codeplex.com/aspnet/Release/ProjectReleases.aspx?ReleaseId=17613">there is an MVC example from the DLR team</a>.</p>
<p>You might also be interested in <a href="http://sparkviewengine.com/documentation/ironpython">Spark</a>.</p>
| 12 | 2009-01-14T14:16:01Z | [
"python",
"asp.net-mvc",
"linq",
"dynamic",
"ironpython"
] |
IronPython on ASP.NET MVC | 441,838 | <p>Has anyone tried ASP.NET MVC using IronPython? Having done a lot of Python development recently, it would be nice to continue with the language as I go into a potential ASP.NET MVC project.</p>
<p>I'm especially interested in exploiting the dynamic aspects of Python with .NET features such as LINQ and want to know... | 21 | 2009-01-14T03:45:24Z | 4,223,420 | <p>Using IronPython in ASP.NET MVC: <a href="http://www.codevoyeur.com/Articles/Tags/ironpython.aspx">http://www.codevoyeur.com/Articles/Tags/ironpython.aspx</a> </p>
<p>this page contains following articles:</p>
<ul>
<li>A Simple IronPython ControllerFactory for ASP.NET MVC</li>
<li>A Simple IronPython ActionFilter ... | 7 | 2010-11-19T08:59:15Z | [
"python",
"asp.net-mvc",
"linq",
"dynamic",
"ironpython"
] |
IronPython on ASP.NET MVC | 441,838 | <p>Has anyone tried ASP.NET MVC using IronPython? Having done a lot of Python development recently, it would be nice to continue with the language as I go into a potential ASP.NET MVC project.</p>
<p>I'm especially interested in exploiting the dynamic aspects of Python with .NET features such as LINQ and want to know... | 21 | 2009-01-14T03:45:24Z | 35,583,183 | <p>I'm currently working on this. It already supports a lot of things: <a href="https://github.com/simplic-systems/ironpython-aspnet-mvc" rel="nofollow">https://github.com/simplic-systems/ironpython-aspnet-mvc</a></p>
<p>more information on this:</p>
<p>Import the <code>aspnet</code> module</p>
<pre><code>import asp... | 2 | 2016-02-23T16:41:54Z | [
"python",
"asp.net-mvc",
"linq",
"dynamic",
"ironpython"
] |
Good Python networking libraries for building a TCP server? | 441,849 | <p>I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. </p>
<p>Also, would using Twisted even have a benefit over rolling my own server with select.select()?</p>
| 9 | 2009-01-14T03:51:13Z | 441,863 | <p>The standard library includes SocketServer and related modules which might be sufficient for your needs. This is a good middle ground between a complex framework like Twisted, and rolling your own select() loop.</p>
| 6 | 2009-01-14T04:00:44Z | [
"python",
"networking",
"twisted"
] |
Good Python networking libraries for building a TCP server? | 441,849 | <p>I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. </p>
<p>Also, would using Twisted even have a benefit over rolling my own server with select.select()?</p>
| 9 | 2009-01-14T03:51:13Z | 441,872 | <p>I must agree that the documentation is a bit terse but the tutorial gets you up and running quickly.</p>
<p><a href="http://twistedmatrix.com/projects/core/documentation/howto/tutorial/index.html">http://twistedmatrix.com/projects/core/documentation/howto/tutorial/index.html</a></p>
<p>The event-based programming ... | 10 | 2009-01-14T04:06:30Z | [
"python",
"networking",
"twisted"
] |
Good Python networking libraries for building a TCP server? | 441,849 | <p>I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. </p>
<p>Also, would using Twisted even have a benefit over rolling my own server with select.select()?</p>
| 9 | 2009-01-14T03:51:13Z | 441,882 | <p>If you're reluctant to use Twisted, you might want to check out <a href="http://danieldandrada.blogspot.com/2007/09/python-socketserverthreadingtcpserver.html" rel="nofollow">SocketServer.ThreadingTCPServer</a>. It's easy enough to use, and it's good <em>enough</em> for many purposes.</p>
<p>For the majority of sit... | 1 | 2009-01-14T04:13:47Z | [
"python",
"networking",
"twisted"
] |
Good Python networking libraries for building a TCP server? | 441,849 | <p>I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. </p>
<p>Also, would using Twisted even have a benefit over rolling my own server with select.select()?</p>
| 9 | 2009-01-14T03:51:13Z | 442,079 | <p>Just adding an answer to re-iterate other posters - it'll be worth it to use Twisted. There's no reason to write yet another TCP server that'll end up working not as well as one using twisted would. The only reason would be if writing your own is much faster, developer-wise, but if you just bite the bullet and learn... | 1 | 2009-01-14T06:19:12Z | [
"python",
"networking",
"twisted"
] |
Good Python networking libraries for building a TCP server? | 441,849 | <p>I was just wondering what network libraries there are out there for Python for building a TCP/IP server. I know that Twisted might jump to mind but the documentation seems scarce, sloppy, and scattered to me. </p>
<p>Also, would using Twisted even have a benefit over rolling my own server with select.select()?</p>
| 9 | 2009-01-14T03:51:13Z | 445,477 | <p>I've tried 3 approaches:</p>
<ul>
<li>Write my own select() loop <a href="http://sourceforge.net/projects/joeagent/" rel="nofollow">framework</a> (pretty much dead, I don't necessarily recommend it.)</li>
<li>Using SocketServer</li>
<li><a href="http://twistedmatrix.com/trac/" rel="nofollow">Twisted</a></li>
</ul>
... | 1 | 2009-01-15T02:50:14Z | [
"python",
"networking",
"twisted"
] |
Which new mp3 player to run old Python scripts | 441,864 | <p>Which mp3/media player could I buy which will allow me to run an existing set of python scripts.</p>
<p>The existing scripts control xmms on linux: providing "next tracks" given data on ratings/last played/genre/how long since acquired/.... so that it all runs on a server upstairs somewhere, and I do not need to ch... | 0 | 2009-01-14T04:01:29Z | 441,967 | <p>The only possibility I'm aware of is to use <a href="http://www.rockbox.org/" rel="nofollow">Rockbox</a>, and then <a href="http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-08/0111.shtml" rel="nofollow">port the Python interpreter</a> to it, or just port the functionality to some set of C programs, which... | 3 | 2009-01-14T04:59:55Z | [
"python",
"embedded",
"mp3"
] |
Which new mp3 player to run old Python scripts | 441,864 | <p>Which mp3/media player could I buy which will allow me to run an existing set of python scripts.</p>
<p>The existing scripts control xmms on linux: providing "next tracks" given data on ratings/last played/genre/how long since acquired/.... so that it all runs on a server upstairs somewhere, and I do not need to ch... | 0 | 2009-01-14T04:01:29Z | 460,065 | <p>Another possibility is to use an old iPod and <a href="http://ipodlinux.org/" rel="nofollow">iPod Linux</a> and the <a href="http://ciberjacobo.com/en/linux_on_ipod.html#python" rel="nofollow">Python Port for iPod Linux</a>.<br />
You'll use Podzilla's Media Player Daemon as the player and you'll have to figure out ... | 1 | 2009-01-20T03:41:11Z | [
"python",
"embedded",
"mp3"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 442,061 | <p>So, you're not going to like the answer, partly because I'm not yet done writing the code and partly because it's a lot of work.</p>
<p>What you need to do, as I discovered when I ran into this myself, is:</p>
<ol>
<li>Spend a lot of time reading through the formset and model-formset code to get a feel for how it ... | 25 | 2009-01-14T06:08:25Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 1,689,701 | <p>I came accross the same problem.</p>
<p>You can do it through JavaScript, make a simple JS that makes an ajax call for all the band memebers, and populates the form.</p>
<p>This solution lacks DRY principle, because you need to write this for every inline form you have.</p>
| 3 | 2009-11-06T19:16:42Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 2,404,496 | <p>Here is how I solved the problem.
There's a bit of a trade-off in creating and deleting the records, but the code is clean...</p>
<pre><code>def manage_event(request, event_id):
"""
Add a boolean field 'record_saved' (default to False) to the Event model
Edit an existing Event record or, if the record d... | 0 | 2010-03-08T20:27:17Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 3,766,344 | <p>I spent a fair amount of time trying to come up with a solution that I could re-use across sites. James' post contained the key piece of wisdom of extending <code>BaseInlineFormSet</code> but strategically invoking calls against <code>BaseFormSet</code>.</p>
<p>The solution below is broken into two pieces: a <code>... | 16 | 2010-09-22T04:35:19Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 16,417,369 | <p>Django 1.4 and higher supports <a href="https://docs.djangoproject.com/en/1.5/topics/forms/modelforms/#providing-initial-values">providing initial values</a>.</p>
<p>In terms of the original question, the following would work:</p>
<pre><code>class AttendanceFormSet(models.BaseInlineFormSet):
def __init__(self,... | 13 | 2013-05-07T11:01:21Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 20,687,767 | <p>Just override "save_new" method, it worked for me in Django 1.5.5:</p>
<pre><code>class ModelAAdminFormset(forms.models.BaseInlineFormSet):
def save_new(self, form, commit=True):
result = super(ModelAAdminFormset, self).save_new(form, commit=False)
# modify "result" here
if commit:
... | -1 | 2013-12-19T17:15:07Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 28,386,657 | <p>Using django 1.7 we ran into some issues creating an inline form with additional context baked into the model (not just an instance of the model to be passed in).</p>
<p>I came up with a different solution for injecting data into the ModelForm being passed in to the form set. Because in python you can dynamically c... | 3 | 2015-02-07T19:55:54Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 30,675,900 | <p>I ran into this question -6 years later- , and we are on Django 1.8 now.</p>
<p>Still no perfectly clean , short answer to the question. </p>
<p>The issue lies in the ModelAdmin._create_formsets() <em><a href="https://github.com/django/django/blob/master/django/contrib/admin/options.py#L1711-1722" rel="nofollow">g... | 2 | 2015-06-05T21:12:14Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 36,914,970 | <p>You can override empty_form getter on a formset. Here is an example on how do I deal with this in conjunction with django admin:</p>
<pre><code>class MyFormSet(forms.models.BaseInlineFormSet):
model = MyModel
@property
def empty_form(self):
initial = {}
if self.parent_obj:
i... | 0 | 2016-04-28T12:38:53Z | [
"python",
"django",
"django-forms"
] |
Pre-populate an inline FormSet? | 442,040 | <p>I'm working on an attendance entry form for a band. My idea is to have a section of the form to enter event information for a performance or rehearsal. Here's the model for the event table:</p>
<pre><code>class Event(models.Model):
event_id = models.AutoField(primary_key=True)
date = models.DateField()
... | 37 | 2009-01-14T05:49:25Z | 37,348,474 | <p>I'm having the same problem. I'm using Django 1.9, and I've tried the solution proposed by Simanas, overriding the property "empty_form", adding some default values in de dict initial. That worked but in my case I had 4 extra inline forms, 5 in total, and only one of the five forms was populated with the initial dat... | 0 | 2016-05-20T13:52:12Z | [
"python",
"django",
"django-forms"
] |
How do I create an HTTP server in Python using the first available port? | 442,062 | <p>I want to avoid hardcoding the port number as in the following:</p>
<pre><code>httpd = make_server('', 8000, simple_app)
</code></pre>
<p>The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client ... | 3 | 2009-01-14T06:08:39Z | 442,073 | <p>Is <code>make_server</code> a function that you've written? More specifically, do you handle the code that creates the sockets? If you do, there should be a way where you don't specify a port number (or you specify 0 as a port number) and the OS will pick an available one for you.</p>
<p>Besides that, you could jus... | 2 | 2009-01-14T06:16:18Z | [
"python",
"httpserver"
] |
How do I create an HTTP server in Python using the first available port? | 442,062 | <p>I want to avoid hardcoding the port number as in the following:</p>
<pre><code>httpd = make_server('', 8000, simple_app)
</code></pre>
<p>The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client ... | 3 | 2009-01-14T06:08:39Z | 442,074 | <p>The problem is that you need a known port for the application to use. But if you give a port number of 0, I believe the OS will provide you with the first available unused port.</p>
| 6 | 2009-01-14T06:16:22Z | [
"python",
"httpserver"
] |
How do I create an HTTP server in Python using the first available port? | 442,062 | <p>I want to avoid hardcoding the port number as in the following:</p>
<pre><code>httpd = make_server('', 8000, simple_app)
</code></pre>
<p>The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client ... | 3 | 2009-01-14T06:08:39Z | 442,083 | <p>Firewalls allow you to permit or deny traffic on a port-by-port basis. For this reason alone, an application without a well-defined port should expect to run into all kinds of problems in a client installation. </p>
<p>I say pick a random port, and make it very easy for the user to change the port if need be. </p>... | -1 | 2009-01-14T06:20:30Z | [
"python",
"httpserver"
] |
How do I create an HTTP server in Python using the first available port? | 442,062 | <p>I want to avoid hardcoding the port number as in the following:</p>
<pre><code>httpd = make_server('', 8000, simple_app)
</code></pre>
<p>The reason I'm creating the server this way is that I want to use it as a 'kernel' for an Adobe AIR app so it will communicate using PyAMF. Since I'm running this on the client ... | 3 | 2009-01-14T06:08:39Z | 442,981 | <blockquote>
<p>The problem is that you need a known port for the application to use. But if you give a port number of 0, I believe the OS will provide you with the first available unused port.</p>
</blockquote>
<p>You are correct, sir. Here's how that works:</p>
<pre><code>>>> import socket
>>> s... | 5 | 2009-01-14T13:41:38Z | [
"python",
"httpserver"
] |
ReadInt(), ReadByte(), ReadString(), etc. in Python? | 442,188 | <p>The functions ReadInt(), ReadByte(), and ReadString() (to name a few) exist in other languages for reading input from streams. I am trying to read from a socket, and I want to use functions like these. Are they tucked away in Python somewhere under a different way or has someone made a library for it?</p>
<p>Also, ... | 3 | 2009-01-14T07:34:04Z | 442,197 | <p>I think <a href="http://docs.python.org/library/struct.html#struct.unpack_from">struct.unpack_from</a> is what you're looking for.</p>
| 8 | 2009-01-14T07:38:17Z | [
"python"
] |
ReadInt(), ReadByte(), ReadString(), etc. in Python? | 442,188 | <p>The functions ReadInt(), ReadByte(), and ReadString() (to name a few) exist in other languages for reading input from streams. I am trying to read from a socket, and I want to use functions like these. Are they tucked away in Python somewhere under a different way or has someone made a library for it?</p>
<p>Also, ... | 3 | 2009-01-14T07:34:04Z | 442,662 | <p>Note that Python doesn't have readByte, readInt and readString because it doesn't work directly with all those fancy data types. Files provides strings which you can convert.</p>
<p>Python <code><=</code> 2.6 has String and that's what you get from your input streams -- strings. The simple <code>socket.read()<... | 0 | 2009-01-14T11:40:01Z | [
"python"
] |
ReadInt(), ReadByte(), ReadString(), etc. in Python? | 442,188 | <p>The functions ReadInt(), ReadByte(), and ReadString() (to name a few) exist in other languages for reading input from streams. I am trying to read from a socket, and I want to use functions like these. Are they tucked away in Python somewhere under a different way or has someone made a library for it?</p>
<p>Also, ... | 3 | 2009-01-14T07:34:04Z | 4,338,551 | <p>Python's way is using struct.unpack to read binary data.
I'm very used to the BinaryReader and BinaryWriter in C#, so I made this:</p>
<pre><code>from struct import *
class BinaryStream:
def __init__(self, base_stream):
self.base_stream = base_stream
def readByte(self):
return self.base_st... | 7 | 2010-12-02T18:37:08Z | [
"python"
] |
ReadInt(), ReadByte(), ReadString(), etc. in Python? | 442,188 | <p>The functions ReadInt(), ReadByte(), and ReadString() (to name a few) exist in other languages for reading input from streams. I am trying to read from a socket, and I want to use functions like these. Are they tucked away in Python somewhere under a different way or has someone made a library for it?</p>
<p>Also, ... | 3 | 2009-01-14T07:34:04Z | 22,507,473 | <p>I used the code of Zippoxer and it works well for almost everything, thank you.</p>
<p>However I had some issue with readString(). It was specified in the C# doc that the length is encoded on 7 bytes. Thus I used readUChar instead of readUInt16:</p>
<pre><code>def readString(self):
length = self.readUChar()
... | 0 | 2014-03-19T13:30:37Z | [
"python"
] |
How do I use a 2-d boolean array to select from a 1-d array on a per-row basis in numpy? | 442,218 | <p>Let me illustrate this question with an example:</p>
<pre><code>import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arang... | 1 | 2009-01-14T07:49:24Z | 442,231 | <p>Here is another ugly way of doing it:</p>
<pre><code>n.apply_along_axis(base.__getitem__, 0, matrix).reshape((5,1))
</code></pre>
| 0 | 2009-01-14T07:54:52Z | [
"python",
"numpy"
] |
How do I use a 2-d boolean array to select from a 1-d array on a per-row basis in numpy? | 442,218 | <p>Let me illustrate this question with an example:</p>
<pre><code>import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arang... | 1 | 2009-01-14T07:49:24Z | 442,669 | <p>If I understand your question correctly you can simply use matrix multiplication:</p>
<pre><code>result = numpy.dot(matrix, base)
</code></pre>
<p>If the result must have the same shape as in your example just add a reshape:</p>
<pre><code>result = numpy.dot(matrix, base).reshape((5,1))
</code></pre>
<p>If the m... | 1 | 2009-01-14T11:42:09Z | [
"python",
"numpy"
] |
How do I use a 2-d boolean array to select from a 1-d array on a per-row basis in numpy? | 442,218 | <p>Let me illustrate this question with an example:</p>
<pre><code>import numpy
matrix = numpy.identity(5, dtype=bool) #Using identity as a convenient way to create an array with the invariant that there will only be one True value per row, the solution should apply to any array with this invariant
base = numpy.arang... | 1 | 2009-01-14T07:49:24Z | 445,168 | <p>My try:</p>
<pre><code>numpy.sum(matrix * base, axis=1)
</code></pre>
| 0 | 2009-01-15T00:05:41Z | [
"python",
"numpy"
] |
Generic catch for python | 442,343 | <p>I have some extremely weird behavior that seems to result in silent exceptions. How can I write a general try catch where I can debug all exceptions. Something along the lines of:</p>
<pre><code>try:
# something that fails
except e:
print e
</code></pre>
<p>A bit more about the problem at hand in detail:</... | 33 | 2009-01-14T09:05:20Z | 442,348 | <p>Does this work? :</p>
<pre><code>except BaseException, e:
</code></pre>
| 1 | 2009-01-14T09:07:41Z | [
"python",
"exception"
] |
Generic catch for python | 442,343 | <p>I have some extremely weird behavior that seems to result in silent exceptions. How can I write a general try catch where I can debug all exceptions. Something along the lines of:</p>
<pre><code>try:
# something that fails
except e:
print e
</code></pre>
<p>A bit more about the problem at hand in detail:</... | 33 | 2009-01-14T09:05:20Z | 442,353 | <p>The <a href="http://docs.python.org/library/traceback.html" rel="nofollow">traceback module</a> is quite useful for formatting tracebacks. You can then write it to a logfile.</p>
| 2 | 2009-01-14T09:10:18Z | [
"python",
"exception"
] |
Generic catch for python | 442,343 | <p>I have some extremely weird behavior that seems to result in silent exceptions. How can I write a general try catch where I can debug all exceptions. Something along the lines of:</p>
<pre><code>try:
# something that fails
except e:
print e
</code></pre>
<p>A bit more about the problem at hand in detail:</... | 33 | 2009-01-14T09:05:20Z | 442,358 | <p>Exceptions are already printed by default before program termination. If you want to send the error somewhere else (not print it) you can do this:</p>
<pre><code>try:
something()
except Exception as e:
send_somewhere(traceback.format_exception(*sys.exc_info()))
raise # reraises the exception
</code></pr... | 60 | 2009-01-14T09:12:41Z | [
"python",
"exception"
] |
What is the best approach to implement configuration app with Django? | 442,355 | <p>I need to program kind of configuration registry for Django-based application. </p>
<p>Requirements:</p>
<ol>
<li>Most likely <code>param_name</code> : <code>param_value</code> structure</li>
<li>Editable via admin interface</li>
<li>Has to work with syncdb. How to deal with a situation in which other apps depend ... | 2 | 2009-01-14T09:11:43Z | 442,600 | <p>Once a while (year ago) I used <a href="http://code.google.com/p/django-values/" rel="nofollow">dbsettings</a> to have some sort of business configuration accessible via admin interface, but I cann't say how it fits today.</p>
| 1 | 2009-01-14T11:05:37Z | [
"python",
"django",
"configuration",
"django-models",
"django-admin"
] |
What is the best approach to implement configuration app with Django? | 442,355 | <p>I need to program kind of configuration registry for Django-based application. </p>
<p>Requirements:</p>
<ol>
<li>Most likely <code>param_name</code> : <code>param_value</code> structure</li>
<li>Editable via admin interface</li>
<li>Has to work with syncdb. How to deal with a situation in which other apps depend ... | 2 | 2009-01-14T09:11:43Z | 448,110 | <p>I think you'll have trouble if you make other apps depend (at interpretation/app-loading time) on values set in your config app. Can you use some kind of placeholder value in Python code at interpretation time, and then pull in the real config data on the post_syncdb signal?</p>
| 0 | 2009-01-15T19:25:43Z | [
"python",
"django",
"configuration",
"django-models",
"django-admin"
] |
What is the best approach to implement configuration app with Django? | 442,355 | <p>I need to program kind of configuration registry for Django-based application. </p>
<p>Requirements:</p>
<ol>
<li>Most likely <code>param_name</code> : <code>param_value</code> structure</li>
<li>Editable via admin interface</li>
<li>Has to work with syncdb. How to deal with a situation in which other apps depend ... | 2 | 2009-01-14T09:11:43Z | 468,837 | <p>I have found <a href="http://www.chipx86.com/blog/?p=261" rel="nofollow">djblets.siteconfig</a> very useful. Works great with the Admin app, and very easy to use. Highly recommended.</p>
| 5 | 2009-01-22T11:51:51Z | [
"python",
"django",
"configuration",
"django-models",
"django-admin"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 442,453 | <p>If your symlink is set up in the way you state, then <code>/tmp/foo/kiwi</code> is the directory that you're really in. <code>/tmp/bar/kiwi</code> is just another way to get to the same place.</p>
<p>Note that the shell command <code>pwd -P</code> will give you the physical path of the current directory. In your ca... | 2 | 2009-01-14T09:57:12Z | [
"python"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 442,467 | <p>If you don't find anything else, you can use </p>
<pre><code>os.getenv("PWD")
</code></pre>
<p>It's not really a portable python method, but works on POSIX systems. It gets the value of the <code>PWD</code> environment variable, which is set by the <code>cd</code> command (if you don't use <code>cd -P</code>) to t... | 6 | 2009-01-14T10:02:09Z | [
"python"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 442,525 | <p>Just as a matter of interest, if you are in a directory you can use the -P option to get the pwd command to resolve all symbolic links to their actual directories.</p>
<pre><code>$ ln -s Desktop toto
$ cd toto
$
$ pwd
/home/ken/toto
$
$ pwd -P
/home/ken/Desktop
$
</code></pre>
<p>HTH</p>
<p>cheers,</p>
<p>Rob</... | 0 | 2009-01-14T10:21:06Z | [
"python"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 442,533 | <p>You could also try lstat. It will give you info about a file/dir, including telling you whether it's a link and showing you where it links to if it is.</p>
| 0 | 2009-01-14T10:24:06Z | [
"python"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 442,588 | <p>When your shell returning the path, it is relying on the shell enviroment variable "PWD" which gets set as you traverse through the symlink path, but actually it is under the directory as returned by the getcwd(). So, if you get from shell's PWD you will get what you want.</p>
<pre>
>>> os.getcwd()
'/home/ors/foo/t... | 0 | 2009-01-14T10:56:27Z | [
"python"
] |
How to know when you are in a symbolic link | 442,442 | <p>How to know, in Python, that the directory you are in is inside a symbolic link ?</p>
<p>I have a directory <strong>/tmp/foo/kiwi</strong></p>
<p>I create a symlink <strong>/tmp/bar</strong> pointing to <strong>/tmp/foo</strong></p>
<p>I enter into <strong>/tmp/bar/kiwi</strong></p>
<p>the linux command <strong>... | 4 | 2009-01-14T09:52:41Z | 27,951,581 | <p>Here is another way:</p>
<pre><code>import os
os.popen('pwd').read().strip('\n')
</code></pre>
<p>Here is a demonstration in python shell:</p>
<pre><code>>>> import os
>>> os.popen('pwd').read().strip('\n')
'/home/projteam/staging/site/proj'
>>> # This returns actual path
>>> i... | 0 | 2015-01-14T20:11:22Z | [
"python"
] |
cascading forms in Django/else using any Pythonic framework | 442,596 | <p>Can anyone point to an example written in Python (django preferred) with ajax for cascading forms? Cascading Forms is basically forms whose field values change if and when another field value changes. Example Choose Country, and then States will change...</p>
| 3 | 2009-01-14T11:04:04Z | 442,659 | <p>This is (<em>mostly</em>) front-end stuff.</p>
<p>As you may have noticed Django attempts to leave all the AJAX stuff up to you, so I don't think you'll find anything built in to do this.</p>
<p>However, using JS (which is what you'll have to do in order to do this without submitting a billion forms manually), you... | 3 | 2009-01-14T11:37:39Z | [
"python",
"django"
] |
cascading forms in Django/else using any Pythonic framework | 442,596 | <p>Can anyone point to an example written in Python (django preferred) with ajax for cascading forms? Cascading Forms is basically forms whose field values change if and when another field value changes. Example Choose Country, and then States will change...</p>
| 3 | 2009-01-14T11:04:04Z | 443,155 | <p>I would also suggest considering getting a mapping of all data once instead of requesting subfield values one by one. Unless the subfield choices change frequently (states/cities change?) or huge in numbers (>1000) this should offer best performance and it is less complex.</p>
<p>You don't even need to create a sep... | 1 | 2009-01-14T14:33:55Z | [
"python",
"django"
] |
How to properly interact with a process using subprocess module | 443,057 | <p>I'm having problems redirecting stdio of another program using subprocess module. Just reading from stdout results in hanging, and Popen.communicate() works but it closes pipes after reading/writing. What's the easiest way to implement this?</p>
<p>I was playing around with this on windows:</p>
<pre><code>import s... | 6 | 2009-01-14T14:07:12Z | 443,080 | <p>Doesn't fit 100% to your example but helps to understand the underlying issue: Process P starts child C. Child C writes something to its stdout. stdout of C is a pipe which has a 4096 character buffer and the output is shorter than that. Now, C waits for some input. For C, everything is fine.</p>
<p>P waits for the... | 11 | 2009-01-14T14:16:38Z | [
"python",
"subprocess"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.