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 and Oracle | 1,796,198 | <p>I would like to be able to connect to Oracle 10.1.0.2.0 (which is installed on different machine) via python.</p>
<p>My comp is running on Ubuntu 9.04 Jaunty with Python 2.6 installed.</p>
<p>I have downloaded and unpacked <code>instantclient-basic-linux32-10.1.0.5-20060511.zip</code> , set <code>LD_LIBRARY_PATH</... | 3 | 2009-11-25T11:03:58Z | 1,796,464 | <p>I believe OCIClientVersion requires Oracle 10g release 2, but you're using release 1.</p>
<p>It looks like cx_Oracle binary you downloaded has been compiled with -DORACLE_10GR2 which makes it include the OCIClientVersion call. Since this is a compile-time-only option there should really be downloads for 10g and 10g... | 4 | 2009-11-25T11:52:20Z | [
"python",
"django",
"oracle"
] |
python and Oracle | 1,796,198 | <p>I would like to be able to connect to Oracle 10.1.0.2.0 (which is installed on different machine) via python.</p>
<p>My comp is running on Ubuntu 9.04 Jaunty with Python 2.6 installed.</p>
<p>I have downloaded and unpacked <code>instantclient-basic-linux32-10.1.0.5-20060511.zip</code> , set <code>LD_LIBRARY_PATH</... | 3 | 2009-11-25T11:03:58Z | 1,808,405 | <p>Thanks to bobince for his answer, I will just try to summarize possible solutions to make it more readable for the others.</p>
<p>Both <code>LD_LIBRARY_PATH</code> and <code>ORACLE_HOME</code> need to point to directory where Oracle InstantClient is unpacked.</p>
<ul>
<li>You can use <code>cx_Oracle 4.4.1 for Orac... | 2 | 2009-11-27T12:11:29Z | [
"python",
"django",
"oracle"
] |
Python SSH paramiko probelm - ssh from inside of ssh session | 1,796,441 | <pre><code>import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
ip = '192.168.100.6'
client.connect(ip, username='root', password='mima')
i, o, e = client.exec_command('apt-get install sl -y --force-yes')
print o.read(), e.read()
client.close()
</code></pre>
<p>i used this example.. it is work... | 3 | 2009-11-25T11:47:07Z | 1,796,462 | <p>You exec the command "ssh" in the client, and not apt-get.</p>
<p>You can't really start a paramiko session on the client as long as your python program isn't there. The software you start using ssh must live on that machine.</p>
<p>Perhaps first scp a copy of your software, and start that using a parameter like -... | 0 | 2009-11-25T11:51:27Z | [
"python",
"ssh",
"paramiko"
] |
Python SSH paramiko probelm - ssh from inside of ssh session | 1,796,441 | <pre><code>import paramiko
client = paramiko.SSHClient()
client.load_system_host_keys()
ip = '192.168.100.6'
client.connect(ip, username='root', password='mima')
i, o, e = client.exec_command('apt-get install sl -y --force-yes')
print o.read(), e.read()
client.close()
</code></pre>
<p>i used this example.. it is work... | 3 | 2009-11-25T11:47:07Z | 1,796,474 | <p>can't you call the <code>ssh</code> command from inside of your client.exec_command?<br>
like:</p>
<pre><code>client.exec_command('ssh user@host2 "apt-get install sl -y --force-yes"')
</code></pre>
| 3 | 2009-11-25T11:54:02Z | [
"python",
"ssh",
"paramiko"
] |
Accessing a Python traceback from the C API | 1,796,510 | <p>I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, i... | 17 | 2009-11-25T12:05:44Z | 1,796,538 | <p>One principal I've found useful in writing C extensions is to use each language where it's best suited. So if you have a task to do that would be best implemented in Python, implement in Python, and if it would be best implemented in C, do it in C. Interpreting tracebacks is best done in Python for two reasons: fi... | 2 | 2009-11-25T12:13:15Z | [
"python"
] |
Accessing a Python traceback from the C API | 1,796,510 | <p>I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, i... | 17 | 2009-11-25T12:05:44Z | 1,796,569 | <p>I've discovered that <code>_frame</code> is actually defined in the <code>frameobject.h</code> header included with Python. Armed with this plus looking at <code>traceback.c</code> in the Python C implementation, we have:</p>
<pre><code>#include <Python.h>
#include <frameobject.h>
PyTracebackObject* t... | 7 | 2009-11-25T12:21:48Z | [
"python"
] |
Accessing a Python traceback from the C API | 1,796,510 | <p>I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, i... | 17 | 2009-11-25T12:05:44Z | 8,706,144 | <p>This is an old question but for future reference, you can get the current stack frame from the thread state object and then just walk the frames backward. A traceback object isn't necessary unless you want to preserve the state for the future.</p>
<p>For example:</p>
<pre><code>PyThreadState *tstate = PyThreadSta... | 6 | 2012-01-02T22:51:33Z | [
"python"
] |
Accessing a Python traceback from the C API | 1,796,510 | <p>I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, i... | 17 | 2009-11-25T12:05:44Z | 15,907,460 | <p>I prefer calling into python from C:</p>
<pre><code>err = PyErr_Occurred();
if (err != NULL) {
PyObject *ptype, *pvalue, *ptraceback;
PyObject *pystr, *module_name, *pyth_module, *pyth_func;
char *str;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
pystr = PyObject_Str(pvalue);
str ... | 7 | 2013-04-09T16:30:29Z | [
"python"
] |
Accessing a Python traceback from the C API | 1,796,510 | <p>I'm having some trouble figuring out the proper way to walk a Python traceback using the C API. I'm writing an application that embeds the Python interpreter. I want to be able to execute arbitrary Python code, and if it raises an exception, to translate it to my own application-specific C++ exception. For now, i... | 17 | 2009-11-25T12:05:44Z | 27,512,210 | <p>I had reason to do this recently while writing an allocation tracker for numpy. The previous answers are close but <code>frame->f_lineno</code> will not always return the correct line number--you need to call <code>PyFrame_GetLineNumber()</code>. Here's an updated code snippet:</p>
<pre><code>#include "frameobje... | 1 | 2014-12-16T19:16:37Z | [
"python"
] |
Python, thread and gobject | 1,796,588 | <p>I am writing a program by a framework using pygtk. The main program doing the following things:</p>
<ol>
<li>Create a watchdog thread to monitor some resource </li>
<li>Create a client to receive data from socket</li>
<li>call <code>gobject.Mainloop()</code></li>
</ol>
<p>but it seems after my program enter the Ma... | 5 | 2009-11-25T12:25:21Z | 1,796,638 | <p>Can you post some code? It could be that you have problems with the <a href="http://docs.python.org/glossary.html#term-global-interpreter-lock">Global Interpreter Lock</a>.</p>
<p><a href="http://www.jejik.com/articles/2007/01/python-gstreamer%5Fthreading%5Fand%5Fthe%5Fmain%5Floop/">Your problem solved by someone e... | 7 | 2009-11-25T12:34:35Z | [
"python",
"multithreading",
"pygtk"
] |
Python, thread and gobject | 1,796,588 | <p>I am writing a program by a framework using pygtk. The main program doing the following things:</p>
<ol>
<li>Create a watchdog thread to monitor some resource </li>
<li>Create a client to receive data from socket</li>
<li>call <code>gobject.Mainloop()</code></li>
</ol>
<p>but it seems after my program enter the Ma... | 5 | 2009-11-25T12:25:21Z | 1,799,006 | <p>You have failed to initialise the threading-based code-paths in gtk.</p>
<blockquote>
<p>You must remember two things when
using threads with PyGTK:</p>
<ol>
<li>GTK Threads must be initialised with gtk.gdk.threads_init:</li>
</ol>
</blockquote>
<p>From <a href="http://unpythonic.blogspot.com/2007/08/... | 2 | 2009-11-25T18:27:54Z | [
"python",
"multithreading",
"pygtk"
] |
import an array in python | 1,796,597 | <p>How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn't already exist.</p>
<p>For example, save out a matrix to a file then load it back.</p>
| 9 | 2009-11-25T12:26:18Z | 1,796,610 | <p>Checkout the entry on the <a href="http://scipy.org/Numpy%5FExample%5FList#head-e20ed4935bc0f3edcb23420fe9d2617dbcd6b1ea">numpy example list</a>. Here is the entry on .loadtxt()</p>
<pre><code>>>> from numpy import *
>>>
>>> data = loadtxt("myfile.txt") # myfile.txt ... | 17 | 2009-11-25T12:29:03Z | [
"python",
"numpy"
] |
import an array in python | 1,796,597 | <p>How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn't already exist.</p>
<p>For example, save out a matrix to a file then load it back.</p>
| 9 | 2009-11-25T12:26:18Z | 1,796,614 | <p>Have a look at <a href="http://www.scipy.org/Cookbook/InputOutput" rel="nofollow">SciPy cookbook</a>. It should give you an idea of some basic methods to import /export data.</p>
<p>If you save/load the files from your own Python programs, you may also want to consider the <a href="http://docs.python.org/library/pi... | 0 | 2009-11-25T12:29:26Z | [
"python",
"numpy"
] |
import an array in python | 1,796,597 | <p>How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn't already exist.</p>
<p>For example, save out a matrix to a file then load it back.</p>
| 9 | 2009-11-25T12:26:18Z | 16,517,441 | <p>(I know the question is old, but I think this might be good as a reference for people with similar questions)</p>
<p>If you want to load data from an ASCII/text file (which has the benefit or being more or less human-readable and easy to parse in other software), numpy.loadtxt is probably what you want: </p>
<ul>
... | 1 | 2013-05-13T08:11:18Z | [
"python",
"numpy"
] |
import an array in python | 1,796,597 | <p>How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn't already exist.</p>
<p>For example, save out a matrix to a file then load it back.</p>
| 9 | 2009-11-25T12:26:18Z | 16,527,094 | <p>Another option is <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html"><code>numpy.genfromtxt</code></a>, e.g:</p>
<pre><code>import numpy as np
data = np.genfromtxt("myfile.dat",delimiter=",")
</code></pre>
<p>This will make <code>data</code> a numpy array with as many rows and colu... | 6 | 2013-05-13T16:43:46Z | [
"python",
"numpy"
] |
import an array in python | 1,796,597 | <p>How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn't already exist.</p>
<p>For example, save out a matrix to a file then load it back.</p>
| 9 | 2009-11-25T12:26:18Z | 36,140,358 | <p>In Python, Storing a bare python list as a numpy.array and then saving it out to file, then loading it back, and converting it back to a list takes some conversion tricks. The confusion is because python lists are not at all the same thing as numpy.arrays:</p>
<pre><code>import numpy as np
foods = ['grape', 'cherr... | 1 | 2016-03-21T19:54:40Z | [
"python",
"numpy"
] |
Python and BeautifulSoup, not finding 'a' | 1,796,725 | <p>Here's a piece of HTML code (from delicious):</p>
<pre><code><h4>
<a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Links with Anonymous Referers &amp; Anti-Bot Protection</a>
<span class="saverem">
<em class="bookmark-actions">
<strong><a... | 3 | 2009-11-25T12:51:12Z | 1,796,814 | <p>If you want to look for an anchor with exactly those two classes you'd, have to use a regexp, I think:</p>
<pre><code>tags = soup.findAll('a', attrs={'class': re.compile(r'\binlinesave\b.*\baction\b')})
</code></pre>
<p>Keep in mind that this regexp won't work if the ordering of the class names is reversed (<code>... | 1 | 2009-11-25T13:09:58Z | [
"python",
"html",
"beautifulsoup"
] |
Python and BeautifulSoup, not finding 'a' | 1,796,725 | <p>Here's a piece of HTML code (from delicious):</p>
<pre><code><h4>
<a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Links with Anonymous Referers &amp; Anti-Bot Protection</a>
<span class="saverem">
<em class="bookmark-actions">
<strong><a... | 3 | 2009-11-25T12:51:12Z | 1,797,002 | <p>Python string methods</p>
<pre><code>html=open("file").read()
for item in html.split("<strong>"):
if "class" in item and "inlinesave action" in item:
url_with_junk = item.split('href="')[1]
m = url_with_junk.index('">')
print url_with_junk[:m]
</code></pre>
| 0 | 2009-11-25T13:46:10Z | [
"python",
"html",
"beautifulsoup"
] |
Python and BeautifulSoup, not finding 'a' | 1,796,725 | <p>Here's a piece of HTML code (from delicious):</p>
<pre><code><h4>
<a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Links with Anonymous Referers &amp; Anti-Bot Protection</a>
<span class="saverem">
<em class="bookmark-actions">
<strong><a... | 3 | 2009-11-25T12:51:12Z | 1,797,117 | <p>May be that issue is fixed in <a href="http://www.crummy.com/software/BeautifulSoup/download/3.x/BeautifulSoup-3.1.0.tar.gz" rel="nofollow">verion 3.1.0</a>, I could parse yours,</p>
<pre><code>>>> html="""<h4>
... <a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Li... | 0 | 2009-11-25T14:05:43Z | [
"python",
"html",
"beautifulsoup"
] |
Python and BeautifulSoup, not finding 'a' | 1,796,725 | <p>Here's a piece of HTML code (from delicious):</p>
<pre><code><h4>
<a rel="nofollow" class="taggedlink " href="http://imfy.us/" >Generate Secure Links with Anonymous Referers &amp; Anti-Bot Protection</a>
<span class="saverem">
<em class="bookmark-actions">
<strong><a... | 3 | 2009-11-25T12:51:12Z | 1,798,445 | <p>You might make some forward progress using pyparsing:</p>
<pre><code>from pyparsing import makeHTMLTags, withAttribute
htmlsrc="""<h4>... etc."""
atag = makeHTMLTags("a")[0]
atag.setParseAction(withAttribute(("class","inlinesave action")))
for result in atag.searchString(htmlsrc):
print result.href
</c... | 0 | 2009-11-25T17:12:49Z | [
"python",
"html",
"beautifulsoup"
] |
How to import a file by its full path using C api? | 1,796,925 | <pre><code>PyObject* PyImport_ImportModule( const char *name)
</code></pre>
<p>How to specify a full file path instead and a module name?</p>
<p>Like <code>PyImport_SomeFunction(const char *path_to_script, const char *name)</code></p>
<p>Thanks,
Elias</p>
| 2 | 2009-11-25T13:31:25Z | 1,801,262 | <p>I can't give you a full answer, but I think I can give you a place to start. Python provides a built-in module called <code>imp</code> which provides access to import internals. It includes a function load_module() which lets you pass in a path. This is implemented in <a href="http://svn.python.org/view/python/tags/... | 1 | 2009-11-26T02:37:26Z | [
"python",
"python-c-api"
] |
How to import a file by its full path using C api? | 1,796,925 | <pre><code>PyObject* PyImport_ImportModule( const char *name)
</code></pre>
<p>How to specify a full file path instead and a module name?</p>
<p>Like <code>PyImport_SomeFunction(const char *path_to_script, const char *name)</code></p>
<p>Thanks,
Elias</p>
| 2 | 2009-11-25T13:31:25Z | 1,802,842 | <p>Eventually, I ended up using the load_source from imp module:</p>
<pre><code>s.sprintf(
"import imp\n"
"imp.load_source('%s', r'%s')", modname, script_path);
PyRun_SimpleString(s.c_str());
</code></pre>
<p>I think it is the most feasible solution. Other suggestions are welcome.</p>
| 1 | 2009-11-26T10:23:57Z | [
"python",
"python-c-api"
] |
How to import a file by its full path using C api? | 1,796,925 | <pre><code>PyObject* PyImport_ImportModule( const char *name)
</code></pre>
<p>How to specify a full file path instead and a module name?</p>
<p>Like <code>PyImport_SomeFunction(const char *path_to_script, const char *name)</code></p>
<p>Thanks,
Elias</p>
| 2 | 2009-11-25T13:31:25Z | 13,102,694 | <p>Another solution for cases when all *.py file are in one directory: </p>
<pre><code>PySys_SetPath("path/with/python/files");
PyObject *pModule = PyImport_ImportModule("filename_without_extension");
</code></pre>
| 1 | 2012-10-27T17:58:42Z | [
"python",
"python-c-api"
] |
How to import a file by its full path using C api? | 1,796,925 | <pre><code>PyObject* PyImport_ImportModule( const char *name)
</code></pre>
<p>How to specify a full file path instead and a module name?</p>
<p>Like <code>PyImport_SomeFunction(const char *path_to_script, const char *name)</code></p>
<p>Thanks,
Elias</p>
| 2 | 2009-11-25T13:31:25Z | 20,006,115 | <p>As pointed out, using the above solution by AlexP, you can't import any modules outside of the specified directory. However, instead of <em>setting</em> the path, you can <em>add</em> a path, which is to be searched for modules. This can be done by appending that path to <a href="http://docs.python.org/2/library/sys... | 0 | 2013-11-15T16:42:13Z | [
"python",
"python-c-api"
] |
How to import a file by its full path using C api? | 1,796,925 | <pre><code>PyObject* PyImport_ImportModule( const char *name)
</code></pre>
<p>How to specify a full file path instead and a module name?</p>
<p>Like <code>PyImport_SomeFunction(const char *path_to_script, const char *name)</code></p>
<p>Thanks,
Elias</p>
| 2 | 2009-11-25T13:31:25Z | 32,793,465 | <p>CPython will <a href="https://github.com/python/cpython/blob/master/Python/import.c#L1706" rel="nofollow">not hesitate</a> to call through the <code>imp</code> module to perform import jobs, so there's no reason that you shouldn't do it yourself.</p>
<p>Here's one way to do it in C++, where <code>modulePath</code> ... | 0 | 2015-09-26T03:57:35Z | [
"python",
"python-c-api"
] |
Trouble Upgrading Python / Django on CentOS | 1,797,017 | <p>As you can see by reading my other thread today <a href="http://stackoverflow.com/questions/1796105/point-django-at-different-python-version">here</a>, I'm having some troubles upgrading Python.</p>
<p>At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an appli... | 0 | 2009-11-25T13:48:56Z | 1,797,127 | <p>I don't know anything about CentOS, but if you have multiple Python version installed and you wan't to install packages using <code>easy_install</code>, you just need to call it with the corresponding Python interpreter. This should install the packing into the site-package directory of Python 2.5:</p>
<pre><code>#... | 2 | 2009-11-25T14:07:20Z | [
"python",
"django",
"centos"
] |
Trouble Upgrading Python / Django on CentOS | 1,797,017 | <p>As you can see by reading my other thread today <a href="http://stackoverflow.com/questions/1796105/point-django-at-different-python-version">here</a>, I'm having some troubles upgrading Python.</p>
<p>At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an appli... | 0 | 2009-11-25T13:48:56Z | 1,797,133 | <p>easy_install is a shell script the first line of which tells it where python is installed (I am on OSX so can't say exactly what your directories will be )</p>
<p>So you could copy easy_install and change the first line to point to 2.5. (or do as Heas suggests)</p>
<p>Althernatively when you installed python 2.5 ... | 0 | 2009-11-25T14:08:37Z | [
"python",
"django",
"centos"
] |
Trouble Upgrading Python / Django on CentOS | 1,797,017 | <p>As you can see by reading my other thread today <a href="http://stackoverflow.com/questions/1796105/point-django-at-different-python-version">here</a>, I'm having some troubles upgrading Python.</p>
<p>At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an appli... | 0 | 2009-11-25T13:48:56Z | 1,799,806 | <p>You don't need to 'install' Django at all, it just needs to live on the Pythonpath somewhere. Assuming it's currently in the Python2.4 site-packages directory, you can just move it to the 2.5 one:</p>
<pre><code>sudo mv /usr/lib/python2.4/site-packages/django /usr/lib/python2.5/site-packages/django
</code></pre>
<... | 0 | 2009-11-25T20:39:19Z | [
"python",
"django",
"centos"
] |
Trouble Upgrading Python / Django on CentOS | 1,797,017 | <p>As you can see by reading my other thread today <a href="http://stackoverflow.com/questions/1796105/point-django-at-different-python-version">here</a>, I'm having some troubles upgrading Python.</p>
<p>At the moment I have Python 2.4 with Django installed on a CentOS machine. However I've recently deployed an appli... | 0 | 2009-11-25T13:48:56Z | 1,799,807 | <p>assuming your python2.5 interpreter lives in /usr/bin/python2.5, you can install setuptools for python2.5 as such:</p>
<pre><code>curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo /usr/bin/python2.5 ez_setup.py
</code></pre>
<p>Among other things, this installs an "easy_install-2.5" script in your $PATH ... | 1 | 2009-11-25T20:39:35Z | [
"python",
"django",
"centos"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 1,797,163 | <p>I would put them in settings.py. In the past, I have put system checks like this:</p>
<pre><code>try:
from local_settings import *
except ImportError:
print "Missing %s" % os.path.join(PROJECT_ROOT, "local_settings.py")
if DEBUG:
for p in [PROJECT_ROOT, MEDIA_ROOT, THEME_DIR, ADMIN_MEDIA_ROOT] + list(T... | 3 | 2009-11-25T14:12:46Z | [
"python",
"django"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 1,797,198 | <p>If you don't want to use settings module, then try project's <code>__init__.py</code>.</p>
| 4 | 2009-11-25T14:21:13Z | [
"python",
"django"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 1,797,207 | <p>If you want to check that the system is correctly installed, I think that you should write your <a href="http://docs.djangoproject.com/en/dev/howto/custom-management-commands/" rel="nofollow">own admin command</a> and run it as post-installation check.</p>
<p>I think that it doesn't worth to check if the python ver... | 4 | 2009-11-25T14:22:53Z | [
"python",
"django"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 1,798,361 | <p>We use the top-level <code>urls.py</code> for this.</p>
| 3 | 2009-11-25T16:58:13Z | [
"python",
"django"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 3,154,109 | <p>You can put it in settings.py as mentioned by others, but having code in the settings is not ideal. There is also the option of adding a handler for django.db.models.signals.class_prepared that does the desired start up checks after a specific model class is prepared.</p>
| 0 | 2010-06-30T23:17:22Z | [
"python",
"django"
] |
Correct place to put extra startup code in django? | 1,797,046 | <p>I would like to run some environment checks when my django process starts and die noisily in the case of an error. I'm thinking things like the database has an incorrect encoding or the machine has a python version we don't support.</p>
<p>I'd rather our team be faced with a fatal error that they have to fix, rathe... | 6 | 2009-11-25T13:52:56Z | 13,517,044 | <p>I have tested all three __init__.py Settings.py and urls.py methods and this is what I have found.</p>
<p>When code is run from either __init__.py or Settings.py, the start up functions are run <strong>twice</strong> upon web server start up; when the start up functions are run from urls.py the code is run <strong>... | 2 | 2012-11-22T16:48:00Z | [
"python",
"django"
] |
Problem installing Shoutpy + Boost.python on opensolaris | 1,797,110 | <p>Im trying to install shoutpy on opensolaris 2009.6. It relies on boost.python. i've installed the <code>boost_devel</code> libraries from blastwave and linked <code>/opt/csw/include/boost</code> to <code>/usr/include/boost</code> . But when I try to <code>easy_install shoutpy</code> I get the following output</p>
<... | 1 | 2009-11-25T14:04:38Z | 1,861,672 | <p>Unfortunately I've never tried to compile <code>shoutpy</code> under OpenSolaris and I don't use it these days. Boost.python requires a lot from its C++ compiler. Use <code>easy_install -b build_directory shoutpy</code> so it'll keep the source code after it fails, then check the C++ compiler Python tries to use aga... | 0 | 2009-12-07T17:47:52Z | [
"python",
"boost",
"boost-python",
"opensolaris"
] |
Microprocessor to RS-232 realtime plot using PySerial/Matplotlib? | 1,797,249 | <p>I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit <a href="http://openeeg.sourceforge.net" rel="nofollow">http://openeeg.sourceforge.net</a>)</p>
<p>The analogue output is amplifi... | 2 | 2009-11-25T14:28:04Z | 1,797,408 | <p>To handle the complicated binary data format you could maybe use <a href="http://docs.scipy.org/doc/numpy/user/basics.rec.html" rel="nofollow">structured arrays</a> in numpy (see also <a href="http://mentat.za.net/numpy/numpy%5Fadvanced%5Fslides/" rel="nofollow">here</a> for a nice introduction). After defining the ... | 2 | 2009-11-25T14:48:07Z | [
"python",
"matplotlib",
"serial-port",
"pyserial",
"microprocessors"
] |
Microprocessor to RS-232 realtime plot using PySerial/Matplotlib? | 1,797,249 | <p>I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit <a href="http://openeeg.sourceforge.net" rel="nofollow">http://openeeg.sourceforge.net</a>)</p>
<p>The analogue output is amplifi... | 2 | 2009-11-25T14:28:04Z | 1,800,496 | <p><a href="http://www.scipy.org/Cookbook/Matplotlib/Animations" rel="nofollow">This is some good reading on using matplotlib for animation with the various GUI backends</a>. Not quite what you are asking but it should give you a rough idea of matplotlib's capabilities for fast plotting/updating graphs.</p>
| 2 | 2009-11-25T22:49:35Z | [
"python",
"matplotlib",
"serial-port",
"pyserial",
"microprocessors"
] |
Microprocessor to RS-232 realtime plot using PySerial/Matplotlib? | 1,797,249 | <p>I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit <a href="http://openeeg.sourceforge.net" rel="nofollow">http://openeeg.sourceforge.net</a>)</p>
<p>The analogue output is amplifi... | 2 | 2009-11-25T14:28:04Z | 1,824,389 | <p>There's a good realtime plotting example <a href="http://eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis/" rel="nofollow">here</a>. It's a good example in that it runs with self generated data, so it's easy to test, but it's also obvious where to modify the code for plotting real data, and the code i... | 2 | 2009-12-01T06:37:42Z | [
"python",
"matplotlib",
"serial-port",
"pyserial",
"microprocessors"
] |
Is there something like for i in range(length) in PHP? | 1,797,322 | <p>In python we have:</p>
<pre><code>for i in range(length)
</code></pre>
<p>What about in PHP?</p>
| 6 | 2009-11-25T14:38:49Z | 1,797,337 | <p><code>for ($i = 0; $i < LENGTH_GOES_HERE; $i++) { ... }</code></p>
<p>or</p>
<p><code>foreach (range(0, LENGTH_GOES_HERE - 1) as $i) { ... }</code>, cf. <a href="http://php.net/manual/en/function.range.php" rel="nofollow">range()</a>.</p>
| 1 | 2009-11-25T14:40:45Z | [
"php",
"python",
"range"
] |
Is there something like for i in range(length) in PHP? | 1,797,322 | <p>In python we have:</p>
<pre><code>for i in range(length)
</code></pre>
<p>What about in PHP?</p>
| 6 | 2009-11-25T14:38:49Z | 1,797,342 | <p>Straight from the <a href="http://php.net/manual/en/function.range.php">docs:</a></p>
<pre><code>foreach (range(0, 12) as $number) {
echo $number;
}
</code></pre>
| 9 | 2009-11-25T14:41:25Z | [
"php",
"python",
"range"
] |
Is there something like for i in range(length) in PHP? | 1,797,322 | <p>In python we have:</p>
<pre><code>for i in range(length)
</code></pre>
<p>What about in PHP?</p>
| 6 | 2009-11-25T14:38:49Z | 1,797,349 | <p>There is a range function in php, you can use like this.</p>
<pre><code>foreach( range(0,10) as $y){
//do something
}
</code></pre>
<p>but unlike python, you have to pass 2 parameters, range(10) will not work.</p>
| 1 | 2009-11-25T14:41:42Z | [
"php",
"python",
"range"
] |
Is there something like for i in range(length) in PHP? | 1,797,322 | <p>In python we have:</p>
<pre><code>for i in range(length)
</code></pre>
<p>What about in PHP?</p>
| 6 | 2009-11-25T14:38:49Z | 1,797,353 | <p>Try this:</p>
<pre><code>// Generates the digits in base 10.
// array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
foreach (range(0, 9) as $number) {
echo $number;
}
</code></pre>
| 1 | 2009-11-25T14:42:00Z | [
"php",
"python",
"range"
] |
Is there something like for i in range(length) in PHP? | 1,797,322 | <p>In python we have:</p>
<pre><code>for i in range(length)
</code></pre>
<p>What about in PHP?</p>
| 6 | 2009-11-25T14:38:49Z | 1,797,358 | <p>Old fashioned <code>for</code> loops:</p>
<pre><code>for ($i = 0; $i < length; $i++) {
// ...
}
</code></pre>
<p>Or foreach using the <a href="http://php.net/range" rel="nofollow">range function</a>:</p>
<pre><code>foreach (range(1, 10) as $i) {
// ...
}
</code></pre>
| 4 | 2009-11-25T14:42:34Z | [
"php",
"python",
"range"
] |
os x python 2.6 bus error | 1,797,519 | <p>i am getting weird python bus error when building a web app.</p>
<p><a href="http://pastie.org/714569" rel="nofollow">http://pastie.org/714569</a></p>
<p>i am using python 2.6 from mac ports in osx snowleopart 10.6.2. i have done python_select and stuff. how to figure out what is going on?
thanks</p>
| 1 | 2009-11-25T15:02:47Z | 1,797,533 | <p>This is most likely a bug in Python or your web application framework. Please report it to their respective bug tracker.</p>
| 1 | 2009-11-25T15:04:53Z | [
"python",
"osx",
"osx-snow-leopard",
"macports"
] |
os x python 2.6 bus error | 1,797,519 | <p>i am getting weird python bus error when building a web app.</p>
<p><a href="http://pastie.org/714569" rel="nofollow">http://pastie.org/714569</a></p>
<p>i am using python 2.6 from mac ports in osx snowleopart 10.6.2. i have done python_select and stuff. how to figure out what is going on?
thanks</p>
| 1 | 2009-11-25T15:02:47Z | 11,086,195 | <p>I got the same error on my MacOS 10.6.8 with both python 2.7.1 and 2.6.1. The problem appeared after a year of successful work. I suspect a system updated was the reason. I upgraded the python framework to 2.7.3 and this helped.</p>
| 0 | 2012-06-18T15:37:44Z | [
"python",
"osx",
"osx-snow-leopard",
"macports"
] |
recursive function for a django model instance | 1,797,586 | <p>i want to make message view show all other messages that led up to that message. the original message will not have a response_to value and should terminate the recursion. is there a better way to do this? (i'm looking at memory over speed, because a thread shouldn't typically be more than 10 - 20 messages long).</p... | 0 | 2009-11-25T15:13:13Z | 1,797,656 | <p>Yes. not using recursion.</p>
<pre><code>def get_thread(msg):
messages = [] # empty message set
while msg.response_to:
messages.append(msg)
msg = msg.response_to
messages.append(msg) # will append the original message
return messages
</code></pre>
| 3 | 2009-11-25T15:23:34Z | [
"python",
"django",
"recursion"
] |
recursive function for a django model instance | 1,797,586 | <p>i want to make message view show all other messages that led up to that message. the original message will not have a response_to value and should terminate the recursion. is there a better way to do this? (i'm looking at memory over speed, because a thread shouldn't typically be more than 10 - 20 messages long).</p... | 0 | 2009-11-25T15:13:13Z | 1,798,205 | <p>If you want to limit recursion depth, add a decrementing counter:</p>
<pre><code>class Message(Model):
def get_thread(self, max_length = 10):
if self.response_to:
thread = response_to.get_thread(max_length-1)
else:
thread = []
thread.append(self)
return t... | 0 | 2009-11-25T16:34:47Z | [
"python",
"django",
"recursion"
] |
Recognising tone of the audio | 1,797,631 | <p>I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.</p>
| 14 | 2009-11-25T15:19:55Z | 1,797,658 | <p>You will need to use an audio library such as the built-in <a href="http://docs.python.org/library/audioop.html" rel="nofollow"><strong>audioop</strong></a>.</p>
<p>Analyzing the specific note being played is not trivial, but can be done using those APIs.</p>
<p>Also could be of use: <a href="http://wiki.python.or... | 1 | 2009-11-25T15:24:02Z | [
"python",
"audio"
] |
Recognising tone of the audio | 1,797,631 | <p>I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.</p>
| 14 | 2009-11-25T15:19:55Z | 1,797,674 | <p>To recognize the frequency of an audio signal, you would use the FFT (<a href="http://en.wikipedia.org/wiki/Fast%5FFourier%5Ftransform">fast Fourier transform</a>) algorithm. As far as I can tell, PyGame has no means to record audio, nor does it support the FFT transform.</p>
<p>First, you need to capture the raw s... | 16 | 2009-11-25T15:27:20Z | [
"python",
"audio"
] |
Recognising tone of the audio | 1,797,631 | <p>I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.</p>
| 14 | 2009-11-25T15:19:55Z | 1,797,699 | <p>This <a href="http://www.codeproject.com/KB/audio-video/FftGuitarTuner.aspx" rel="nofollow">link</a> shows some one doing it in VB.NET but the basics of what need to be done to achieve your goal is captured in these links below. </p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/STFT" rel="nofollow">STFT</a></li>
... | 0 | 2009-11-25T15:29:12Z | [
"python",
"audio"
] |
Recognising tone of the audio | 1,797,631 | <p>I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.</p>
| 14 | 2009-11-25T15:19:55Z | 1,798,363 | <p>I once wrote a utility that does exactly that - it analyses what sounds are being played. </p>
<p>You can look at the code <a href="https://web.archive.org/web/20120112041203/http://trac.assembla.com/guitarist/browser/src/soundAnalyzer/AudioRecorder.py" rel="nofollow">here</a> (or you can download the whole project... | 18 | 2009-11-25T16:58:22Z | [
"python",
"audio"
] |
Recognising tone of the audio | 1,797,631 | <p>I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.</p>
| 14 | 2009-11-25T15:19:55Z | 2,443,998 | <p>Very similar questions:</p>
<ul>
<li><a href="http://stackoverflow.com/questions/1499932/audio-processing-tone-recognition">http://stackoverflow.com/questions/1499932/audio-processing-tone-recognition</a></li>
<li><a href="http://stackoverflow.com/questions/1354084/real-time-pitch-detection">http://stackoverflow.co... | 1 | 2010-03-14T22:16:18Z | [
"python",
"audio"
] |
Parsing a hex formated DEC 32 bit single precision floating point value in python | 1,797,806 | <p>I'm having problems parsing a hex formatted DEC 32bit single precision floating point value in python, the value I'm parsing is represented as D44393DB in hex. The original floating point value is ~108, read from a display of the sending unit.</p>
<p>The format is specified as:
1bit sign + 8bit exponent + 23bit man... | 2 | 2009-11-25T15:43:56Z | 1,798,241 | <p>Is it definitely a DEC32 value? The sign bit seems to be 1, which indicates negative by this format. However, you do get a result very close to your 108 value if you ignore this and assume that the exponent bias is 15, retaining the 0.1 factor on the mantissa:</p>
<pre><code>def decode(x):
exp = (x>>30)... | 0 | 2009-11-25T16:41:05Z | [
"python",
"floating-point"
] |
Parsing a hex formated DEC 32 bit single precision floating point value in python | 1,797,806 | <p>I'm having problems parsing a hex formatted DEC 32bit single precision floating point value in python, the value I'm parsing is represented as D44393DB in hex. The original floating point value is ~108, read from a display of the sending unit.</p>
<p>The format is specified as:
1bit sign + 8bit exponent + 23bit man... | 2 | 2009-11-25T15:43:56Z | 1,798,533 | <p>Is it possible that the bytes got shuffled somehow? The arrangements of bits that you describe (sign bit in byte 2, LSB of exponent in byte 1) is different from Appendix O that you link to. It looks like byte 1 and 2 were exchanged. </p>
<p>I'll assume that byte 3 and 4 were also exchanged, so that the real hex val... | 3 | 2009-11-25T17:22:58Z | [
"python",
"floating-point"
] |
Parsing a hex formated DEC 32 bit single precision floating point value in python | 1,797,806 | <p>I'm having problems parsing a hex formatted DEC 32bit single precision floating point value in python, the value I'm parsing is represented as D44393DB in hex. The original floating point value is ~108, read from a display of the sending unit.</p>
<p>The format is specified as:
1bit sign + 8bit exponent + 23bit man... | 2 | 2009-11-25T15:43:56Z | 1,802,498 | <p>From my copy of "Microcomputers and Memories" (DEC, 1981), you are correct about the difference between the two formats. The DEC mantissa is normalized to <code>0.5<=f<1</code> and the IEEE format mantissa is normalized to <code>1<=f<2</code>, both with the MSB implicit and not stored. Thus the mantissa ... | 1 | 2009-11-26T09:14:43Z | [
"python",
"floating-point"
] |
Parsing a hex formated DEC 32 bit single precision floating point value in python | 1,797,806 | <p>I'm having problems parsing a hex formatted DEC 32bit single precision floating point value in python, the value I'm parsing is represented as D44393DB in hex. The original floating point value is ~108, read from a display of the sending unit.</p>
<p>The format is specified as:
1bit sign + 8bit exponent + 23bit man... | 2 | 2009-11-25T15:43:56Z | 1,803,229 | <p>Found under "Related" on the RHS: <a href="http://stackoverflow.com/questions/194912/any-c-libraries-available-to-convert-between-floating-point-representations">these answers from last month</a> </p>
<p>One of the references helps understanding the "wired" (weird?) byte2 byte1 notation.</p>
| 1 | 2009-11-26T11:46:14Z | [
"python",
"floating-point"
] |
Fabric error No handlers could be found for logger "paramiko.transport" | 1,797,925 | <p>I'm not sure why I'm getting this error that's terminating my connection. I updated paramiko-1.7.6 from 1.7.5 via easy_install.</p>
<p>I'm trying to setup Fabric to upload my Django app to my server. The error seems to be happening when I attempt to make a backup of the existing app directory:</p>
<pre><code>def b... | 5 | 2009-11-25T15:59:42Z | 1,798,129 | <p>If it's not causing a problem, you can safely ignore this message. </p>
<p>In this case, the library (paramiko), expects the application to handle the logging. The application programmer however probably expected the library to not have any side effects, and handle logging properly. </p>
<p>See <a href="http://doc... | 2 | 2009-11-25T16:25:00Z | [
"python",
"fabric"
] |
Fabric error No handlers could be found for logger "paramiko.transport" | 1,797,925 | <p>I'm not sure why I'm getting this error that's terminating my connection. I updated paramiko-1.7.6 from 1.7.5 via easy_install.</p>
<p>I'm trying to setup Fabric to upload my Django app to my server. The error seems to be happening when I attempt to make a backup of the existing app directory:</p>
<pre><code>def b... | 5 | 2009-11-25T15:59:42Z | 1,822,345 | <p>It turns out that this error was a result of me not configuring <strong>env.password</strong> as a simple string. </p>
<p>Both <strong>env.user</strong> and <strong>env.password</strong> should be simple strings, not Lists.
<a href="http://docs.fabfile.org/0.9.0/usage/env.html#user">Documentation</a></p>
| 9 | 2009-11-30T20:57:55Z | [
"python",
"fabric"
] |
Artificial Inteligence library in python | 1,798,091 | <p>I was wondering if there are any python AI libraries similar to <a href="http://code.google.com/p/aima-python/">aima-python</a> <s>but for a more recent version of python...</s> and how they are in comparison to aima-python.<br>
I was particularly interested in search algorithms such as hill-climbing, simulated anne... | 19 | 2009-11-25T16:19:27Z | 1,798,169 | <p>There are a bunch of Python AI libraries, including <a href="http://pybrain.org/">PyBrain</a>, <a href="http://opencv.willowgarage.com/wiki/">OpenCV</a>, <a href="http://pyml.sourceforge.net/">PyML</a>, and <a href="http://pyevolve.sourceforge.net/">PyEvolve</a>. Here are a few useful guides, <a href="http://www.de... | 19 | 2009-11-25T16:29:05Z | [
"python",
"artificial-intelligence",
"genetic-algorithm",
"simulated-annealing",
"hill-climbing"
] |
Artificial Inteligence library in python | 1,798,091 | <p>I was wondering if there are any python AI libraries similar to <a href="http://code.google.com/p/aima-python/">aima-python</a> <s>but for a more recent version of python...</s> and how they are in comparison to aima-python.<br>
I was particularly interested in search algorithms such as hill-climbing, simulated anne... | 19 | 2009-11-25T16:19:27Z | 1,798,175 | <p>You would be hard-pressed to find better written code than the aima-python stuff, and I've done a lot of comparison with other search algorithms. Why do you want more "recent" code? I've used a couple of the AIMA classes in a Python 2.6 project, including the search algorithms you're talking about. The only times th... | 3 | 2009-11-25T16:30:21Z | [
"python",
"artificial-intelligence",
"genetic-algorithm",
"simulated-annealing",
"hill-climbing"
] |
Artificial Inteligence library in python | 1,798,091 | <p>I was wondering if there are any python AI libraries similar to <a href="http://code.google.com/p/aima-python/">aima-python</a> <s>but for a more recent version of python...</s> and how they are in comparison to aima-python.<br>
I was particularly interested in search algorithms such as hill-climbing, simulated anne... | 19 | 2009-11-25T16:19:27Z | 1,805,523 | <p><a href="http://pyevolve.sourceforge.net/">Pyevolve</a> is a Genetic Algorithms/ Genetic programming Python library.</p>
| 7 | 2009-11-26T20:29:27Z | [
"python",
"artificial-intelligence",
"genetic-algorithm",
"simulated-annealing",
"hill-climbing"
] |
Artificial Inteligence library in python | 1,798,091 | <p>I was wondering if there are any python AI libraries similar to <a href="http://code.google.com/p/aima-python/">aima-python</a> <s>but for a more recent version of python...</s> and how they are in comparison to aima-python.<br>
I was particularly interested in search algorithms such as hill-climbing, simulated anne... | 19 | 2009-11-25T16:19:27Z | 3,691,321 | <p>Although it is not strictly AI, the <a href="http://scikit-learn.sourceforge.net/">scikit-learn</a> has a lot of machine learning algorithms that can come in handy. Two important details are that it is BSD-licensed, and that it focuses on having fast and numerically-efficient algorithms.</p>
| 10 | 2010-09-11T14:23:18Z | [
"python",
"artificial-intelligence",
"genetic-algorithm",
"simulated-annealing",
"hill-climbing"
] |
Artificial Inteligence library in python | 1,798,091 | <p>I was wondering if there are any python AI libraries similar to <a href="http://code.google.com/p/aima-python/">aima-python</a> <s>but for a more recent version of python...</s> and how they are in comparison to aima-python.<br>
I was particularly interested in search algorithms such as hill-climbing, simulated anne... | 19 | 2009-11-25T16:19:27Z | 32,476,224 | <p>I just wanted to add one thing: <strong>DEAP</strong> is a package for <em>Distributed Evolutionary Algorithms</em> in Python.</p>
<p>It provides a framework for working with <em>Genetic Algorithms</em> and with additional aspects such as:</p>
<ul>
<li>Multi-objective optimization (also using the Pareto frontier)<... | 1 | 2015-09-09T09:45:56Z | [
"python",
"artificial-intelligence",
"genetic-algorithm",
"simulated-annealing",
"hill-climbing"
] |
Python CGI script IOError Broken Pipe | 1,798,311 | <p>I have an old Python based web form that I am updating to use a GPG for encyption instead of a no longer supported python package. When call the script via the command line it works just fine, but via the web brower and CGI there is a error: <strong>IOError: [Errno 32] Broken pipe</strong>. This error occurs if I us... | 2 | 2009-11-25T16:51:18Z | 1,799,554 | <p>Good question - I'm not sure that it's either a <code>python-gnupg</code> issue or even a <code>gpg</code> issue. It might be an issue with <code>subprocess</code> or <code>cgi</code> or some interaction between the two. What happens if you try this with a very minimal script which reads from stdin and writes the ou... | 0 | 2009-11-25T19:56:01Z | [
"python",
"cgi",
"gnupg"
] |
Python CGI script IOError Broken Pipe | 1,798,311 | <p>I have an old Python based web form that I am updating to use a GPG for encyption instead of a no longer supported python package. When call the script via the command line it works just fine, but via the web brower and CGI there is a error: <strong>IOError: [Errno 32] Broken pipe</strong>. This error occurs if I us... | 2 | 2009-11-25T16:51:18Z | 2,053,003 | <p>I know my answer might come too late, but I recently had the same problem and I think I could solve it.</p>
<p>GPG seems to output some stuff ("You need a passphrase" blabla) to the terminal regardless of stdout being redirected - don't ask me how :)</p>
<p>However, the Broken Pipe seems to occur because gpg can't... | 1 | 2010-01-12T22:38:59Z | [
"python",
"cgi",
"gnupg"
] |
Launching default application for given type of file, OS X | 1,798,351 | <p>I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment.</p>
<p>What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? <code>subprocess.call</code... | 2 | 2009-11-25T16:56:08Z | 1,798,364 | <p>Do you know about the <code>open</code> command in Mac OS X? I think you can solve your problem by calling it from Python.</p>
<p><code>man open</code> for details:</p>
<p>The open command opens a file (or a directory or URL), just as if you had double-clicked the
file's icon. If no application name is specified, ... | 1 | 2009-11-25T16:58:22Z | [
"python",
"subprocess"
] |
Launching default application for given type of file, OS X | 1,798,351 | <p>I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment.</p>
<p>What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? <code>subprocess.call</code... | 2 | 2009-11-25T16:56:08Z | 1,798,407 | <blockquote>
<p>What python code can launch
Safari/Firefox/whatever is system
default html viewer and open given
file?</p>
</blockquote>
<p>There is a <a href="http://docs.python.org/library/webbrowser.html" rel="nofollow">webbrowser</a> module in python, try this:</p>
<pre><code>import webbrowser
webbrowser.... | 3 | 2009-11-25T17:05:13Z | [
"python",
"subprocess"
] |
Launching default application for given type of file, OS X | 1,798,351 | <p>I'm writing a python script that generates html file. Every time I run this script I'd like at the end to open default system browser for this file. It's all in OS X environment.</p>
<p>What python code can launch Safari/Firefox/whatever is system default html viewer and open given file? <code>subprocess.call</code... | 2 | 2009-11-25T16:56:08Z | 1,799,054 | <blockquote>
<p>import ic</p>
<p>ic.launchurl('file:///somefile.html')</p>
</blockquote>
| 0 | 2009-11-25T18:36:25Z | [
"python",
"subprocess"
] |
Overcoming Python's limitations regarding instance methods | 1,798,450 | <p>It seems that Python has some limitations regarding instance methods.</p>
<ol>
<li>Instance methods can't be copied.</li>
<li>Instance methods can't be pickled.</li>
</ol>
<p>This is problematic for me, because I work on a very object-oriented <a href="http://garlicsim.org">project</a> in which I reference instanc... | 8 | 2009-11-25T17:13:40Z | 1,798,654 | <p>REST - Representation State Transfer. Just send state, not methods.</p>
<p>To transfer an object X from A to B, we do this.</p>
<ol>
<li><p>A encode the state of X in some
handy, easy-to-parse notation. JSON
is popular.</p></li>
<li><p>A sends the JSON text to B.</p></li>
<li><p>B decodes the state of X form JSO... | 2 | 2009-11-25T17:36:35Z | [
"python",
"oop",
"copy",
"instance-method"
] |
Overcoming Python's limitations regarding instance methods | 1,798,450 | <p>It seems that Python has some limitations regarding instance methods.</p>
<ol>
<li>Instance methods can't be copied.</li>
<li>Instance methods can't be pickled.</li>
</ol>
<p>This is problematic for me, because I work on a very object-oriented <a href="http://garlicsim.org">project</a> in which I reference instanc... | 8 | 2009-11-25T17:13:40Z | 1,798,677 | <p>pickle the instance and then access the method after unpickling it. Pickling a method of an instance doesn't make sense because it relies on the instance. If it doesn't, then write it as an independent function. </p>
<pre><code>import pickle
class A:
def f(self):
print 'hi'
x = A()
f = open('tmp', '... | -3 | 2009-11-25T17:40:29Z | [
"python",
"oop",
"copy",
"instance-method"
] |
Overcoming Python's limitations regarding instance methods | 1,798,450 | <p>It seems that Python has some limitations regarding instance methods.</p>
<ol>
<li>Instance methods can't be copied.</li>
<li>Instance methods can't be pickled.</li>
</ol>
<p>This is problematic for me, because I work on a very object-oriented <a href="http://garlicsim.org">project</a> in which I reference instanc... | 8 | 2009-11-25T17:13:40Z | 1,798,869 | <p>You might be able to do this using <a href="http://docs.python.org/library/copy%5Freg.html#copy%5Freg.pickle"><code>copy_reg.pickle</code></a>. In Python 2.6:</p>
<pre><code>import copy_reg
import types
def reduce_method(m):
return (getattr, (m.__self__, m.__func__.__name__))
copy_reg.pickle(types.MethodType,... | 13 | 2009-11-25T18:08:59Z | [
"python",
"oop",
"copy",
"instance-method"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,490 | <p>It doesn't work as you expect because strip is character based. You need to do this instead:</p>
<pre><code>foo = foo.replace(' ', '')[:-3].upper()
</code></pre>
| 60 | 2009-11-25T17:17:44Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,499 | <p>What's wrong with this?</p>
<pre><code>foo.replace(" ", "")[:-3].upper()
</code></pre>
| 0 | 2009-11-25T17:18:28Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,500 | <pre><code>>>> foo = 'BS1 1AB'
>>> foo.replace(" ", "").rstrip()[:-3].upper()
'BS1'
</code></pre>
| 0 | 2009-11-25T17:18:32Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,530 | <p>You might have misunderstood rstrip slightly, it strips not a string but any character in the string you specify.</p>
<p>Like this:</p>
<pre><code>>>> text = "xxxxcbaabc"
>>> text.rstrip("abc")
'xxxx'
</code></pre>
<p>So instead, just use </p>
<pre><code>text = text[:-3]
</code></pre>
<p>(afte... | 3 | 2009-11-25T17:22:41Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,537 | <p>Removing any and all whitespace:</p>
<pre><code>foo = ''.join(foo.split())
</code></pre>
<p>Removing last three characters:</p>
<pre><code>foo = foo[:-3]
</code></pre>
<p>Converting to capital letters:</p>
<pre><code>foo = foo.upper()
</code></pre>
<p>All of that code in one line:</p>
<pre><code>foo = ''.join... | 95 | 2009-11-25T17:23:17Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,571 | <p>Aren't you performing the operations in the wrong order? You requirement seems to be <code>foo[:-3].replace(" ", "").upper()</code></p>
| 0 | 2009-11-25T17:26:28Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,591 | <p>I try to avoid regular expressions, but this appears to work:</p>
<p><code>string = re.sub("\s","",(string.lower()))[:-3]</code></p>
| 1 | 2009-11-25T17:29:27Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,798,623 | <p>It some what depends on your definition of whitespace. I would generally call whitespace to be spaces, tabs, line breaks and carriage returns. If this is your definition you want to use a regex with \s to replace all whitespace charactors:</p>
<pre><code>import re
def myCleaner(foo):
print 'dirty: ', foo
f... | 0 | 2009-11-25T17:33:58Z | [
"python",
"string"
] |
Python Remove last 3 characters of a string | 1,798,465 | <p>I'm trying to remove the last 3 characters from a string in python, I don't know what these characters are so I can't use <code>rstrip</code>, I also need to remove any white space and convert to upper-case</p>
<p>an example would be:</p>
<pre><code>foo = "Bs12 3ab"
foo.replace(" ", "").rstrip(foo[-3:]).upper()
</... | 56 | 2009-11-25T17:14:52Z | 1,801,045 | <pre><code>>>> foo = "Bs12 3ab"
>>> foo[:-3]
'Bs12 '
>>> foo[:-3].strip()
'Bs12'
>>> foo[:-3].strip().replace(" ","")
'Bs12'
>>> foo[:-3].strip().replace(" ","").upper()
'BS12'
</code></pre>
| 6 | 2009-11-26T01:15:13Z | [
"python",
"string"
] |
basic python module design question | 1,798,656 | <p>I have:</p>
<pre><code>lib/
lib/__init__.py
lib/game.py
</code></pre>
<p>In <code>__init__.py</code> I'd like to define a variable that can be accessed by any class inside lib, like so:</p>
<pre><code>BASE = 'http://www.whatever.com'
</code></pre>
<p>And then inside game.py, acces it inside in the Game class:</p... | 1 | 2009-11-25T17:36:43Z | 1,798,714 | <p>See <a href="http://docs.python.org/tutorial/modules.html#intra-package-references" rel="nofollow">http://docs.python.org/tutorial/modules.html#intra-package-references</a></p>
<p>So you could have a <code>lib/settings.py</code> file which contains the line</p>
<pre><code>BASE = 'http://www.whatever.com'
</code></... | 4 | 2009-11-25T17:46:17Z | [
"python"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 1,798,807 | <p>You are reducing the length of your list <code>l</code> as you iterate over it, so as you approach the end of your indices in the range statement, some of those indices are no longer valid.</p>
<p>It <em>looks</em> like what you want to do is:</p>
<pre><code>l = [x for x in l if x != 0]
</code></pre>
<p>which wil... | 33 | 2009-11-25T17:59:39Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 1,798,825 | <p>The expression <code>len(l)</code> is evaluated only one time, at the moment the <code>range()</code> builtin is evaluated. The range object constructed at that time does not change; it can't possibly know anything about the object <code>l</code>.</p>
<p>P.S. <code>l</code> is a lousy name for a value! It looks lik... | 11 | 2009-11-25T18:01:32Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 1,798,835 | <p>You're changing the size of the list while iterating over it, which is probably not what you want and is the cause of your error. </p>
<p><strong>Edit:</strong> As others have answered and commented, list comprehensions are better as a first choice and especially so in response to this question. I offered this as ... | 4 | 2009-11-25T18:03:41Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 28,358,315 | <p>I am using python 3.3.5. The above solution of using while loop did not work for me. Even if i put <code>print (i)</code> after <code>len(l)</code> it gave me an error. I ran the same code in command line (shell)[ window that pops up when we run a function] it runs without error. What i did was calculated len(l) out... | 0 | 2015-02-06T03:57:00Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 30,860,565 | <p>The problem was that you attempted to modify the list you were referencing within the loop that used the list <code>len()</code>. When you remove the item from the list, then the new <code>len()</code> is calculated on the next loop.</p>
<p>For example, after the first run, when you removed <code>(i)</code> using <... | 0 | 2015-06-16T06:47:28Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 35,675,237 | <p>What <a href="http://stackoverflow.com/a/1798807/714907">Mark Rushakoff</a> said is true, but if you iterate in the opposite direction, it is possible to remove elements from the list in the for-loop as well. E.g.,</p>
<pre><code>x = [1,2,3,0,0,1]
for i in range(len(x)-1, -1, -1):
if x[i] == 0:
x.pop(i)... | 0 | 2016-02-27T20:45:44Z | [
"python",
"list"
] |
python : list index out of range error | 1,798,796 | <p>I have written a simple python program </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
l.pop(i)
</code></pre>
<p>This gives me error 'list index out of range' on line <code>if l[i]==0:</code></p>
<p>After debugging I could figure out that <code>i</code> is getting increment... | 18 | 2009-11-25T17:57:54Z | 37,525,261 | <p>List comprehension will lead you to a solution.</p>
<p>But the right way to copy a object in python is using <a href="https://docs.python.org/2/library/copy.html" rel="nofollow">python module copy</a> - Shallow and deep copy operations. </p>
<pre><code>l=[1,2,3,0,0,1]
for i in range(0,len(l)):
if l[i]==0:
... | 0 | 2016-05-30T12:06:17Z | [
"python",
"list"
] |
Download file using partial download (HTTP) | 1,798,879 | <p>Is there a way to download huge and still growing file over HTTP using the partial-download feature?</p>
<p>It seems that this code downloads file from scratch every time it executed:</p>
<pre><code>import urllib
urllib.urlretrieve ("http://www.example.com/huge-growing-file", "huge-growing-file")
</code></pre>
<p... | 20 | 2009-11-25T18:10:02Z | 1,798,945 | <p>It is possible to do partial download using the range header, the following will request a selected range of bytes:</p>
<pre><code>req = urllib2.Request('http://www.python.org/')
req.headers['Range'] = 'bytes=%s-%s' % (start, end)
f = urllib2.urlopen(req)
</code></pre>
<p>For example:</p>
<pre><code>>>> ... | 37 | 2009-11-25T18:18:55Z | [
"python",
"http",
"partial"
] |
Download file using partial download (HTTP) | 1,798,879 | <p>Is there a way to download huge and still growing file over HTTP using the partial-download feature?</p>
<p>It seems that this code downloads file from scratch every time it executed:</p>
<pre><code>import urllib
urllib.urlretrieve ("http://www.example.com/huge-growing-file", "huge-growing-file")
</code></pre>
<p... | 20 | 2009-11-25T18:10:02Z | 1,798,957 | <p>If I understand your question correctly, the file is not changing during download, but is updated regularly. If that is the question, <a href="http://rsync.samba.org/" rel="nofollow">rsync</a> is the answer.</p>
<p>If the file is being updated continually including during download, you'll need to modify rsync or a... | 1 | 2009-11-25T18:21:24Z | [
"python",
"http",
"partial"
] |
Download file using partial download (HTTP) | 1,798,879 | <p>Is there a way to download huge and still growing file over HTTP using the partial-download feature?</p>
<p>It seems that this code downloads file from scratch every time it executed:</p>
<pre><code>import urllib
urllib.urlretrieve ("http://www.example.com/huge-growing-file", "huge-growing-file")
</code></pre>
<p... | 20 | 2009-11-25T18:10:02Z | 1,798,984 | <p>This is quite easy to do using TCP sockets and raw HTTP. The relevant request header is "Range".</p>
<p>An example request might look like:</p>
<pre><code>mysock = connect(("www.example.com", 80))
mysock.write(
"GET /huge-growing-file HTTP/1.1\r\n"+\
"Host: www.example.com\r\n"+\
"Range: bytes=XXXX-\r\n"+\
... | 2 | 2009-11-25T18:24:41Z | [
"python",
"http",
"partial"
] |
Python: print doesn't work, script hangs endlessly | 1,799,462 | <p>Using Python 2.6, I wrote a script in Windows XP.</p>
<p>The script does the following:</p>
<p>Input: Domain name (ie: amazon.com)</p>
<p>The script queries DNS via the dnspython module and returns any A record IP Addresses.
The output is in a special format needed for a specific application which utilizes this d... | 1 | 2009-11-25T19:40:36Z | 1,799,534 | <p>Have you tried doing</p>
<pre><code>entities = StringIO()
for answer in results:
entities.write('''<Entity Type="IPAddress"><Value>{0}</Value></Entity>'''.format(answer))
entities.flush()
maltego_transform(entities.getvalue())
entities.close()
</code></pre>
| 1 | 2009-11-25T19:53:17Z | [
"python",
"printing"
] |
Python: print doesn't work, script hangs endlessly | 1,799,462 | <p>Using Python 2.6, I wrote a script in Windows XP.</p>
<p>The script does the following:</p>
<p>Input: Domain name (ie: amazon.com)</p>
<p>The script queries DNS via the dnspython module and returns any A record IP Addresses.
The output is in a special format needed for a specific application which utilizes this d... | 1 | 2009-11-25T19:40:36Z | 1,799,676 | <p>Apparently dnspython wants 16 bytes of <a href="http://archives.free.net.ph/message/20090925.192334.c8a114cd.ca.html">high-quality random numbers</a> at startup. Getting them (from /dev/random) can block.</p>
<p>If you hit Ctrl+C, it actually catches the <code>KeyboardInterupt</code> exception and falls back on les... | 5 | 2009-11-25T20:15:51Z | [
"python",
"printing"
] |
importing cx_Oracle and kinterbasdb returns error | 1,799,475 | <p>Greetings, everybody.</p>
<p>I'm trying to import the following libraries in python: cx_Oracle and kinterbasdb.</p>
<p>But, when I try, I get a very similar message error.
*for cx_Oracle:
Traceback (most recent call last):
File "", line 1, in
ImportError: DLL load failed: Não foi possÃvel encontrar o procedim... | 1 | 2009-11-25T19:43:00Z | 1,803,407 | <p>oracle is a complete pain. i don't know the details for windows, but for unix you need ORACLE_HOME and LD_LIBRARY_PATH to both be defined before cx_oracle will work. in windows this would be your environment variables, i guess. so check those.</p>
<p>also, check that they are defined in the environment in which ... | -1 | 2009-11-26T12:26:50Z | [
"python",
"cx-oracle",
"kinterbasdb"
] |
Numpy - show decimal values in array results | 1,799,527 | <p>how do I calculate that an array of python numpy or me of all the calculate decimals and not skip like.</p>
<pre><code>>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]).
>> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]).
>> A / C
array ([[0, 0, 0],
[4, 2, 2],
[1, 1, 1]])
</code></pr... | 1 | 2009-11-25T19:52:25Z | 1,799,560 | <p>To avoid integer division, use <code>numpy.true_divide(A,C)</code>. You can also put <code>from __future__ import division</code> at the top of the file to default to this behavior.</p>
| 6 | 2009-11-25T19:56:23Z | [
"python",
"numpy"
] |
Numpy - show decimal values in array results | 1,799,527 | <p>how do I calculate that an array of python numpy or me of all the calculate decimals and not skip like.</p>
<pre><code>>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]).
>> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]).
>> A / C
array ([[0, 0, 0],
[4, 2, 2],
[1, 1, 1]])
</code></pr... | 1 | 2009-11-25T19:52:25Z | 1,799,604 | <p>Try converting one of the arrays <code>A</code> or <code>C</code> into an array of floats. For instance:</p>
<pre><code>A = A * 1.0
</code></pre>
<p>Then the division will be floating point division.</p>
| 2 | 2009-11-25T20:02:33Z | [
"python",
"numpy"
] |
Numpy - show decimal values in array results | 1,799,527 | <p>how do I calculate that an array of python numpy or me of all the calculate decimals and not skip like.</p>
<pre><code>>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]]).
>> C = numpy.array ([[7,8,9], [1,2,3], [4,5,6]]).
>> A / C
array ([[0, 0, 0],
[4, 2, 2],
[1, 1, 1]])
</code></pr... | 1 | 2009-11-25T19:52:25Z | 1,852,228 | <p>Numpy arrays may have different types. You may also create a float array, it will always divide correctly:</p>
<pre><code>>>> A = numpy.array ([[1,2,3], [4,5,6], [7,8,9]], dtype=float)
>>> A/2
array([[ 0.5, 1. , 1.5],
[ 2. , 2.5, 3. ],
[ 3.5, 4. , 4.5]])
</code></pre>
<p>Notic... | 0 | 2009-12-05T13:42:19Z | [
"python",
"numpy"
] |
Django Admin "Edit Selection" Action? | 1,800,008 | <p>I'd like to write a django-admin action (for use when the user selects zero or more rows) that will allow them to edit the selected items as a group. I only need to edit one of the items in the model (the "room") at a time, but I don't want to have to go through all 480 of my objects and manually edit them one-by-on... | 2 | 2009-11-25T21:17:15Z | 1,800,752 | <p>There may be ways of doing it in the admin, but why not just create a custom view to do this?</p>
<p>When you start getting into heavy customizations of the admin, it indicates that you should start writing a custom app that you can easily modify. It is actually very easy to get most of the functionality of the ad... | -1 | 2009-11-25T23:49:48Z | [
"python",
"django",
"django-admin"
] |
Django Admin "Edit Selection" Action? | 1,800,008 | <p>I'd like to write a django-admin action (for use when the user selects zero or more rows) that will allow them to edit the selected items as a group. I only need to edit one of the items in the model (the "room") at a time, but I don't want to have to go through all 480 of my objects and manually edit them one-by-on... | 2 | 2009-11-25T21:17:15Z | 1,805,741 | <p>You are able to create custom admin actions, and using JavaScript or custom ModleForms you could easily create popup windows or alerts, or whatever you want to do. For example I have this in the admin for one of my apps:</p>
<p>admin.py:</p>
<pre><code>def deactivate_selected(modeladmin, request, queryset):
r... | 3 | 2009-11-26T21:29:55Z | [
"python",
"django",
"django-admin"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.