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
How to do a meaningful code-coverage analysis of my unit-tests?
1,006,189
<p>I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems...
5
2009-06-17T10:20:17Z
1,006,225
<p>For the code coverage alone, you could use <a href="http://nedbatchelder.com/code/coverage/" rel="nofollow">coverage.py</a>.</p> <p>As for coverage.py vs <a href="http://darcs.idyll.org/~t/projects/figleaf/doc/" rel="nofollow">figleaf</a>:</p> <blockquote> <p>figleaf differs from the gold standard of Python co...
6
2009-06-17T10:27:46Z
[ "python", "testing" ]
How to do a meaningful code-coverage analysis of my unit-tests?
1,006,189
<p>I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems...
5
2009-06-17T10:20:17Z
1,006,244
<p>Assuming you already have a relatively comprehensive test suite, there are tools for the python part. The C part is much more problematic, depending on tools availability.</p> <ul> <li><p>For <a href="http://darcs.idyll.org/~t/projects/figleaf/doc/" rel="nofollow">python unit tests</a></p></li> <li><p>For C code, i...
1
2009-06-17T10:31:10Z
[ "python", "testing" ]
How to do a meaningful code-coverage analysis of my unit-tests?
1,006,189
<p>I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems...
5
2009-06-17T10:20:17Z
1,006,261
<p>First step would be writing meaningfull tests. If you'll be writing tests only meant to reach full coverage, you'll be counter-productive; it will probably mean you'll focus on unit's implementation details instead of it's expectations.</p> <p>BTW, I'd use nose as unittest framework (<a href="http://somethingabouto...
4
2009-06-17T10:35:01Z
[ "python", "testing" ]
How to do a meaningful code-coverage analysis of my unit-tests?
1,006,189
<p>I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems...
5
2009-06-17T10:20:17Z
1,006,454
<p><strong>"every single part of our project has a meaningful test in place"</strong></p> <p>"Part" is undefined. "Meaningful" is undefined. That's okay, however, since it gets better further on.</p> <p><strong>"validates the correctness of every component in our system"</strong></p> <p>"Component" is undefined. ...
3
2009-06-17T11:25:47Z
[ "python", "testing" ]
How to do a meaningful code-coverage analysis of my unit-tests?
1,006,189
<p>I manage the testing for a very large financial pricing system. Recently our HQ have insisted that we verify that every single part of our project has a meaningful test in place. At the very least they want a system which guarantees that when we change something we can spot unintentional changes to other sub-systems...
5
2009-06-17T10:20:17Z
1,008,603
<p>FWIW, this is what we do. Since I don't know about your Unit-Test and Regression-Test setup, you have to decide yourself whether this is helpful.</p> <ul> <li>Every Python package has <a href="http://docs.python.org/library/unittest.html" rel="nofollow">UnitTests</a>.</li> <li>We automatically detect unit tests usi...
3
2009-06-17T17:51:28Z
[ "python", "testing" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
1,006,301
<p>If you're interested into the number of processors <em>available</em> to your current process, you have to check <a href="http://man7.org/linux/man-pages/man7/cpuset.7.html">cpuset</a> first. Otherwise (or if cpuset is not in use), <a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.cpu_coun...
118
2009-06-17T10:43:28Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
1,006,337
<p>If you have python with a version >= 2.6 you can simply use</p> <pre><code>import multiprocessing multiprocessing.cpu_count() </code></pre> <p><a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.cpu_count">http://docs.python.org/library/multiprocessing.html#multiprocessing.cpu_count</a></...
401
2009-06-17T10:53:53Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
3,845,635
<p>Can't figure out how to add to the code or reply to the message but here's support for jython that you can tack in before you give up:</p> <pre><code># jython try: from java.lang import Runtime runtime = Runtime.getRuntime() res = runtime.availableProcessors() if res &gt; 0: return res excep...
7
2010-10-02T12:16:02Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
14,840,102
<p>An other option is to use the <a href="http://code.google.com/p/psutil/"><code>psutil</code></a> library, which always turn out useful in these situations:</p> <pre><code>&gt;&gt;&gt; import psutil &gt;&gt;&gt; psutil.cpu_count() 2 </code></pre> <p>This should work on any platform supported by <code>psutil</code>(...
39
2013-02-12T19:19:05Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
24,805,009
<p><code>multiprocessing.cpu_count()</code> will return the number of logical CPUs, so if you have a quad-core CPU with hyperthreading, it will return <code>8</code>. If you want the number of physical CPUs, use the python bindings to hwloc:</p> <pre><code>#!/usr/bin/env python import hwloc topology = hwloc.Topology(...
11
2014-07-17T13:32:10Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
25,569,974
<p>Another option if you don't have Python 2.6:</p> <pre><code>import commands n = commands.getoutput("grep -c processor /proc/cpuinfo") </code></pre>
2
2014-08-29T14:05:39Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
25,636,145
<p>In Python 3.4+: <a href="https://docs.python.org/3/library/os.html#os.cpu_count">os.cpu_count()</a>.</p> <p><code>multiprocessing.cpu_count()</code> is implemented in terms of this function but raises <code>NotImplementedError</code> if <code>os.cpu_count()</code> returns <code>None</code> ("can't determine number ...
8
2014-09-03T04:16:56Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
29,770,622
<p>You can also use "joblib" for this purpose. </p> <pre><code>import joblib print joblib.cpu_count() </code></pre> <p>This method will give you the number of cpus in the system. joblib needs to be installed though. More information on joblib can be found here <a href="https://pythonhosted.org/joblib/parallel.h...
2
2015-04-21T11:14:43Z
[ "python", "system-information" ]
How to find out the number of CPUs using python
1,006,289
<p>I want to know the number of CPUs on the local machine using Python. The result should be <code>user/real</code> as output by <code>time(1)</code> when called with an optimally scaling userspace-only program.</p>
230
2009-06-17T10:41:44Z
36,540,625
<p>platform independent:</p> <blockquote> <p>psutil.cpu_count(logical=False)</p> </blockquote> <p><a href="https://github.com/giampaolo/psutil/blob/master/INSTALL.rst" rel="nofollow">https://github.com/giampaolo/psutil/blob/master/INSTALL.rst</a></p>
3
2016-04-11T05:42:55Z
[ "python", "system-information" ]
Capitalizing non-ASCII words in Python
1,006,450
<p>How to capitalize words containing non-ASCII characters in Python? Is there a way to tune <code>string</code>'s <code>capitalize()</code> method to do that?</p>
5
2009-06-17T11:24:42Z
1,006,463
<p>Use Unicode strings:</p> <pre><code># coding: cp1252 print u"é".capitalize() # Prints É </code></pre> <p>If all you have is an 8-bit string, decode it into Unicode first:</p> <pre><code># coding: cp1252 print "é".decode('cp1252').capitalize() # Prints É </code></pre> <p>If you then need it as an 8-bit string...
10
2009-06-17T11:30:16Z
[ "python", "unicode", "ascii", "capitalization" ]
Capitalizing non-ASCII words in Python
1,006,450
<p>How to capitalize words containing non-ASCII characters in Python? Is there a way to tune <code>string</code>'s <code>capitalize()</code> method to do that?</p>
5
2009-06-17T11:24:42Z
1,006,467
<p><code>capitalize()</code> should Just Work&trade; for Unicode strings.</p>
1
2009-06-17T11:32:52Z
[ "python", "unicode", "ascii", "capitalization" ]
Simple python plugin system
1,006,556
<p><br /> I'm writing a parser for an internal xml-based metadata format in python. I need to provide different classes for handling different tags. There will be a need for a rather big collection of handlers, so I've envisioned it as a simple plugin system. What I want to do is simply load every class in a package, a...
0
2009-06-17T11:57:14Z
1,006,595
<p>Probably one of your <code>handlerMod</code> modules does not contain any <code>tags</code> variable.</p>
0
2009-06-17T12:06:15Z
[ "python" ]
Simple python plugin system
1,006,556
<p><br /> I'm writing a parser for an internal xml-based metadata format in python. I need to provide different classes for handling different tags. There will be a need for a rather big collection of handlers, so I've envisioned it as a simple plugin system. What I want to do is simply load every class in a package, a...
0
2009-06-17T11:57:14Z
1,007,289
<p>I suggest you read the example and explanation on <a href="http://www.diveintopython.net/html_processing/all_together.html" rel="nofollow">this page</a> where how to write a plug-in architecture is explained.</p>
0
2009-06-17T14:11:20Z
[ "python" ]
Simple python plugin system
1,006,556
<p><br /> I'm writing a parser for an internal xml-based metadata format in python. I need to provide different classes for handling different tags. There will be a need for a rather big collection of handlers, so I've envisioned it as a simple plugin system. What I want to do is simply load every class in a package, a...
0
2009-06-17T11:57:14Z
1,087,194
<p>First off, apologies for poorly formated/incorrect code.<br /> Also thanks for looking at it. However, the culprit was, as so often, between the chair and the keyboard. I confused myself by having classes and modules of the same name. The result of my_import (which I now realize I didn't even mention where it comes ...
0
2009-07-06T14:11:35Z
[ "python" ]
Simple python plugin system
1,006,556
<p><br /> I'm writing a parser for an internal xml-based metadata format in python. I need to provide different classes for handling different tags. There will be a need for a rather big collection of handlers, so I've envisioned it as a simple plugin system. What I want to do is simply load every class in a package, a...
0
2009-06-17T11:57:14Z
32,276,389
<p>Simple and completly extensible implementation via <a href="https://github.com/katyukha/extend-me" rel="nofollow">extend_me</a> library.</p> <p>Code could look like</p> <pre><code>from extend_me import ExtensibleByHash # create meta class tagMeta = ExtensibleByHash._('Tag', hashattr='name') # create base class f...
0
2015-08-28T17:11:33Z
[ "python" ]
What would the jvm have to sacrifice in order to implement tail call optimisation?
1,006,596
<p>People say that the clojure implementation is excellent apart from the limitation of having no tail call optimisation - a limitation of the jvm not the clojure implementation. </p> <p><a href="http://lambda-the-ultimate.org/node/2547" rel="nofollow">http://lambda-the-ultimate.org/node/2547</a></p> <p>It has been s...
3
2009-06-17T12:06:19Z
1,006,726
<p>Whilst different (in that the il instructions existed already) it's worth noting the additional effort the .Net <a href="http://blogs.msdn.com/clrcodegeneration/archive/2009/05/11/tail-call-improvements-in-net-framework-4.aspx" rel="nofollow">64 bit JIT team</a> had to go through to respect all tail calls.</p> <p>I...
6
2009-06-17T12:33:34Z
[ "python", "clojure", "jvm", "stack-trace", "tail-call-optimization" ]
What would the jvm have to sacrifice in order to implement tail call optimisation?
1,006,596
<p>People say that the clojure implementation is excellent apart from the limitation of having no tail call optimisation - a limitation of the jvm not the clojure implementation. </p> <p><a href="http://lambda-the-ultimate.org/node/2547" rel="nofollow">http://lambda-the-ultimate.org/node/2547</a></p> <p>It has been s...
3
2009-06-17T12:06:19Z
1,013,576
<p>Work is <a href="http://challenge.openjdk.org/projects/mlvm/subprojects.html" rel="nofollow">underway now</a> to add tail calls to the JVM. There's a <a href="http://wikis.sun.com/display/mlvm/TailCalls" rel="nofollow">wiki page</a> talking about some details.</p>
2
2009-06-18T16:03:42Z
[ "python", "clojure", "jvm", "stack-trace", "tail-call-optimization" ]
What would the jvm have to sacrifice in order to implement tail call optimisation?
1,006,596
<p>People say that the clojure implementation is excellent apart from the limitation of having no tail call optimisation - a limitation of the jvm not the clojure implementation. </p> <p><a href="http://lambda-the-ultimate.org/node/2547" rel="nofollow">http://lambda-the-ultimate.org/node/2547</a></p> <p>It has been s...
3
2009-06-17T12:06:19Z
2,949,094
<p>Yes it is generally the case that implementing TCO will prevent you from getting full stack traces. This is inevitable because the whole point of TCO is to avoid creating additional stack frames.</p> <p>It's also worth interesting to note that Clojure has an non-stack-consuming "recur" feature to get around this co...
0
2010-06-01T10:53:54Z
[ "python", "clojure", "jvm", "stack-trace", "tail-call-optimization" ]
wxProgressDialog like behaviour for a wxDialog
1,006,598
<p>I want to create modal dialog but which shouldn't behave in a modal way i.e. control flow should continue</p> <p>if i do</p> <pre><code> dlg = wx.Dialog(parent) dlg.ShowModal() print "xxx" dlg.Destroy() </code></pre> <p>"xxx" will not get printed, but in case of progress dialog</p> <pre><code>dlg = wx.Progr...
0
2009-06-17T12:06:23Z
1,007,845
<p>Just use <code>Show</code> instead of <code>ShowModal</code>.</p> <p>If your function (the <code>print "xxx"</code> part) runs for a long time you will either have to manually call <code>wx.SafeYield</code> every so often or move your work to a separate thread and send custom events to your dialog from it.</p> <p>...
1
2009-06-17T15:37:32Z
[ "python", "wxpython", "modal-dialog" ]
wxProgressDialog like behaviour for a wxDialog
1,006,598
<p>I want to create modal dialog but which shouldn't behave in a modal way i.e. control flow should continue</p> <p>if i do</p> <pre><code> dlg = wx.Dialog(parent) dlg.ShowModal() print "xxx" dlg.Destroy() </code></pre> <p>"xxx" will not get printed, but in case of progress dialog</p> <pre><code>dlg = wx.Progr...
0
2009-06-17T12:06:23Z
1,017,277
<p>It was very trivial, just using wx.PD_APP_MODAL style in wx.Dialog allows it to be modal without stopping the program flow, only user input to app is blocked, i thought PD_APP_MODAL is only for progress dialog</p>
0
2009-06-19T10:17:09Z
[ "python", "wxpython", "modal-dialog" ]
OLE Compound Documents in Python
1,006,682
<p><br /> how would you parse a Microsoft <a href="http://www.forensicswiki.org/wiki/OLE%5FCompound%5FFile" rel="nofollow">OLE compound document</a> using Python?</p> <p><strong>Edit:</strong> Sorry, I forgot to say that I need write support too.. In short, I have an OLE compound file that I have to read, modify a bit...
3
2009-06-17T12:27:12Z
1,006,732
<p>Just found <a href="http://www.decalage.info/python/olefileio" rel="nofollow">OleFileIO_PL</a>, but it doesn't have write support.. :/</p> <p><strong>Edit:</strong> Looks like there's a way (though Windows-only) that supports writing too.. The <a href="http://python.net/crew/mhammond/win32/" rel="nofollow">pywin32<...
3
2009-06-17T12:34:37Z
[ "python", "ole" ]
OLE Compound Documents in Python
1,006,682
<p><br /> how would you parse a Microsoft <a href="http://www.forensicswiki.org/wiki/OLE%5FCompound%5FFile" rel="nofollow">OLE compound document</a> using Python?</p> <p><strong>Edit:</strong> Sorry, I forgot to say that I need write support too.. In short, I have an OLE compound file that I have to read, modify a bit...
3
2009-06-17T12:27:12Z
1,007,375
<p>An alternative: The xlrd package has a reader. The xlwt package (a fork of pyExcelerator) has a writer. They handle filesizes of 100s of MB cheerfully; the packages have been widely used for about 4 years. The compound document modules are targetted at getting "Workbook" streams into and out of Excel .xls files as e...
2
2009-06-17T14:26:23Z
[ "python", "ole" ]
OLE Compound Documents in Python
1,006,682
<p><br /> how would you parse a Microsoft <a href="http://www.forensicswiki.org/wiki/OLE%5FCompound%5FFile" rel="nofollow">OLE compound document</a> using Python?</p> <p><strong>Edit:</strong> Sorry, I forgot to say that I need write support too.. In short, I have an OLE compound file that I have to read, modify a bit...
3
2009-06-17T12:27:12Z
12,296,246
<p>For completeness: on Linux there's also the <a href="http://projects.gnome.org/libgsf/" rel="nofollow">GNOME Structured File Library</a> (but the default package for Debian/Ubuntu has Python support disabled, since the Python bindings are <a href="http://git.gnome.org/browse/libgsf/tree/python/README-python" rel="no...
0
2012-09-06T08:45:59Z
[ "python", "ole" ]
How to retrieve the selected text from the active window
1,007,185
<p>I am trying to create a simple open source utility for windows using <strong>Python</strong> that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut.</p> <p>Usage is partially outlined in the following example:<...
11
2009-06-17T13:54:58Z
1,007,553
<p>It won't be trivial but here is the starting point</p> <pre><code>import win32gui hwnd = win32gui.GetForegroundWindow() print win32gui.GetWindowText(hwnd) </code></pre> <p>Maybe you will have to use <code>FindWindow</code>,<code>FindWindowEx</code> to get child windows with focus</p> <p>edit: also while experimen...
1
2009-06-17T14:52:30Z
[ "python", "windows", "winapi", "pywin32" ]
How to retrieve the selected text from the active window
1,007,185
<p>I am trying to create a simple open source utility for windows using <strong>Python</strong> that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut.</p> <p>Usage is partially outlined in the following example:<...
11
2009-06-17T13:54:58Z
1,009,487
<p>You're far better off using the Ctrl-C method. Fetching text directly will work for something like an edit control, but is useless for retrieving text that an application has painted directly on its own window. </p>
1
2009-06-17T20:58:12Z
[ "python", "windows", "winapi", "pywin32" ]
How to retrieve the selected text from the active window
1,007,185
<p>I am trying to create a simple open source utility for windows using <strong>Python</strong> that can perform user-defined actions on the selected text of the currently active window. The utility should be activated using a pre-defined keyboard shortcut.</p> <p>Usage is partially outlined in the following example:<...
11
2009-06-17T13:54:58Z
7,535,892
<p>the code below will work only on simple text boxes (just did it in VB6, and ported to python)</p> <p>edit: <strong>it was tested only on python 2.6</strong></p> <pre><code>from ctypes import * import win32gui import win32api import win32con user32 = windll.user32 kernel32 = windll.kernel32 class RECT(Structure)...
1
2011-09-23T23:40:01Z
[ "python", "windows", "winapi", "pywin32" ]
How do you make this code more pythonic?
1,007,215
<p>Could you guys please tell me how I can make the following code more pythonic? </p> <p>The code is correct. Full disclosure - it's problem 1b in Handout #4 of <a href="http://www.stanford.edu/class/cs229/materials.html" rel="nofollow">this</a> machine learning course. I'm supposed to use newton's algorithm on the t...
3
2009-06-17T14:00:46Z
1,007,222
<p>You could make use of the <b><a href="http://www.python.org/dev/peps/pep-0343/" rel="nofollow">with</a></b> statement.</p>
0
2009-06-17T14:02:42Z
[ "python", "machine-learning", "scipy" ]
How do you make this code more pythonic?
1,007,215
<p>Could you guys please tell me how I can make the following code more pythonic? </p> <p>The code is correct. Full disclosure - it's problem 1b in Handout #4 of <a href="http://www.stanford.edu/class/cs229/materials.html" rel="nofollow">this</a> machine learning course. I'm supposed to use newton's algorithm on the t...
3
2009-06-17T14:00:46Z
1,007,355
<p>One obvious change is to get rid of the "for i in range(1, 100):" and just iterate over the file lines. To iterate over both files (xfile and yfile), zip them. ie replace that block with something like:</p> <pre><code> import itertools for xline, yline in itertools.izip(xfile, yfile): s= xline.split(" ") ...
9
2009-06-17T14:23:22Z
[ "python", "machine-learning", "scipy" ]
How do you make this code more pythonic?
1,007,215
<p>Could you guys please tell me how I can make the following code more pythonic? </p> <p>The code is correct. Full disclosure - it's problem 1b in Handout #4 of <a href="http://www.stanford.edu/class/cs229/materials.html" rel="nofollow">this</a> machine learning course. I'm supposed to use newton's algorithm on the t...
3
2009-06-17T14:00:46Z
1,007,368
<p>the code that reads the files into lists could be drastically simpler</p> <pre><code>for line in open("q1x.dat", "r"): x = map(float,line.split(" ")[1:]) y = map(float, open("q1y.dat", "r").readlines()) </code></pre>
0
2009-06-17T14:25:21Z
[ "python", "machine-learning", "scipy" ]
How do you make this code more pythonic?
1,007,215
<p>Could you guys please tell me how I can make the following code more pythonic? </p> <p>The code is correct. Full disclosure - it's problem 1b in Handout #4 of <a href="http://www.stanford.edu/class/cs229/materials.html" rel="nofollow">this</a> machine learning course. I'm supposed to use newton's algorithm on the t...
3
2009-06-17T14:00:46Z
1,007,377
<pre><code>x = matrix([[0.],[0],[1]]) theta = matrix(zeros([3,1])) for i in range(5): grad = matrix(zeros([3,1])) hess = matrix(zeros([3,3])) [xfile, yfile] = [open('q1'+a+'.dat', 'r') for a in 'xy'] for xline, yline in zip(xfile, yfile): x.transpose()[0,:2] = [map(float, xline.split(" ")[1:3])] y = fl...
4
2009-06-17T14:26:48Z
[ "python", "machine-learning", "scipy" ]
How do you make this code more pythonic?
1,007,215
<p>Could you guys please tell me how I can make the following code more pythonic? </p> <p>The code is correct. Full disclosure - it's problem 1b in Handout #4 of <a href="http://www.stanford.edu/class/cs229/materials.html" rel="nofollow">this</a> machine learning course. I'm supposed to use newton's algorithm on the t...
3
2009-06-17T14:00:46Z
1,009,035
<blockquote> <p>the matrixes kept rounding to integers until I initialized one value to 0.0. Is there a better way?</p> </blockquote> <p>At the top of your code:</p> <pre><code>from __future__ import division </code></pre> <p>In Python 2.6 and earlier, integer division always returns an integer unless there is a...
3
2009-06-17T19:19:45Z
[ "python", "machine-learning", "scipy" ]
Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?
1,007,391
<p>Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour?</p> <p><strong>Details:</strong> </p> <p>This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nic...
1
2009-06-17T14:29:06Z
1,007,426
<p>In Python there is <a href="http://www.python.org/doc/2.5.2/lib/module-ctypes.html" rel="nofollow">ctypes</a> and in Perl there is <a href="http://search.cpan.org/~cosimo/Win32-API-0.58/API.pm" rel="nofollow">Win32::API</a></p> <p><strong>ctypes Example</strong></p> <pre><code>from ctypes import * windll.user32.Me...
7
2009-06-17T14:34:34Z
[ "python", "ruby", "perl", "winapi" ]
Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?
1,007,391
<p>Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour?</p> <p><strong>Details:</strong> </p> <p>This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nic...
1
2009-06-17T14:29:06Z
1,007,441
<p>If you are trying to automate some task in a website you might want to look at <a href="http://search.cpan.org/dist/Test-WWW-Selenium/lib/WWW/Selenium.pm" rel="nofollow"><code>WWW::Selenium</code></a>. It, along with <a href="http://seleniumhq.org/projects/remote-control/" rel="nofollow">Selenium Remote Control</a>...
8
2009-06-17T14:35:58Z
[ "python", "ruby", "perl", "winapi" ]
Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?
1,007,391
<p>Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour?</p> <p><strong>Details:</strong> </p> <p>This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nic...
1
2009-06-17T14:29:06Z
1,007,452
<p>I find this is easier to approach in Java or C++. Java has a <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Robot.html" rel="nofollow">Robot class</a> that allows you to just pass x, y coordinates and click somewhere. Using C++, you can achieve that same functionality using <code>mouse_event()</code> or <...
0
2009-06-17T14:37:34Z
[ "python", "ruby", "perl", "winapi" ]
Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?
1,007,391
<p>Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour?</p> <p><strong>Details:</strong> </p> <p>This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nic...
1
2009-06-17T14:29:06Z
1,009,497
<p>To answer the actual question, in Perl, you would use the SendMouse (and the associated functions) provided by the <a href="http://search.cpan.org/~karasik/Win32-GuiTest-1.56/" rel="nofollow">Win32::GuiTest</a> module.</p> <pre><code>#!/usr/bin/perl use strict; use warnings; use Win32::GuiTest qw( MouseMoveAbsPix...
6
2009-06-17T21:01:00Z
[ "python", "ruby", "perl", "winapi" ]
Using Perl, Python, or Ruby, how to write a program to "click" on the screen at scheduled time?
1,007,391
<p>Using Perl, Python, or Ruby, can I write a program, probably calling Win32 API, to "click" on the screen at scheduled time, like every 1 hour?</p> <p><strong>Details:</strong> </p> <p>This is for experimentation -- and can the clicking be effective on Flash content as well as any element on screen? It can be nic...
1
2009-06-17T14:29:06Z
1,009,537
<p>If using a different tool is allowed, you should take a look at <a href="http://www.autohotkey.com/" rel="nofollow">AutoHotkey</a> or <a href="http://www.autoitscript.com/autoit3/" rel="nofollow">AutoIt</a>. These tools were made for this sort of thing, and I've always been keen on using the right tools for the righ...
1
2009-06-17T21:09:40Z
[ "python", "ruby", "perl", "winapi" ]
mrdivide function in MATLAB: what is it doing, and how can I do it in Python?
1,007,442
<p>I have this line of MATLAB code:</p> <pre><code>a/b </code></pre> <p>I am using these inputs:</p> <pre><code>a = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9] b = ones(25, 18) </code></pre> <p>This is the result (a 1x25 matrix):</p> <pre><code>[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] </code></pre> <p>Wha...
6
2009-06-17T14:36:13Z
1,007,469
<p>a/b finds the least square solution to the system of linear equations bx = a</p> <p>if b is invertible, this is a*inv(b), but if it isn't, the it is the x which minimises norm(bx-a)</p> <p>You can read more about least squares on <a href="http://en.wikipedia.org/wiki/Least%5Fsquares" rel="nofollow">wikipedia</a>.<...
1
2009-06-17T14:40:02Z
[ "python", "matlab", "numpy", "linear-algebra" ]
mrdivide function in MATLAB: what is it doing, and how can I do it in Python?
1,007,442
<p>I have this line of MATLAB code:</p> <pre><code>a/b </code></pre> <p>I am using these inputs:</p> <pre><code>a = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9] b = ones(25, 18) </code></pre> <p>This is the result (a 1x25 matrix):</p> <pre><code>[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] </code></pre> <p>Wha...
6
2009-06-17T14:36:13Z
1,007,532
<p>Per <a href="http://mathesaurus.sourceforge.net/matlab-numpy.html" rel="nofollow">this handy "cheat sheet"</a> of numpy for matlab users, <code>linalg.lstsq(b,a)</code> -- <code>linalg</code> is <a href="http://www.scipy.org/doc/numpy%5Fapi%5Fdocs/numpy.linalg.linalg.html" rel="nofollow">numpy.linalg.linalg</a>, a l...
1
2009-06-17T14:49:28Z
[ "python", "matlab", "numpy", "linear-algebra" ]
mrdivide function in MATLAB: what is it doing, and how can I do it in Python?
1,007,442
<p>I have this line of MATLAB code:</p> <pre><code>a/b </code></pre> <p>I am using these inputs:</p> <pre><code>a = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,9] b = ones(25, 18) </code></pre> <p>This is the result (a 1x25 matrix):</p> <pre><code>[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] </code></pre> <p>Wha...
6
2009-06-17T14:36:13Z
15,739,248
<p><a href="http://www.mathworks.com/help/matlab/ref/mrdivide.html" rel="nofollow">MRDIVIDE</a> or the <code>/</code> operator actually solves the <code>xb = a</code> linear system, as opposed to <a href="http://www.mathworks.com/help/matlab/ref/mldivide.html" rel="nofollow">MLDIVIDE</a> or the <code>\</code> operator ...
3
2013-04-01T07:14:36Z
[ "python", "matlab", "numpy", "linear-algebra" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,499
<p>You don't need regular expressions, Python has a string method that does what you need:</p> <pre><code>mystring.replace (" ", "_") </code></pre>
137
2009-06-17T14:44:23Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,503
<p>Using the <code>re</code> module:</p> <pre><code>import re re.sub('\s+', '_', "This should be connected") # This_should_be_connected re.sub('\s+', '_', 'And so\tshould this') # And_so_should_this </code></pre> <p>Unless you have multiple spaces or other whitespace possibilities as above, you may just wish to ...
11
2009-06-17T14:45:07Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,508
<p>use string's replace method:</p> <p><code>"this should be connected".replace(" ", "_")</code></p> <p><code>"this_should_be_disconnected".replace("_", " ")</code></p>
9
2009-06-17T14:45:30Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,615
<p>Replacing spaces is fine, but I might suggest going a little further to handle other URL-hostile characters like question marks, apostrophes, exclamation points, etc. </p> <p>Also note that the general consensus among SEO experts is that <a href="http://www.google.com/search?q=dashes+underscores+seo">dashes are pr...
42
2009-06-17T15:03:21Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,685
<p>Django has a 'slugify' function which does this, as well as other URL-friendly optimisations. It's hidden away in the defaultfilters module.</p> <pre><code>&gt;&gt;&gt; from django.template.defaultfilters import slugify &gt;&gt;&gt; slugify("This should be connected") this-should-be-connected </code></pre> <p>Thi...
33
2009-06-17T15:15:21Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,007,836
<p>I'm using the following piece of code for my friendly urls:</p> <pre><code>from unicodedata import normalize from re import sub def slugify(title): name = normalize('NFKD', title).encode('ascii', 'ignore').replace(' ', '-').lower() #remove `other` characters name = sub('[^a-zA-Z0-9_-]', '', name) #...
5
2009-06-17T15:36:32Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,012,401
<p>Python has a built in method on strings called replace which is used as so:</p> <pre><code>string.replace(old, new) </code></pre> <p>So you would use:</p> <pre><code>string.replace(" ", "_") </code></pre> <p>I had this problem a while ago and I wrote code to replace characters in a string. I have to start rememb...
1
2009-06-18T12:34:42Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
1,016,761
<pre><code>perl -e 'map { $on=$_; s/ /_/; rename($on, $_) or warn $!; } &lt;*&gt;;' </code></pre> <p>Match et replace space > underscore of all files in current directory</p>
-1
2009-06-19T07:30:53Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
3,176,580
<p>OP is using python, but in javascript (something to be careful of since the syntaxes are similar.</p> <pre><code>// only replaces the first instance of ' ' with '_' "one two three".replace(' ', '_'); =&gt; "one_two three" // replaces all instances of ' ' with '_' "one two three".replace(/\s/g, '_'); =&gt; "one_tw...
2
2010-07-04T23:34:14Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
10,376,875
<p>This takes into account blank characters other than space and I think it's faster than using <code>re</code> module:</p> <pre><code>url = "_".join( title.split() ) </code></pre>
16
2012-04-29T23:18:36Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
32,827,222
<p>Surprisingly this library not mentioned yet</p> <p>python package named python-slugify, which does a pretty good job of slugifying:</p> <pre><code>pip install python-slugify </code></pre> <p>Works like this:</p> <pre><code>from slugify import slugify txt = "This is a test ---" r = slugify(txt) self.assertEquals...
1
2015-09-28T16:01:41Z
[ "python", "regex", "django" ]
How do I replace whitespaces with underscore and vice versa?
1,007,481
<p>I want to replace whitespace with underscore in a string to create nice URLs. So that for example:</p> <pre><code>"This should be connected" becomes "This_should_be_connected" </code></pre> <p>I am using Python with Django. Can this be solved using regular expressions? </p>
77
2009-06-17T14:41:36Z
38,686,304
<pre><code>mystring.replace (" ", "_") </code></pre> <p>if you assign this value to any variable, it will work</p> <pre><code>s = mystring.replace (" ", "_") </code></pre> <p>by default mystring wont have this</p>
0
2016-07-31T16:51:23Z
[ "python", "regex", "django" ]
How to tell Buildout to install a egg from a URL (w/o pypi)
1,007,488
<p>I have some egg accessible as a URL, say <a href="http://myhosting.com/somepkg.egg" rel="nofollow">http://myhosting.com/somepkg.egg</a> . Now I don't have this somepkg listed on pypi. How do I tell buildout to fetch and install it for me. I have tried a few recipes but no luck so far.</p> <p>TIA</p>
5
2009-06-17T14:43:00Z
1,007,770
<p>You should just be able to add a 'find-links' option to your [buildout] section within the buildout.cfg file. I just tested this internally with the following buildout.cfg.</p> <pre><code>[buildout] find-links = http://buildslave01/eggs/hostapi.core-1.0_r102-py2.4.egg parts = mypython [mypython] recipe = zc.recip...
5
2009-06-17T15:27:51Z
[ "python", "buildout", "egg" ]
How do I build a list of all possible tuples from this table?
1,007,666
<p>Suppose I have a set of column definitions:</p> <pre><code>Col1: value11 value12 value13 Col2: value21 value22 Col3: value31 value32 value33 ... </code></pre> <p>Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:</p> <pre><...
2
2009-06-17T15:12:01Z
1,007,739
<p>Looks like itertools.combination could help you.</p> <pre><code>&gt;&gt;&gt; from itertools import combinations &gt;&gt;&gt; list(combinations(xrange(5), 2)) [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)] &gt;&gt;&gt; list(combinations(xrange(5), 3)) [(0, 1, 2), (0, 1, 3), (0, 1, 4...
0
2009-06-17T15:21:58Z
[ "python", "algorithm" ]
How do I build a list of all possible tuples from this table?
1,007,666
<p>Suppose I have a set of column definitions:</p> <pre><code>Col1: value11 value12 value13 Col2: value21 value22 Col3: value31 value32 value33 ... </code></pre> <p>Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:</p> <pre><...
2
2009-06-17T15:12:01Z
1,007,741
<p>The best way to get this is going to be using itertools.product(). For example:</p> <pre><code>import itertools group1 = ['a', 'b'] group2 = ['c', 'd'] print list(itertools.product(group1, group2)) #==&gt; [('a', 'c'), ('a', 'd'), ('b', 'c'), ('b', 'd')] </code></pre> <p>This function accepts multiple arguments...
13
2009-06-17T15:22:28Z
[ "python", "algorithm" ]
How do I build a list of all possible tuples from this table?
1,007,666
<p>Suppose I have a set of column definitions:</p> <pre><code>Col1: value11 value12 value13 Col2: value21 value22 Col3: value31 value32 value33 ... </code></pre> <p>Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:</p> <pre><...
2
2009-06-17T15:12:01Z
1,007,853
<p>In addition to using itertools.product() as jeremy suggests, you might want to consider converting your list of tuples to a dict to make lookups for columnName fast:</p> <p><code>dict(tupleList)</code></p>
1
2009-06-17T15:38:13Z
[ "python", "algorithm" ]
How do I build a list of all possible tuples from this table?
1,007,666
<p>Suppose I have a set of column definitions:</p> <pre><code>Col1: value11 value12 value13 Col2: value21 value22 Col3: value31 value32 value33 ... </code></pre> <p>Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:</p> <pre><...
2
2009-06-17T15:12:01Z
1,007,859
<p>more general solutions that Jeremy's would be:</p> <pre><code>import itertools full = [[value11, value12, value13], [value21, value22], [value31, value32, value33]] ids = 0, 2 </code></pre> <p>or if it is a dict (as it should be):</p> <pre><code>full = {'col1': [value11, value12, value13], ...
2
2009-06-17T15:38:55Z
[ "python", "algorithm" ]
How do I build a list of all possible tuples from this table?
1,007,666
<p>Suppose I have a set of column definitions:</p> <pre><code>Col1: value11 value12 value13 Col2: value21 value22 Col3: value31 value32 value33 ... </code></pre> <p>Given some subset of columns -- 2 or more -- I want to find all possible values for those columns. Suppose I choose columns 1 and 2, above:</p> <pre><...
2
2009-06-17T15:12:01Z
1,007,880
<p>I'll bet <code>itertools</code>-based solutions are going to be faster, but if they need to be avoided (e.g. stuck on Python 2.5 without itertools.product, etc), it can of course be entirely coded in "base Python" when one must.</p> <p>Trying to "pull out all the stops" for speed, maybe something like:</p> <pre><c...
1
2009-06-17T15:41:24Z
[ "python", "algorithm" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,873
<p>You should be using os.popen() if you simply import os.</p>
-1
2009-06-17T15:40:26Z
[ "python", "popen" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,878
<p>Popen is defined in the subprocess module</p> <pre><code>import subprocess ... subprocess.Popen(...) </code></pre> <p>Or:</p> <pre><code>from subprocess import Popen Popen(...) </code></pre>
7
2009-06-17T15:41:15Z
[ "python", "popen" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,890
<p>If your import looks like this:</p> <pre><code>import os </code></pre> <p>Then you need to reference the things included in os like this:</p> <pre><code>os.popen() </code></pre> <p>If you dont want to do that, you can change your import to look like this:</p> <pre><code>from os import * </code></pre> <p>Which ...
1
2009-06-17T15:42:13Z
[ "python", "popen" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,897
<p>When you import a module, the module's members don't become part of the global namespace: you still have to prefix them with <code>modulename.</code>. So, you have to say</p> <pre><code>import os process = os.popen(command, mode, bufsize) </code></pre> <p>Alternatively, you can use the <code>from module import na...
0
2009-06-17T15:43:08Z
[ "python", "popen" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,900
<p>This looks like Popen from the subprocess module (python >= 2.4)</p> <pre><code>from subprocess import Popen </code></pre>
1
2009-06-17T15:43:12Z
[ "python", "popen" ]
Popen and python
1,007,855
<p>Working on some code and I'm given the error when running it from the command prompt...</p> <pre><code>NameError: name 'Popen' is not defined </code></pre> <p>but I've imported both <code>import os</code> and <code>import sys</code>.</p> <p>Here's part of the code</p> <pre><code>exepath = os.path.join(EXE File l...
4
2009-06-17T15:38:25Z
1,007,901
<p>you should do:</p> <pre><code>import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc. </code></pre>
26
2009-06-17T15:43:15Z
[ "python", "popen" ]
How do I test if a string exists in a Genshi stream?
1,008,038
<p>I'm working on a plugin for Trac and am inserting some javascript into the rendered HTML by manipulating the Genshi stream.</p> <p>I need to test if a javascript function is already in the HTML and if it is then overwrite it with a new version, if it isn't then add it to the HTML.</p> <p>How do I perform a search ...
0
2009-06-17T16:04:19Z
1,008,223
<p>Aha!! I have solved this by first attempting to remove the function from the stream: </p> <pre><code>stream = stream | Transformer('.//head/script["functionName()"]').remove() </code></pre> <p>and then adding the updated/new version:</p> <pre><code>stream = stream | Transformer('.//head').append(tag.script(functi...
1
2009-06-17T16:35:49Z
[ "python", "stream", "genshi" ]
Execution order with threads and PyGTK on Windows
1,008,322
<p>I'm having issues with threads and PyGTK on Windows. According the the <a href="http://faq.pygtk.org/index.py?req=show&amp;file=faq21.003.htp" rel="nofollow">PyGTK FAQ</a> (and my own experimentation), the only way to reliably update the GUI from a child thread is to use the <code>gobject.idle_add</code> function. ...
1
2009-06-17T16:56:41Z
1,008,365
<p>You could wrap the two functions into another function and call idle_add on this function:</p> <pre><code>def update_and_print(self): self.updateText() print self.textEntry.get_text() def startThread(self): gobject.idle_add(self.update_and_print) </code></pre>
1
2009-06-17T17:04:14Z
[ "python", "windows", "multithreading", "pygtk" ]
Execution order with threads and PyGTK on Windows
1,008,322
<p>I'm having issues with threads and PyGTK on Windows. According the the <a href="http://faq.pygtk.org/index.py?req=show&amp;file=faq21.003.htp" rel="nofollow">PyGTK FAQ</a> (and my own experimentation), the only way to reliably update the GUI from a child thread is to use the <code>gobject.idle_add</code> function. ...
1
2009-06-17T16:56:41Z
1,012,052
<p>Don't try to update or access your GUI from a thread. You're just asking for trouble. For example, the fact that "<code>get_text</code>" works <em>at all</em> in a thread is almost an accident. You might be able to rely on it in GTK - although I'm not even sure about that - but you won't be able to do so in other...
2
2009-06-18T10:59:31Z
[ "python", "windows", "multithreading", "pygtk" ]
Name of file I'm editing
1,008,557
<p>I'm editing a file in ~/Documents. However, my working directory is somewhere else, say ~/Desktop.</p> <p>The file I'm editing is a Python script. I'm interested in doing a command like...</p> <p>:!python </p> <p>without needing to do</p> <p>:!python ~/Documents/script.py</p> <p>Is that possible? If so, what wo...
2
2009-06-17T17:45:14Z
1,008,586
<p>Try: !python %</p>
9
2009-06-17T17:48:58Z
[ "python", "vim" ]
Name of file I'm editing
1,008,557
<p>I'm editing a file in ~/Documents. However, my working directory is somewhere else, say ~/Desktop.</p> <p>The file I'm editing is a Python script. I'm interested in doing a command like...</p> <p>:!python </p> <p>without needing to do</p> <p>:!python ~/Documents/script.py</p> <p>Is that possible? If so, what wo...
2
2009-06-17T17:45:14Z
1,008,733
<p>I quite often map a key to do this for me. I usually use the F5 key as that has no command associated with it by default in vim.</p> <p>The mapping I like to use is:</p> <pre><code>:map &lt;F5&gt; :w&lt;CR&gt;:!python % 2&gt;&amp;1 \| tee /var/tmp/robertw/results&lt;CR&gt; </code></pre> <p>this will also make sur...
6
2009-06-17T18:19:26Z
[ "python", "vim" ]
Lookup and combine data in Python
1,008,587
<p>I have 3 text files</p> <ol> <li>many lines of <code>value1&lt;tab&gt;value2</code> (maybe 600)</li> <li>many more lines of <code>value2&lt;tab&gt;value3</code> (maybe 1000)</li> <li>many more lines of <code>value2&lt;tab&gt;value4</code> (maybe 2000)</li> </ol> <p>Not all lines match, some will have one or more v...
1
2009-06-17T17:49:09Z
1,008,643
<p>Start with this.</p> <pre><code>def loadDictionaryFromAFile( aFile ): dictionary = {} for line in aFile: fields = line.split('\t') dictionary[fields[0]]= fields dict2 = loadDictionaryFromAFile( open("file2","r" ) dict3 = loadDictionaryFromAFile( open("file3","r" ) for line in open("file1",...
3
2009-06-17T18:00:45Z
[ "python", "string", "file" ]
Lookup and combine data in Python
1,008,587
<p>I have 3 text files</p> <ol> <li>many lines of <code>value1&lt;tab&gt;value2</code> (maybe 600)</li> <li>many more lines of <code>value2&lt;tab&gt;value3</code> (maybe 1000)</li> <li>many more lines of <code>value2&lt;tab&gt;value4</code> (maybe 2000)</li> </ol> <p>Not all lines match, some will have one or more v...
1
2009-06-17T17:49:09Z
1,008,647
<p>Untested:</p> <pre><code>f1 = open("file1.txt") f2 = open("file2.txt") f3 = open("file3.txt") v1 = [line.split() for line in f1] # dict comprehensions following, these need Python 3 v2 = {vals[0]:vals[1] for vals in line.split() for line in f2} v3 = {vals[0]:vals[1] for vals in line.split() for line in f3} for v ...
5
2009-06-17T18:01:14Z
[ "python", "string", "file" ]
Popen.communicate() throws OSError: "[Errno 10] No child processes"
1,008,858
<p>I'm trying to start up a child process and get its output on Linux from Python using the subprocess module:</p> <pre><code>#!/usr/bin/python2.4 import subprocess p = subprocess.Popen(['ls', '-l', '/etc'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate...
8
2009-06-17T18:40:15Z
1,009,382
<p>You might be running into the bug mentioned here: <a href="http://bugs.python.org/issue1731717" rel="nofollow">http://bugs.python.org/issue1731717</a></p>
3
2009-06-17T20:32:03Z
[ "python", "linux" ]
Popen.communicate() throws OSError: "[Errno 10] No child processes"
1,008,858
<p>I'm trying to start up a child process and get its output on Linux from Python using the subprocess module:</p> <pre><code>#!/usr/bin/python2.4 import subprocess p = subprocess.Popen(['ls', '-l', '/etc'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate...
8
2009-06-17T18:40:15Z
1,198,166
<p>I'm not able to reproduce this on my Python (2.4.6-1ubuntu3). How are you running your script? How often does this occur?</p>
0
2009-07-29T05:18:29Z
[ "python", "linux" ]
Popen.communicate() throws OSError: "[Errno 10] No child processes"
1,008,858
<p>I'm trying to start up a child process and get its output on Linux from Python using the subprocess module:</p> <pre><code>#!/usr/bin/python2.4 import subprocess p = subprocess.Popen(['ls', '-l', '/etc'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate...
8
2009-06-17T18:40:15Z
2,321,095
<p>I ran into this problem using Python 2.6.4 which I built into my home directory (because I don't want to upgrade the "built-in" Python on the machine).</p> <p>I worked around it by replacing <code>subprocess.Popen()</code> with (the deprecated) <code>os.popen3()</code>.</p>
0
2010-02-23T19:35:22Z
[ "python", "linux" ]
Popen.communicate() throws OSError: "[Errno 10] No child processes"
1,008,858
<p>I'm trying to start up a child process and get its output on Linux from Python using the subprocess module:</p> <pre><code>#!/usr/bin/python2.4 import subprocess p = subprocess.Popen(['ls', '-l', '/etc'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate...
8
2009-06-17T18:40:15Z
3,837,851
<p>Are you intercepting SIGCHLD in the script? If you are then Popen will not run as expected since it relies on it's own handler for that signal. </p> <p>You can check for SIGCHLD handlers by commenting out the Popen call and then running:</p> <pre><code>strace python &lt;your_script.py&gt; | grep SIGCHLD </code></p...
6
2010-10-01T09:16:34Z
[ "python", "linux" ]
Processing pairs of values from two sequences in Clojure
1,009,037
<p>I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?</p>
8
2009-06-17T19:20:23Z
1,009,078
<pre><code>(zipmap [:a :b :c] (range 3)) -&gt; {:c 2, :b 1, :a 0} </code></pre> <p>Iterating over maps happens pairwise, e.g. like this:</p> <pre><code>(doseq [[k v] (zipmap [:a :b :c] (range 3))] (printf "key: %s, value: %s\n" k v)) </code></pre> <p>prints:</p> <pre><code>key: :c, value: 2 key: :b, value: 1 key:...
4
2009-06-17T19:30:16Z
[ "python", "clojure", "zip" ]
Processing pairs of values from two sequences in Clojure
1,009,037
<p>I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?</p>
8
2009-06-17T19:20:23Z
1,009,096
<p>Another way is to simply use map together with some function that collects its arguments in a sequence, like this:</p> <pre><code>user=&gt; (map vector '(1 2 3) "abc") ([1 \a] [2 \b] [3 \c]) </code></pre>
12
2009-06-17T19:34:06Z
[ "python", "clojure", "zip" ]
Processing pairs of values from two sequences in Clojure
1,009,037
<p>I'm trying to get into the Clojure community. I've been working a lot with Python, and one of the features I make extensive use of is the zip() method, for iterating over pairs of values. Is there a (clever and short) way of achieving the same in Clojure?</p>
8
2009-06-17T19:20:23Z
1,016,876
<p>The question has been answered, but there's still <code>interleave</code>, which also handles an arbitrary number of sequences, but does not group the resulting sequence into tuples (but you can use <code>partition</code> for that).</p>
3
2009-06-19T08:16:43Z
[ "python", "clojure", "zip" ]
Obtaining financial data from Google Finance which is outside the scope of the API
1,009,524
<p>Google's finance API is incomplete -- many of the figures on a page such as:</p> <p><a href="http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE" rel="nofollow">http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE</a></p> <p>are not available via the API. </p> <p>I need this data to rank companies on Canadian...
5
2009-06-17T21:07:00Z
1,009,573
<p>Scraping web pages always sucks, but I would recommend converting them to xml (via tidy or some other HTML -> XML program) and then using xpath to walk the nodes that you are interested in.</p>
0
2009-06-17T21:20:17Z
[ "python", "api", "data-mining", "google-finance" ]
Obtaining financial data from Google Finance which is outside the scope of the API
1,009,524
<p>Google's finance API is incomplete -- many of the figures on a page such as:</p> <p><a href="http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE" rel="nofollow">http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE</a></p> <p>are not available via the API. </p> <p>I need this data to rank companies on Canadian...
5
2009-06-17T21:07:00Z
1,009,673
<p><a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a> would be the preferred method of HTML parsing with Python</p> <p>Have you looked into options besides Google (e.g. Yahoo Finance API)?</p>
3
2009-06-17T21:42:24Z
[ "python", "api", "data-mining", "google-finance" ]
Obtaining financial data from Google Finance which is outside the scope of the API
1,009,524
<p>Google's finance API is incomplete -- many of the figures on a page such as:</p> <p><a href="http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE" rel="nofollow">http://www.google.com/finance?fstype=ii&amp;q=NYSE:GE</a></p> <p>are not available via the API. </p> <p>I need this data to rank companies on Canadian...
5
2009-06-17T21:07:00Z
1,010,083
<p>You could try asking Google to provide the missing APIs. Otherwise, you're stuck with <a href="http://en.wikipedia.org/wiki/Screen_scraping" rel="nofollow">screen scraping</a>, which is never fun, prone to breaking without notice, and <strong>likely in violation of Google's terms of service</strong>.</p> <p>But, i...
4
2009-06-17T23:55:59Z
[ "python", "api", "data-mining", "google-finance" ]
Output 2 dim array 'list of lists" to text file in python
1,009,712
<p>Simple question - I am creating a two dim array (<code>ddist = [[0]*d for _ in [0]*d]</code>) using lists in the code below. It outputs distance using gis data. I just want a simple way to take the result of my array/list and output to a text file keeping the same N*N structure. I have used output from print statem...
1
2009-06-17T21:49:26Z
1,009,764
<p>that's what you could to output your 2-d list (or any 2d list for that matter):</p> <pre><code>with open(outfile, 'w') as file: file.writelines('\t'.join(str(j) for j in i) + '\n' for i in top_list) </code></pre>
2
2009-06-17T22:05:40Z
[ "python", "list", "text" ]
Timestamp conversion is off by an hour
1,009,812
<p>I'm trying to parse a twitter feed in django, and I'm having a strange problem converting the published time:</p> <p>I've got the time from the feed into a full 9-tuple correctly:</p> <pre><code>&gt;&gt; print tweet_time time.struct_time(tm_year=2009, tm_mon=6, tm_mday=17, tm_hour=14, tm_min=35, tm_sec=28, tm_wday...
2
2009-06-17T22:22:35Z
1,009,828
<p>try flipping the isdst (is daylight savings flag) to a -1 and see if that fixes it. -1 tells it to use (guess) the local daylight savings setting and roll with that. </p>
5
2009-06-17T22:26:28Z
[ "python", "django", "datetime", "time" ]
How to embed some application window in my application using any Python GUI framework
1,009,813
<p>I want some application to look like widget inside my Python application.</p> <p>That's all. I dont need any interaction between them. I'm interested in solutions in <strong>any</strong> GUI toolkit for both windows and x windows.</p> <p>It would be nice to have a solution with Tkinter but it's not crucial.</p>
5
2009-06-17T22:22:44Z
1,009,942
<p>Using GTK on X windows (i.e. Linux, FreeBSD, Solaris), you can use the XEMBED protocol to embed widgets using <a href="http://www.pygtk.org/docs/pygtk/class-gtksocket.html"><code>gtk.Socket</code></a>. Unfortunately, the application that you're launching has to explicitly support it so that you can tell it to embed...
5
2009-06-17T23:01:29Z
[ "python", "user-interface" ]
Using string as variable name
1,009,831
<p>Is there any way for me to use a string to call a method of a class? Here's an example that will hopefully explain better (using the way I think it should be):</p> <pre><code>class helloworld(): def world(self): print "Hello World!" str = "world" hello = helloworld() hello.`str`() </code></pre> <p>Wh...
6
2009-06-17T22:27:22Z
1,009,837
<p>You can use <a href="http://docs.python.org/3.0/library/functions.html#getattr"><code>getattr</code></a>:</p> <pre><code>&gt;&gt;&gt; class helloworld: ... def world(self): ... print("Hello World!") ... &gt;&gt;&gt; m = "world" &gt;&gt;&gt; hello = helloworld() &gt;&gt;&gt; getattr(hello, m)() Hello Wo...
16
2009-06-17T22:31:03Z
[ "python" ]
Using string as variable name
1,009,831
<p>Is there any way for me to use a string to call a method of a class? Here's an example that will hopefully explain better (using the way I think it should be):</p> <pre><code>class helloworld(): def world(self): print "Hello World!" str = "world" hello = helloworld() hello.`str`() </code></pre> <p>Wh...
6
2009-06-17T22:27:22Z
1,009,848
<p>one way is you can set variables to be equal to functions just like data</p> <pre><code>def thing1(): print "stuff" def thing2(): print "other stuff" avariable = thing1 avariable () avariable = thing2 avariable () </code></pre> <p>And the output you'l get is </p> <pre><code>stuff other stuff </code></pr...
-3
2009-06-17T22:33:33Z
[ "python" ]
Using string as variable name
1,009,831
<p>Is there any way for me to use a string to call a method of a class? Here's an example that will hopefully explain better (using the way I think it should be):</p> <pre><code>class helloworld(): def world(self): print "Hello World!" str = "world" hello = helloworld() hello.`str`() </code></pre> <p>Wh...
6
2009-06-17T22:27:22Z
1,009,862
<p><em>Warning: exec is a dangerous function to use, study it before using it</em></p> <p>You can also use the built-in function "exec":</p> <pre><code>&gt;&gt;&gt; def foo(): print('foo was called'); ... &gt;&gt;&gt; some_string = 'foo'; &gt;&gt;&gt; exec(some_string + '()'); foo was called &gt;&gt;&gt; </code></pre...
2
2009-06-17T22:38:55Z
[ "python" ]
Using string as variable name
1,009,831
<p>Is there any way for me to use a string to call a method of a class? Here's an example that will hopefully explain better (using the way I think it should be):</p> <pre><code>class helloworld(): def world(self): print "Hello World!" str = "world" hello = helloworld() hello.`str`() </code></pre> <p>Wh...
6
2009-06-17T22:27:22Z
1,009,894
<p>What you're looking for is <a href="http://www.python.org/doc/2.5.2/ref/exec.html" rel="nofollow">exec</a></p> <pre><code>class helloworld(): def world(self): print "Hello World!" str = "world" hello = helloworld() completeString = "hello.%s()" % str exec(completString) </code></pre>
-3
2009-06-17T22:45:19Z
[ "python" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,009,864
<h2><em>Please</em> note that optparse was deprecated in version 2.7 of Python:</h2> <p><a href="http://docs.python.org/2/library/optparse.html">http://docs.python.org/2/library/optparse.html</a>. <strong>argparse</strong> is the replacement: <a href="http://docs.python.org/2/library/argparse.html#module-argparse">ht...
200
2009-06-17T22:39:49Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,009,879
<pre><code>import sys print "\n".join(sys.argv) </code></pre> <p><code>sys.argv</code> is a list that contains all the arguments passed to the script on the command line.</p> <p>Basically,</p> <pre><code>import sys print sys.argv[1:] </code></pre>
233
2009-06-17T22:42:25Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,009,882
<p>One way to do it is using <code>sys.argv</code>. This will print the script name as the first argument and all the other parameters that you pass to it.</p> <pre><code>import sys for arg in sys.argv: print arg </code></pre>
31
2009-06-17T22:43:08Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,010,367
<p>I like getopt from stdlib, eg:</p> <pre><code>try: opts, args = getopt.getopt(sys.argv[1:], 'h', ['help']) except getopt.GetoptError, err: usage(err) for opt, arg in opts: if opt in ('-h', '--help'): usage() if len(args) != 1: usage("specify thing...") </code></pre> <p>Lately I have bee...
4
2009-06-18T01:30:28Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,010,597
<p>There is also <a href="https://docs.python.org/library/argparse.html" rel="nofollow"><code>argparse</code> stdlib module</a> (an "impovement" on stdlib's <code>optparse</code> module). Example from <a href="https://docs.python.org/howto/argparse.html" rel="nofollow">the introduction to argparse</a>:</p> <pre><code>...
34
2009-06-18T03:12:25Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,010,728
<p>I use optparse myself, but really like the direction Simon Willison is taking with his recently introduced <a href="http://github.com/simonw/optfunc/tree/master">optfunc</a> library. It works by:</p> <blockquote> <p>"introspecting a function definition (including its arguments and their default values) and u...
16
2009-06-18T04:07:57Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
1,050,472
<p>Just going around evangelizing for <a href="http://code.google.com/p/argparse/">argparse</a> which is better for <a href="http://argparse.googlecode.com/svn/trunk/doc/argparse-vs-optparse.html">these</a> reasons.. essentially:</p> <p><em>(copied from the link)</em></p> <ul> <li><p>argparse module can handle positi...
102
2009-06-26T18:15:02Z
[ "python", "command-line", "command-line-arguments" ]
Command Line Arguments In Python
1,009,860
<p>I am originally a C programmer. I have seen numerous tricks and "hacks" to read many different arguments. </p> <p>What are some of the ways Python programmers can do this?</p> <h3>Related</h3> <ul> <li><a href="http://stackoverflow.com/questions/20063/whats-the-best-way-to-grab-parse-command-line-arguments-passed...
269
2009-06-17T22:38:30Z
4,915,576
<p>You may be interested in a little Python module I wrote to make handling of command line arguments even easier (open source and free to use) - <a href="http://freshmeat.net/projects/commando" rel="nofollow">Commando</a></p>
4
2011-02-06T19:28:43Z
[ "python", "command-line", "command-line-arguments" ]