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 |
|---|---|---|---|---|---|---|---|---|---|
Debugging python programs in emacs | 2,324,758 | <p>How to debug python programs in emacs? </p>
<p>I use python-mode.el</p>
<p>I get reference like
import pdb; pdb.set_trace();</p>
<p>but not sure how to use it.</p>
| 40 | 2010-02-24T09:04:45Z | 19,168,037 | <p>For me, I needed to replace the default "pdb" with </p>
<pre><code>python -m pdb myscript.py
</code></pre>
| 13 | 2013-10-03T19:51:12Z | [
"python",
"debugging",
"emacs",
"pdb"
] |
Debugging python programs in emacs | 2,324,758 | <p>How to debug python programs in emacs? </p>
<p>I use python-mode.el</p>
<p>I get reference like
import pdb; pdb.set_trace();</p>
<p>but not sure how to use it.</p>
| 40 | 2010-02-24T09:04:45Z | 37,501,397 | <p>The <a href="https://github.com/realgud/realgud/" rel="nofollow"><code>realgud</code></a> package (available from MELPA) supports PDB (among a gazillion other debuggers), and has a host of neat features that Emac's PDB doesn't have.</p>
<p>The one I like best is the shortkeys mode. Once you start debugging a progra... | 3 | 2016-05-28T16:31:41Z | [
"python",
"debugging",
"emacs",
"pdb"
] |
How do I activate (execute) methods of a class in Python? | 2,324,804 | <p>I have a program (<a href="http://fragments.turtlemeat.com/pythonwebserver.php" rel="nofollow">simple web server</a>) which I try to understand. There is a class called MyHandler. In this class we define 2 methods do_GET and do_POST.</p>
<p>I do not understand several things:</p>
<ol>
<li><p>Where do we use the tw... | 2 | 2010-02-24T09:13:29Z | 2,324,902 | <p>I'm quite new to Python, but I will have a go at an answerâit might help me learn too!</p>
<ol>
<li><p>We don't ever call the <code>do_GET()</code> and <code>do_POST()</code> methods from our code, this is done automatically by the <code>HTTPServer</code> class instance when GET and POST requests are made (see po... | 4 | 2010-02-24T09:32:47Z | [
"python",
"oop",
"class",
"methods"
] |
Count warnings in Python 2.4 | 2,324,820 | <p>I've got some tests that need to count the number of warnings raised by a function. In Python 2.6 this is simple, using</p>
<pre><code>with warnings.catch_warnings(record=True) as warn:
...
self.assertEquals(len(warn), 2)
</code></pre>
<p>Unfortunately, <code>with</code> is not available in Python 2.4, so ... | 5 | 2010-02-24T09:17:01Z | 2,514,496 | <p>What you can do is duplicate the behavior of <a href="http://docs.python.org/library/warnings.html#warnings.catch_warnings" rel="nofollow"><code>warnings.catch_warnings()</code></a> yourself. Save the current value of <a href="http://docs.python.org/library/warnings.html#warnings.showwarning" rel="nofollow"><code>wa... | 3 | 2010-03-25T09:59:00Z | [
"python",
"warnings",
"python-2.4"
] |
Count warnings in Python 2.4 | 2,324,820 | <p>I've got some tests that need to count the number of warnings raised by a function. In Python 2.6 this is simple, using</p>
<pre><code>with warnings.catch_warnings(record=True) as warn:
...
self.assertEquals(len(warn), 2)
</code></pre>
<p>Unfortunately, <code>with</code> is not available in Python 2.4, so ... | 5 | 2010-02-24T09:17:01Z | 2,514,602 | <p>I was going to suggest the same workaround as Ignacio, a bit more complete example of testing code:</p>
<pre><code>import warnings
def setup_warning_catcher():
""" Wrap warnings.showwarning with code that records warnings. """
caught_warnings = []
original_showwarning = warnings.showwarning
def ... | 6 | 2010-03-25T10:15:42Z | [
"python",
"warnings",
"python-2.4"
] |
Creating Python RPM | 2,324,933 | <p>I have been reading about creating an RPM for Python 2.6.4. In this page: <a href="http://docs.python.org/distutils/builtdist.html" rel="nofollow">http://docs.python.org/distutils/builtdist.html</a> it says you can create an RPM of the current Python using <code>python setup.py bdist_rpm</code>. The question's I hav... | 3 | 2010-02-24T09:39:38Z | 2,325,047 | <ol>
<li>This command has to be typed wherever your <code>setup.py</code> is located.</li>
<li>It packages everything that would show up in a <code>bdist</code> tarball.</li>
<li>Err... sort of. While it works, the package it creates is not of very high quality. It's better to use <code>sdist_rpm</code>, then unpack th... | 6 | 2010-02-24T09:57:27Z | [
"python",
"linux",
"rpm",
"rpmbuild",
"checkinstall"
] |
Creating Python RPM | 2,324,933 | <p>I have been reading about creating an RPM for Python 2.6.4. In this page: <a href="http://docs.python.org/distutils/builtdist.html" rel="nofollow">http://docs.python.org/distutils/builtdist.html</a> it says you can create an RPM of the current Python using <code>python setup.py bdist_rpm</code>. The question's I hav... | 3 | 2010-02-24T09:39:38Z | 2,325,082 | <p>These instructions explain how to create an RPM package for your module. As far as I know, there is no (easy) way to package all your Python installation into an RPM.</p>
<p>If you want to create an RPM package to install Python 2.6.4 on an older distro, you download the Python 2.6.4 source RPM and then rebuild it ... | 0 | 2010-02-24T10:04:03Z | [
"python",
"linux",
"rpm",
"rpmbuild",
"checkinstall"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,001 | <p>Well, this is heavily language dependant, but in general the idea there is, that one big operation is faster than many small ones. In your second example, the join knows all the elements that it has to join and thus can just allocate the neccesary resources and put the characters in. The concatenation in your first ... | 0 | 2010-02-24T09:50:35Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,004 | <p>This is because a larger and larger chunk of memory has to be allocated for the string concatenation:</p>
<pre><code>x = 'a' # String of size 1 allocated
x += 'b' # String of size 2 allocated, x copied, and 'b' added. Old x discarded
x += 'b' # String of size 3 allocated, x copied, and 'c' added. Old x discarded
x ... | 3 | 2010-02-24T09:51:00Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,010 | <p>I don't know the internals of join, but in the first version you create a new string every time you call the += operator. Since strings are immutable, every time new memory is allocated and a copy is made.</p>
<p>Now, the join (which is a string method) could only do a single allocation, since it can calculate the ... | 0 | 2010-02-24T09:51:43Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,011 | <p>The reason is that strings in Python (and many other languages) are <a href="http://en.wikipedia.org/wiki/Immutable_object">immutable objects</a> - that is, once created, they can't be changed. Instead, concatenating a string actually makes a <em>new</em> string which consists of the contents of the two smaller stri... | 13 | 2010-02-24T09:51:52Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,018 | <p>The code in a join function knows upfront all the strings its being asked to concatenate and how large those strings are hence it can calculate the final string length before beginning the operation. Hence it need only allocate memory for the final string once and then it can place each source string (and delimiter... | 12 | 2010-02-24T09:52:31Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,325,026 | <p>See <a href="http://stackoverflow.com/questions/476772/python-string-join-performance">http://stackoverflow.com/questions/476772/python-string-join-performance</a> and one specific anwser that describes it very well:</p>
<blockquote>
<p>The advice is about concatenating a lot of strings.</p>
<p>To compute s ... | 3 | 2010-02-24T09:53:54Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
Why join is faster than normal concatenation | 2,324,963 | <p>I've seen several examples from different languages that unambiguously prove that joining elements of a list(array) is times faster that just concatenating string. Unfortunately I didn't find an explanation why?
Can someone explain the inner algorithm that works under both operations and why is the one faster than a... | 10 | 2010-02-24T09:44:23Z | 2,327,083 | <p>The other responses have basically covered it, but if you want even more detail, Joel Spolsky has an article where he describes "<a href="http://www.joelonsoftware.com/articles/fog0000000319.html" rel="nofollow">Schlemiel the painter's algorithm</a>", which is extremely relevant and nicely makes the case for why und... | 1 | 2010-02-24T15:23:53Z | [
"javascript",
"python",
"performance",
"join",
"string-concatenation"
] |
How to redefine a wx.GridSizer? | 2,325,007 | <p>I have this code:</p>
<pre><code>class SoundLog(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, size=(500, 350), *args, **kwargs)
self.SetBackgroundColour((110,110,110))
self.sizer = wx.BoxSizer(wx.VERTICAL)
pluginsNumber = len(plugins) - len(pluginsToHid... | 0 | 2010-02-24T09:51:34Z | 2,326,134 | <p>If you're using something like the <a href="http://www.wxpython.org/docs/api/wx.aui-module.html" rel="nofollow">AUI framework</a>, you can simply create a new grid sizer, and swap out the one you've already got.</p>
| 1 | 2010-02-24T13:03:40Z | [
"python",
"wxpython"
] |
Django admin - Restrict user view by permission | 2,325,150 | <p>I'm starting to learn Django and I have a question.</p>
<p>Is there any way to restric views in the administration interface? I see there are "change, "add" and "delete" permissions, but I wanted to restrict views also. </p>
<p>For example: Two users, "User 1" is superuser and "User 2" is in the editor group. User... | 0 | 2010-02-24T10:19:01Z | 2,325,199 | <p>If you make sure that User 2 has no permissions for any model related to the app you want to hide away (so no change, add or delete powers for any of the models in that app), then it won't appear in the admin for User 2.</p>
| 1 | 2010-02-24T10:25:32Z | [
"python",
"django",
"permissions",
"django-admin",
"admin"
] |
Working with itertools.product and lists in python 3 | 2,325,237 | <p>I'm trying to create a possible list of codons given a protein sequence.</p>
<p>Basically, the script i'm trying to create will process a given string input and outputs a possible combinations of another set of strings the input represents.</p>
<p>For example, the character 'F' represents either 'UUU' or 'UUC'; th... | 3 | 2010-02-24T10:29:59Z | 2,325,261 | <p>You can use <code>*pool</code> to "unpack" the list when calling <code>product()</code>:</p>
<pre><code>for n in itertools.product(*pool):
print(n)
</code></pre>
<p>This syntax expands the list <code>pool</code> into separate positional parameters.</p>
| 5 | 2010-02-24T10:34:10Z | [
"python",
"python-3.x",
"itertools"
] |
Working with itertools.product and lists in python 3 | 2,325,237 | <p>I'm trying to create a possible list of codons given a protein sequence.</p>
<p>Basically, the script i'm trying to create will process a given string input and outputs a possible combinations of another set of strings the input represents.</p>
<p>For example, the character 'F' represents either 'UUU' or 'UUC'; th... | 3 | 2010-02-24T10:29:59Z | 2,325,395 | <p>itertools.product(pool[0],pool[1],...pool[len(pool)-1]) is equivalent to itertools.product(*pool)</p>
<pre><code>import itertools
F = ['UUU', 'UUC']
I = ['AUU', 'AUC', 'AUA']
pool=[F,I]
for n in itertools.product(*pool):
print(''.join(n))
</code></pre>
| 1 | 2010-02-24T10:59:29Z | [
"python",
"python-3.x",
"itertools"
] |
How to handle conditional-imports-dependent exceptions? | 2,325,345 | <p>I'm wondering what is the most elegant way to handle exceptions that depend on a conditional import.
For example:</p>
<pre><code>import ldap
try:
...
l = ldap.open(...)
l.simple_bind_s(...)
...
except ldap.INVALID_CREDENTIALS, e:
pass
except ldap.SERVER_DOWN, e:
pass
</code></pre>
<p>In the... | 2 | 2010-02-24T10:49:35Z | 2,325,399 | <p>This will be easier to handle if you write a set of abstraction modules for authn (Strategy Pattern). Each module will catch its specific authn exceptions, and in place raise generic exceptions defined by the application.</p>
| 1 | 2010-02-24T10:59:53Z | [
"python"
] |
How to handle conditional-imports-dependent exceptions? | 2,325,345 | <p>I'm wondering what is the most elegant way to handle exceptions that depend on a conditional import.
For example:</p>
<pre><code>import ldap
try:
...
l = ldap.open(...)
l.simple_bind_s(...)
...
except ldap.INVALID_CREDENTIALS, e:
pass
except ldap.SERVER_DOWN, e:
pass
</code></pre>
<p>In the... | 2 | 2010-02-24T10:49:35Z | 2,325,401 | <p>Probably somewhere there should be a configuration option in your program that is used to decide which kind of authentication should be used. The imports should be done depending on this option.</p>
<p>If you put all the ldap related authentication functions into their own module, like <code>auth_ldap</code> and do... | 2 | 2010-02-24T11:00:05Z | [
"python"
] |
Python path: Reusing Python module | 2,325,418 | <p>I have written a small DB access module that is extensively reused in many programs. </p>
<p>My code is stored in a single directory tree <code>/projects</code> for backup and versioning reasons, and so the module should be placed within this directory tree, say at <code>/projects/my_py_lib/dbconn.py</code>.</p>
<... | 3 | 2010-02-24T11:03:54Z | 2,325,460 | <p>You can add a <code>PYTHONPATH</code> environment variable to your <code>.bashrc</code> file. eg.</p>
<pre><code>export PYTHONPATH=/projects/my_py_lib
</code></pre>
| 8 | 2010-02-24T11:13:21Z | [
"python",
"ubuntu",
"path"
] |
Python path: Reusing Python module | 2,325,418 | <p>I have written a small DB access module that is extensively reused in many programs. </p>
<p>My code is stored in a single directory tree <code>/projects</code> for backup and versioning reasons, and so the module should be placed within this directory tree, say at <code>/projects/my_py_lib/dbconn.py</code>.</p>
<... | 3 | 2010-02-24T11:03:54Z | 2,325,475 | <p>Another option is to create a soft link in <code>/usr/lib*/python*/site-packages/</code>:</p>
<pre><code>ln -s /projects/my_py_lib /usr/lib*/python*/site-packages/
</code></pre>
<p>That will make the project visible to all Python programs plus any changes will be visible immediately, too.</p>
<p>The main drawback... | 0 | 2010-02-24T11:16:25Z | [
"python",
"ubuntu",
"path"
] |
Python path: Reusing Python module | 2,325,418 | <p>I have written a small DB access module that is extensively reused in many programs. </p>
<p>My code is stored in a single directory tree <code>/projects</code> for backup and versioning reasons, and so the module should be placed within this directory tree, say at <code>/projects/my_py_lib/dbconn.py</code>.</p>
<... | 3 | 2010-02-24T11:03:54Z | 2,325,876 | <p>on linux, this directory will be added to your sys.path automatically for pythonN.M</p>
<pre><code>~/.local/lib/pythonN.M/site-packages/
</code></pre>
<p>So you can put your packages in there for each version of python you are using.</p>
<p>You need a copy for each version of python, otherwise the .pyc file will ... | 2 | 2010-02-24T12:25:28Z | [
"python",
"ubuntu",
"path"
] |
Problem with makefile | 2,325,646 | <p>I created a python project in IDE Anjuta, added some python files and the problem follows. </p>
<p>I need that would make the program after a few <code>.py</code> files lying in src copied to dir <code>/usr/bin</code>. Anjuta generates enormous configure- and makefiles. 'll Show you need to register and where that ... | 0 | 2010-02-24T11:46:04Z | 2,430,439 | <p>I'm also having trouble understanding your question, but it sounds like you want to run <code>make</code> and have the py files copied to a certain directory. This would look like:</p>
<pre><code>$(shell cp *.py /usr/bin)
</code></pre>
<p>Hope this helps.
<br>-tjw</p>
| 0 | 2010-03-12T04:05:26Z | [
"python",
"makefile",
"install",
"anjuta"
] |
How to fix "ImportError: No module named ..." error in Python? | 2,325,923 | <p>What is the correct way to fix this ImportError error?</p>
<p>I have the following directory structure:</p>
<pre><code>/home/bodacydo
/home/bodacydo/work
/home/bodacydo/work/project
/home/bodacydo/work/project/programs
/home/bodacydo/work/project/foo
</code></pre>
<p>And I am in the directory</p>
<pre><code>/hom... | 47 | 2010-02-24T12:31:09Z | 2,326,045 | <p>Python does not add the current directory to <code>sys.path</code>, but rather the directory that the script is in. Add <code>/home/bodacydo/work/project</code> to either <code>sys.path</code> or <code>$PYTHONPATH</code>.</p>
| 52 | 2010-02-24T12:47:46Z | [
"python"
] |
How to fix "ImportError: No module named ..." error in Python? | 2,325,923 | <p>What is the correct way to fix this ImportError error?</p>
<p>I have the following directory structure:</p>
<pre><code>/home/bodacydo
/home/bodacydo/work
/home/bodacydo/work/project
/home/bodacydo/work/project/programs
/home/bodacydo/work/project/foo
</code></pre>
<p>And I am in the directory</p>
<pre><code>/hom... | 47 | 2010-02-24T12:31:09Z | 2,326,120 | <p>Do you have a file called <code>__init__.py</code> in the foo directory? If not then python won't recognise foo as a python package.</p>
<p>See the <a href="http://docs.python.org/tutorial/modules.html#packages">section on packages</a> in the python tutorial for more information.</p>
| 18 | 2010-02-24T13:00:37Z | [
"python"
] |
How to fix "ImportError: No module named ..." error in Python? | 2,325,923 | <p>What is the correct way to fix this ImportError error?</p>
<p>I have the following directory structure:</p>
<pre><code>/home/bodacydo
/home/bodacydo/work
/home/bodacydo/work/project
/home/bodacydo/work/project/programs
/home/bodacydo/work/project/foo
</code></pre>
<p>And I am in the directory</p>
<pre><code>/hom... | 47 | 2010-02-24T12:31:09Z | 2,328,379 | <p>In my mind I have to consider that the <code>foo</code> folder is a stand-alone library. I might want to consider moving it to the <code>Lib\site-packages</code> folder within a python installation. I might want to consider adding a <code>foo.pth</code> file there.</p>
<p>I know it's a library since the <code>./p... | 2 | 2010-02-24T18:14:56Z | [
"python"
] |
How to fix "ImportError: No module named ..." error in Python? | 2,325,923 | <p>What is the correct way to fix this ImportError error?</p>
<p>I have the following directory structure:</p>
<pre><code>/home/bodacydo
/home/bodacydo/work
/home/bodacydo/work/project
/home/bodacydo/work/project/programs
/home/bodacydo/work/project/foo
</code></pre>
<p>And I am in the directory</p>
<pre><code>/hom... | 47 | 2010-02-24T12:31:09Z | 7,886,092 | <p>Here is a step-by-step solution:</p>
<ol>
<li><p>Add a script called <code>run.py</code> in <code>/home/bodacydo/work/project</code> and edit it like this:</p>
<blockquote>
<pre><code>import programs.my_python_program
programs.my_python_program.main()
</code></pre>
</blockquote>
<p>(replace <code>main()</code> wi... | 4 | 2011-10-25T07:38:45Z | [
"python"
] |
How to fix "ImportError: No module named ..." error in Python? | 2,325,923 | <p>What is the correct way to fix this ImportError error?</p>
<p>I have the following directory structure:</p>
<pre><code>/home/bodacydo
/home/bodacydo/work
/home/bodacydo/work/project
/home/bodacydo/work/project/programs
/home/bodacydo/work/project/foo
</code></pre>
<p>And I am in the directory</p>
<pre><code>/hom... | 47 | 2010-02-24T12:31:09Z | 25,078,045 | <p>Example solution for adding the library to your PYTHONPATH.</p>
<ol>
<li><p>Add the following line into your ~/.bashrc or just run it directly:</p>
<pre><code>export PYTHONPATH="$PYTHONPATH:$HOME/.python"
</code></pre></li>
<li><p>Then link your required library into your ~/.python folder, e.g.</p>
<pre><code>ln ... | 2 | 2014-08-01T10:20:46Z | [
"python"
] |
Is there an active Python-Chat? | 2,325,938 | <p>Is there an active Python-Chat? </p>
| 1 | 2010-02-24T12:32:39Z | 2,325,957 | <p><a href="http://www.onderstekop.nl/coding/p7_Python_Game_and_Chat_Server/" rel="nofollow">Python Chat Server</a></p>
<p><a href="http://www.onderstekop.nl/coding/p8_Python_Game_and_Chat_Client/" rel="nofollow">Python Chat Client</a></p>
| 0 | 2010-02-24T12:35:29Z | [
"python",
"chat",
"irc"
] |
Is there an active Python-Chat? | 2,325,938 | <p>Is there an active Python-Chat? </p>
| 1 | 2010-02-24T12:32:39Z | 2,325,963 | <p>If you are asking for an irc channel where people talk about Python, then try <a href="http://www.python.org/community/irc/" rel="nofollow">http://www.python.org/community/irc/</a></p>
| 3 | 2010-02-24T12:36:43Z | [
"python",
"chat",
"irc"
] |
Is there an active Python-Chat? | 2,325,938 | <p>Is there an active Python-Chat? </p>
| 1 | 2010-02-24T12:32:39Z | 2,325,967 | <p>My guess is that you are looking for a IRC channel? well this is not related to programming so you should not be posting that question here?
any way quakenet has a python channel</p>
| 0 | 2010-02-24T12:37:10Z | [
"python",
"chat",
"irc"
] |
Creating a forward compatible OpenGL 3.x context in Python | 2,325,996 | <p>I am using wxPython and I want to use an OpenGL based canvas, but I don't want the context to support deprecated functionality. I've navigated through pyopengl and pyglet in Eclipse, but it did not look like they support this. I'm saying this because I could not find WGL functions used in assigning attributes to a c... | 1 | 2010-02-24T12:41:02Z | 2,326,524 | <p>I can't categorically say that there's no way of doing this but I can point out that given the largely negative response to recent revisions of OpenGL that I doubt there will be a rush for developers to incorporate this sort of thing into their libraries. </p>
<p>For example, pyglet's core rendering functionality m... | 1 | 2010-02-24T14:07:31Z | [
"python",
"opengl",
"openglcontext"
] |
Adding a constant tuple value to a list of tuples | 2,326,359 | <p>I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list.</p>
<p>For example
[(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] </p>
<p>xk,yk are constants</p>
<p>How do I do this</p>
<p>Thanks</p>
| 1 | 2010-02-24T13:42:34Z | 2,326,416 | <p>an example to add things to tuple</p>
<pre><code>>>> a=(1,2)
>>> a+=(1,)
>>> a
(1, 2, 1)
</code></pre>
<p>you can adapt it to your requirement</p>
| 0 | 2010-02-24T13:52:19Z | [
"python"
] |
Adding a constant tuple value to a list of tuples | 2,326,359 | <p>I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list.</p>
<p>For example
[(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] </p>
<p>xk,yk are constants</p>
<p>How do I do this</p>
<p>Thanks</p>
| 1 | 2010-02-24T13:42:34Z | 2,326,495 | <p>Use <a href="http://numpy.scipy.org/" rel="nofollow">numpy</a>, e.g.,</p>
<pre><code>>>> import numpy as np
>>> a = np.array([[1,2],[2,3]])
>>> print a
[[1 2]
[2 3]]
>>> print a + 2
[[3 4]
[4 5]]
</code></pre>
| 4 | 2010-02-24T14:03:04Z | [
"python"
] |
Adding a constant tuple value to a list of tuples | 2,326,359 | <p>I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list.</p>
<p>For example
[(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] </p>
<p>xk,yk are constants</p>
<p>How do I do this</p>
<p>Thanks</p>
| 1 | 2010-02-24T13:42:34Z | 2,326,513 | <pre><code>>>>> l = [(1,2), (3,4)]
>>>> for i, e in enumerate(l):
.... l[i] = (e[0]+xk, e[1]+yk)
</code></pre>
<p>As always, untested. ;-)</p>
<p>If you don't need to do it in place, it's even simpler</p>
<pre><code>>>>> l = [(e[0]+xk, e[1]+yk) for e in l]
</code></pre>
| 3 | 2010-02-24T14:05:36Z | [
"python"
] |
Adding a constant tuple value to a list of tuples | 2,326,359 | <p>I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list.</p>
<p>For example
[(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] </p>
<p>xk,yk are constants</p>
<p>How do I do this</p>
<p>Thanks</p>
| 1 | 2010-02-24T13:42:34Z | 2,326,647 | <p>You can't add a constant to a tuple because tuples are immutable. </p>
<p>You can however create a new tuple from the old one by incrementing it's values. See jae's answer for the basics of how to do this. </p>
<p>You should note however that you will be creating a lot of new tuples in this loop and this may not b... | 3 | 2010-02-24T14:26:04Z | [
"python"
] |
Adding a constant tuple value to a list of tuples | 2,326,359 | <p>I have a list of tuples (each tuple item is a pair of integers) and I would like to add a constant value to each tuple in the list.</p>
<p>For example
[(x0,y0),(x1,y1),...] -> [(x0+xk,y0+yk),(x1+xk,y1+yk)....] </p>
<p>xk,yk are constants</p>
<p>How do I do this</p>
<p>Thanks</p>
| 1 | 2010-02-24T13:42:34Z | 2,326,714 | <p>Solution:</p>
<pre><code>l = [(i[0]+k[0], i[1]+k[1]) for i in l]
</code></pre>
<p>Test code:</p>
<pre><code>l = [(1,2), (3,4)]
k = (10, 100)
l = [(i[0]+k[0], i[1]+k[1]) for i in l]
assert l == [(11, 102), (13, 104)]
</code></pre>
| 0 | 2010-02-24T14:34:41Z | [
"python"
] |
Feedparser-basics how to | 2,326,404 | <p>I'm very new to Feedparser and have returned to Python after a long break so would appreciate any help. I've tried the docs, which are very good, but I'm still slightly lagging.</p>
<p>How would I get Feedparser to take an rss feed and from that get the title and description of the first 10 items and label each it... | 4 | 2010-02-24T13:49:56Z | 5,098,674 | <pre><code>import feedparser
f = feedparser.parse('http://domain/feed')
# f contains a dictionary key 'entries'
# entries is a list of dictionaries with 'title' and 'content' keys
for e in f['entries']:
print e.get('title', '')
print e.get('summary', '')
</code></pre>
<p>Hope that helps.</p>
| 6 | 2011-02-23T23:32:35Z | [
"python",
"rss",
"feedparser"
] |
Why can't I break into a running test with the pdb interactive debugger? | 2,326,472 | <p>How can I break into a running test with the pdb interactive debugger?</p>
<p>This is the test:</p>
<pre><code>class UserTestCase(TestCase):
def test_register_should_create_UserProfile(self):
c = Client()
response = c.post('/account/register/', {u'username': [u'john'], u'email': [u'john@beatles.com'], u'... | 0 | 2010-02-24T14:00:20Z | 2,326,546 | <p>Have you tried ipdb instead of vanilla pdb? I use ipdb and what you're trying to do works fine.</p>
<p>Alternatively, as a fallback, why not try the pdb call inside the method you're testing, just before the response is returned? </p>
| 1 | 2010-02-24T14:09:40Z | [
"python",
"django",
"testing",
"pdb"
] |
xml parsing and reading the values in python | 2,326,601 | <p>I want to know how to read and store the xml data in an array.I m not sure which method to use or class</p>
<p>Can anyone tell which xml lib to use for reading the xml</p>
| -2 | 2010-02-24T14:19:22Z | 2,326,639 | <p>That's quite a wide topic, and the best library depends on quite a few things, so it's not easy to answer this very meaningfully with so little details.</p>
<p>I'd suggest you look into <a href="http://docs.python.org/library/xml.dom.minidom.html" rel="nofollow">xml.dom.minidom</a> and see if it suits your needs.</... | 0 | 2010-02-24T14:25:34Z | [
"python",
"xml"
] |
xml parsing and reading the values in python | 2,326,601 | <p>I want to know how to read and store the xml data in an array.I m not sure which method to use or class</p>
<p>Can anyone tell which xml lib to use for reading the xml</p>
| -2 | 2010-02-24T14:19:22Z | 2,326,656 | <p><a href="http://www.crummy.com/software/BeautifulSoup" rel="nofollow">BeautifulSoup</a> or <a href="http://docs.python.org/library/xml.dom.html" rel="nofollow">xml</a></p>
| 0 | 2010-02-24T14:27:20Z | [
"python",
"xml"
] |
xml parsing and reading the values in python | 2,326,601 | <p>I want to know how to read and store the xml data in an array.I m not sure which method to use or class</p>
<p>Can anyone tell which xml lib to use for reading the xml</p>
| -2 | 2010-02-24T14:19:22Z | 2,327,308 | <p>If you're using Python 2.5+, <a href="http://docs.python.org/library/xml.etree.elementtree.html" rel="nofollow">xml.etree.ElementTree</a> is probably the easiest API to use in the stdlib.</p>
| 0 | 2010-02-24T15:49:09Z | [
"python",
"xml"
] |
xml parsing and reading the values in python | 2,326,601 | <p>I want to know how to read and store the xml data in an array.I m not sure which method to use or class</p>
<p>Can anyone tell which xml lib to use for reading the xml</p>
| -2 | 2010-02-24T14:19:22Z | 3,291,214 | <p>According to <a href="http://pound-python.org/" rel="nofollow">#python</a> channel on FreeNode:</p>
<blockquote>
<p>When parsing XML or HTML, use the <a href="http://codespeak.net/lxml" rel="nofollow">lxml</a> library</p>
</blockquote>
| 0 | 2010-07-20T14:49:31Z | [
"python",
"xml"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 2,326,888 | <p><strong>EDIT</strong> That was several years ago. Since then the portal got closed and maybe reopened. I have no idea what is it's state. But it was using at some point Django (source: I applied there at one point).</p>
<p><a href="http://grono.net/" rel="nofollow">http://grono.net/</a> is a polish equivalent of Fa... | 6 | 2010-02-24T14:54:28Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 2,326,975 | <p>Is this what you're looking for?</p>
<p><a href="http://code.djangoproject.com/wiki/DjangoSuccessStories">http://code.djangoproject.com/wiki/DjangoSuccessStories</a></p>
<p>Or are you looking for this list? <a href="http://www.djangosites.org/">http://www.djangosites.org/</a> </p>
<p>Here are Django powered sites... | 14 | 2010-02-24T15:07:07Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 2,327,142 | <p>Yes, Django is used in the "enterprise world". The good description of pros, cons and the related development efforts can be found here:</p>
<p><a href="http://groups.google.com/group/django-developers/browse_thread/thread/c89e028a536514d3" rel="nofollow">http://groups.google.com/group/django-developers/browse_thre... | 3 | 2010-02-24T15:31:10Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 2,327,568 | <p>For the systems you want to replace, you may find that it is desirable to use something more powerful than Django's ORM like SQLAlchemy. It's not a question of scaling, but the fact is that Django's ORM makes it hard to build complex queries and often pushes you to do in Python what should be done by your RDBMS â ... | 7 | 2010-02-24T16:21:31Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 4,030,459 | <p>My company uses Python/Django as a base for our Intramas Platform. An entreprise grade web application platform that is deployed to about a dozen large clients. </p>
<p>Built in features include central contact management, document generator, extra security layers, default GUI for rapid application design (no messi... | 3 | 2010-10-27T06:17:15Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 6,459,735 | <p>One of the biggest drawbacks in django is that although in theory the concept of applications being self-contained sounds nice, in practice it really doesn't work that well; even if you find some app that provides functionality that you need - it is not always easy to plug it in and go - you will always need to edit... | 13 | 2011-06-23T19:44:44Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
Anyone using Django in the "Enterprise" | 2,326,671 | <p>I know that the word âenterpriseâ gives some people the creeps, but I am curious to know if anyone has experience creating enterprise applications, similar to something like say⦠Java EE applications, which are highly concurrent, distributed applications with Django? I know Java has its own issues but its kind... | 26 | 2010-02-24T14:29:14Z | 9,905,892 | <p>My Company uses Django for at least six large scale enterprises such as mercedes, adidas. we often use the Jython wrapper. The advantages are</p>
<ul>
<li>reduced development cost compared to Java/C#</li>
<li>runs stable via wrappers in IIS or Tomcat/Java environments</li>
<li>protects our software from copycats</l... | 7 | 2012-03-28T10:46:27Z | [
"java",
"python",
"ruby-on-rails",
"django",
"enterprise"
] |
How to print contents of a Python Tkinter.Canvas control? | 2,326,753 | <p>How would I print contents of a Python Tkinter.Canvas control?</p>
<p>I've read that it's possible to print to a postscript printer from this control but examples are hard to come by.</p>
<p>So, any ideas what is needed to print the contents (including images)? </p>
<p>If you've got a cross-platform method all th... | 1 | 2010-02-24T14:40:44Z | 2,326,802 | <p>AFAIK it can only be done using the <code>postscript</code> method from the Canvas. This generates a postscript file with the canvas contents.</p>
<p>Check the documentation for details about this method.</p>
| 0 | 2010-02-24T14:46:07Z | [
"python",
"printing",
"canvas",
"tkinter"
] |
String templates in Python: what are legal characters? | 2,326,757 | <p>I can't quite figure out what's going on with <a href="http://docs.python.org/library/string.html#string.Template" rel="nofollow">string templates</a>:</p>
<pre><code>t = Template('cannot teach an ${dog.old} ${tricks.new}. ${why} is this ${not} working')
print t.safe_substitute({'dog.old': 'old dog', 'tricks.new': ... | 4 | 2010-02-24T14:41:22Z | 2,326,821 | <p><s>Python interprets the <code>.</code> in your name as "access the field <code>old</code> of the instance <code>dog</code>". Try <code>_</code> instead or make <code>dog</code> an object with a field <code>old</code>.</p>
<p>AFAIR, only valid identifiers and <code>.</code> are safe between the braces.</s></p>
<p>... | 1 | 2010-02-24T14:48:42Z | [
"python",
"string",
"templates"
] |
String templates in Python: what are legal characters? | 2,326,757 | <p>I can't quite figure out what's going on with <a href="http://docs.python.org/library/string.html#string.Template" rel="nofollow">string templates</a>:</p>
<pre><code>t = Template('cannot teach an ${dog.old} ${tricks.new}. ${why} is this ${not} working')
print t.safe_substitute({'dog.old': 'old dog', 'tricks.new': ... | 4 | 2010-02-24T14:41:22Z | 2,326,895 | <p>From the documentation...</p>
<blockquote>
<p>$identifier names a substitution placeholder matching a mapping key of "identifier". By default, "identifier" must spell a Python identifier. <strong>The first non-identifier character after the $ character terminates this placeholder specification.</strong></p>
</b... | 4 | 2010-02-24T14:55:26Z | [
"python",
"string",
"templates"
] |
String templates in Python: what are legal characters? | 2,326,757 | <p>I can't quite figure out what's going on with <a href="http://docs.python.org/library/string.html#string.Template" rel="nofollow">string templates</a>:</p>
<pre><code>t = Template('cannot teach an ${dog.old} ${tricks.new}. ${why} is this ${not} working')
print t.safe_substitute({'dog.old': 'old dog', 'tricks.new': ... | 4 | 2010-02-24T14:41:22Z | 2,326,963 | <p>Aha, I tried this experiment:</p>
<pre><code>from string import Template
import uuid
class MyTemplate(Template):
idpattern = r'[a-z][_a-z0-9]*(\.[a-z][_a-z0-9]*)*'
t1 = Template('cannot teach an ${dog.old} ${tricks.new}. ${why} is this ${not} working')
t2 = MyTemplate('cannot teach an ${dog.old} ${tricks.new}... | 2 | 2010-02-24T15:05:28Z | [
"python",
"string",
"templates"
] |
MATLAB to Python Code conversion (NumPy, SciPy, MatplotLib?) | 2,326,786 | <p>I'm trying to convert the following code to Python from MATLAB for an EEG Project (partly because Python's slightly cheaper!)</p>
<p>Hopefully someone can point me in the right direction: I've started to alter it but got bogged down: Particularly trying to find equivalent functions. </p>
<p>Tried scipy.org (NumPy_... | 3 | 2010-02-24T14:44:14Z | 2,326,918 | <p>Um... lots of things.</p>
<p>Python has no <code>end</code> keyword, so you clearly need to read more about Python's syntax.</p>
<p>Python arrays and slices are indexed with <code>[]</code> not <code>()</code>. Ranges are expressed as range(0,10) for example, but slices in the Matlab sense only exist in extension... | 11 | 2010-02-24T14:58:01Z | [
"python",
"matlab",
"numpy",
"matplotlib",
"scipy"
] |
MATLAB to Python Code conversion (NumPy, SciPy, MatplotLib?) | 2,326,786 | <p>I'm trying to convert the following code to Python from MATLAB for an EEG Project (partly because Python's slightly cheaper!)</p>
<p>Hopefully someone can point me in the right direction: I've started to alter it but got bogged down: Particularly trying to find equivalent functions. </p>
<p>Tried scipy.org (NumPy_... | 3 | 2010-02-24T14:44:14Z | 2,328,782 | <p>This may or may not work, but you might want to try a Matlab to Python converter such as <a href="http://sourceforge.net/projects/mat2py/" rel="nofollow">mat2py</a>. I've never tried them, but it might save some time. Also, there's <a href="http://www.scipy.org/NumPy_for_Matlab_Users" rel="nofollow">this page</a> ab... | 2 | 2010-02-24T19:19:34Z | [
"python",
"matlab",
"numpy",
"matplotlib",
"scipy"
] |
MATLAB to Python Code conversion (NumPy, SciPy, MatplotLib?) | 2,326,786 | <p>I'm trying to convert the following code to Python from MATLAB for an EEG Project (partly because Python's slightly cheaper!)</p>
<p>Hopefully someone can point me in the right direction: I've started to alter it but got bogged down: Particularly trying to find equivalent functions. </p>
<p>Tried scipy.org (NumPy_... | 3 | 2010-02-24T14:44:14Z | 2,329,008 | <p>One small point - indexing between the two is different. If you just copy everything from MATLAB to Python, as you seem to have done, you'll be very very confused. MATLAB x(1:5:end) translates to Python x[0::5]. Go back to <a href="http://www.scipy.org/NumPy_for_Matlab_Users">NumPy for MATLAB Users</a> and scan d... | 5 | 2010-02-24T19:53:33Z | [
"python",
"matlab",
"numpy",
"matplotlib",
"scipy"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 2,366,774 | <p>Was stuck on this myself, but finally figured it out. You simply <em>can't</em> set the env.hosts configuration from <em>within</em> a task. Each task is executed N times, once for each Host specified, so the setting is fundamentally outside of task scope.</p>
<p>Looking at your code above, you could simply do th... | 21 | 2010-03-02T21:07:15Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 2,415,868 | <p>You need to set <code>host_string</code> an example would be:</p>
<pre><code>from fabric.context_managers import settings as _settings
def _get_hardware_node(virtualized):
return "localhost"
def mystuff(virtualized):
real_host = _get_hardware_node(virtualized)
with _settings(
host_string=real_... | 9 | 2010-03-10T09:52:17Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 2,814,985 | <p>You can assign to <code>env.hoststring</code> before executing a subtask. Assign to this global variable in a loop if you want to iterate over multiple hosts.</p>
<p>Unfortunately for you and me, fabric is not designed for this use case. Check out the <code>main</code> function at <a href="http://github.com/bitprop... | 2 | 2010-05-11T22:51:23Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 3,449,986 | <p>You need to modify env.hosts at the module level, not within a task function. I made the same mistake.</p>
<pre><code>from fabric.api import *
def _get_hosts():
hosts = []
... populate 'hosts' list ...
return hosts
env.hosts = _get_hosts()
def your_task():
... your task ...
</code></pre>
| 2 | 2010-08-10T14:24:12Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 4,687,027 | <p>I do this by declaring an actual function for each environment. For example:</p>
<pre><code>def test():
env.user = 'testuser'
env.hosts = ['test.server.com']
def prod():
env.user = 'produser'
env.hosts = ['prod.server.com']
def deploy():
...
</code></pre>
<p>Using the above functions, I would... | 119 | 2011-01-14T00:53:14Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 5,465,497 | <p>To explain why it's even an issue. The command <em>fab</em> is leveraging fabric the library to run the tasks on the host lists. If you try and change the host list inside a task, you're esentially attempting to change a list while iterating over it. Or in the case where you have no hosts defined, loop over an empty... | 8 | 2011-03-28T21:50:36Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 6,313,237 | <p>Use <a href="http://docs.fabfile.org/en/latest/usage/execution.html#roles">roledefs</a></p>
<pre><code>from fabric.api import env, run
env.roledefs = {
'test': ['localhost'],
'dev': ['user@dev.example.com'],
'staging': ['user@staging.example.com'],
'production': ['user@production.example.com']
}
... | 66 | 2011-06-11T00:22:43Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 6,383,234 | <p>Here's a simpler version of <a href="http://stackoverflow.com/a/2415868/116973">serverhorrors answer</a>:</p>
<pre><code>from fabric.api import settings
def mystuff():
with settings(host_string='12.34.56.78'):
run("hostname -f")
</code></pre>
| 42 | 2011-06-17T08:31:04Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 8,288,946 | <p>It's very simple. Just initialize the env.host_string variable and all of the following commands will be executed on this host.</p>
<pre><code>from fabric.api import env, run
env.host_string = 'user@exmaple.com'
def foo:
run("hostname -f")
</code></pre>
| 2 | 2011-11-27T20:53:33Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 9,081,696 | <p>Using roles is currently considered to be the "proper" and "correct" way of doing this and is what you "should" do it.</p>
<p>That said, if you are like most of what you "would like" or "desire" is the ability to perform a "twisted syster" or switching target systems on the fly.</p>
<p>So for entertainment purpose... | 0 | 2012-01-31T14:57:54Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 16,889,529 | <p>Contrary to some other answers, it <em>is</em> possible to modify the <code>env</code> environment variables within a task. However, this <code>env</code> will only be used for subsequent tasks executed using the <code>fabric.tasks.execute</code> function.</p>
<pre><code>from fabric.api import task, roles, run, env... | 9 | 2013-06-03T03:06:31Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 18,367,572 | <p>Since fab 1.5 this is a documented way to dynamically set hosts.</p>
<p><a href="http://docs.fabfile.org/en/1.7/usage/execution.html#dynamic-hosts">http://docs.fabfile.org/en/1.7/usage/execution.html#dynamic-hosts</a></p>
<p>Quote from the doc below.</p>
<blockquote>
<p>Using execute with dynamically-set host l... | 13 | 2013-08-21T20:58:10Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 21,458,231 | <p>I'm totally new to fabric, but to get fabric to run the same commands on multiple hosts (e.g. to deploy to multiple servers, in one command) you can run:</p>
<pre><code>fab -H staging-server,production-server deploy
</code></pre>
<p>where <strong>staging-server</strong> and <strong>production-server</strong> are ... | 2 | 2014-01-30T13:45:05Z | [
"python",
"host",
"fabric"
] |
How to set target hosts in Fabric file | 2,326,797 | <p>I want to use Fabric to deploy my web app code to development, staging and production servers. My fabfile:</p>
<pre><code>def deploy_2_dev():
deploy('dev')
def deploy_2_staging():
deploy('staging')
def deploy_2_prod():
deploy('prod')
def deploy(server):
print 'env.hosts:', env.hosts
env.hosts = [server... | 101 | 2010-02-24T14:45:11Z | 22,873,769 | <p>So, in order to set the hosts, and have the commands run across all the hosts, you have to start with:</p>
<pre><code>def PROD():
env.hosts = ['10.0.0.1', '10.0.0.2']
def deploy(version='0.0'):
sudo('deploy %s' % version)
</code></pre>
<p>Once those are defined, then run the command on the command line:</... | 1 | 2014-04-04T22:00:05Z | [
"python",
"host",
"fabric"
] |
How to run a clone of reddit.com website. Reddit.com source code gives error while implementing on Ubuntu 9.10 (karmic) | 2,326,905 | <p>I am implementing the reddit.com source code on ubuntu karmic 9.10.</p>
<p>I have followed all the steps and in one step where i am using paster command it throws an error.
$paster shell example.ini</p>
<p>File "/usr/local/lib/python2.6/dist-packages/Pylons-0.9.6.2-
py2.6.egg/pylons/middleware.py", line 11, in
... | 0 | 2010-02-24T14:56:43Z | 2,328,071 | <p>You need to ensure that all the libraries needed by your Reddit clone are on <a href="http://docs.python.org/tutorial/modules.html#the-module-search-path" rel="nofollow">Python's module search path</a>. There are a lot of different ways to accomplish this. The easiest is probably to just use <a href="http://pypi.p... | 1 | 2010-02-24T17:32:44Z | [
"python",
"pylons",
"paster",
"reddit"
] |
Class level return/exit in Python | 2,327,077 | <p>In my application I have a loop that in each turn creates an instance of a class which performs some operations. In this class I have a signal timer that when invoked is supposed to exit the current turn in the loop gracefully and allow the next operation to continue without any interruption.</p>
<p>In it's current... | 0 | 2010-02-24T15:21:51Z | 2,327,163 | <p>If you're talking about signals as in the <a href="http://docs.python.org/library/signal.html" rel="nofollow">signal module</a>, then the handlers aren't called in a standard fashion.</p>
<p>You can't throw an exception out of them and expect it to appear in your normal code. Indeed you should try to do as little a... | 1 | 2010-02-24T15:33:05Z | [
"python"
] |
Class level return/exit in Python | 2,327,077 | <p>In my application I have a loop that in each turn creates an instance of a class which performs some operations. In this class I have a signal timer that when invoked is supposed to exit the current turn in the loop gracefully and allow the next operation to continue without any interruption.</p>
<p>In it's current... | 0 | 2010-02-24T15:21:51Z | 2,327,164 | <p>Christopher,</p>
<p>maybe using <a href="http://docs.python.org/library/threading.html#timer-objects" rel="nofollow">Timer</a> and <a href="http://docs.python.org/library/threading.html#event-objects" rel="nofollow">Event</a> classes is more appropriate for you. You could check for the event to be set inside you lo... | 1 | 2010-02-24T15:33:12Z | [
"python"
] |
Python and windows filesystem with none-ascii characters | 2,327,226 | <p>I want to write a folder on a windows system, Vista and Win7 with NTFS file systems.
The folders may contain the characters å, ä and/or ö, "förjävligt" for example.</p>
<p>The python files and every string in it is currently in UTF-8, how do I convert it to suite the Windows file system?</p>
| 0 | 2010-02-24T15:39:42Z | 2,327,298 | <p>If you're working with normal Python 2 strings, you can simply convert them to Unicode</p>
<pre><code># -*- coding: utf-8 -*-
normalString = "äöü"
# Now convert to unicode. Specified encoding must match the file encoding
# in this example. In general, you must specify how the bytes-only string
# contained in "n... | 3 | 2010-02-24T15:48:22Z | [
"python",
"windows",
"ntfs"
] |
Python and windows filesystem with none-ascii characters | 2,327,226 | <p>I want to write a folder on a windows system, Vista and Win7 with NTFS file systems.
The folders may contain the characters å, ä and/or ö, "förjävligt" for example.</p>
<p>The python files and every string in it is currently in UTF-8, how do I convert it to suite the Windows file system?</p>
| 0 | 2010-02-24T15:39:42Z | 2,328,131 | <p>If you want to make the strings really nice for working with in windows you can use this <a href="https://svn.origo.ethz.ch/bobcat/src-doc/safefilename-module.html" rel="nofollow">safeFilenameCodec</a>. It is a subset of allowable characters, but you won't have to worry about any craziness getting by. And it has ge... | 1 | 2010-02-24T17:39:50Z | [
"python",
"windows",
"ntfs"
] |
Where should sys.path.append('...') statement go? | 2,327,322 | <p>Just after standard pythonmodule imports?
If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.</p>
| 2 | 2010-02-24T15:51:42Z | 2,327,360 | <p>I generally do it before importing anything. If you're worried that your module names might conflict with the Python stdlib names, then change your module names!</p>
| 0 | 2010-02-24T15:54:54Z | [
"python",
"coding-style"
] |
Where should sys.path.append('...') statement go? | 2,327,322 | <p>Just after standard pythonmodule imports?
If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.</p>
| 2 | 2010-02-24T15:51:42Z | 2,327,364 | <p>I often use a shell script to launch my python applications: I put my <code>sys.path.insert</code> (<code>append</code>) statement just after the "standard" python module imports in my "launch python script".</p>
<p>Using <code>sys.path.insert(0, ...)</code> gets your "imports" in priority in the path list.</p>
| 1 | 2010-02-24T15:55:10Z | [
"python",
"coding-style"
] |
Where should sys.path.append('...') statement go? | 2,327,322 | <p>Just after standard pythonmodule imports?
If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.</p>
| 2 | 2010-02-24T15:51:42Z | 2,327,376 | <p>It should go before the <code>import</code> or <code>from</code> statements that need it (which as you say is obvious). So for example a module could start with:</p>
<pre><code>import sys
import os
import math
try:
import foo
except ImportError:
if 'foopath' in sys.path: raise
sys.path.append('foopath')
im... | 8 | 2010-02-24T15:56:31Z | [
"python",
"coding-style"
] |
Where should sys.path.append('...') statement go? | 2,327,322 | <p>Just after standard pythonmodule imports?
If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.</p>
| 2 | 2010-02-24T15:51:42Z | 2,327,394 | <p>I think it's a matter of taste. But most people tend to put it behind the <code>import sys</code> :-)
I prefer wrapping it in an extra function:</p>
<pre><code>def importmod_abs(name):
sys.path.append() ..
__import__ ...
sys.path.pop()
</code></pre>
<p>... this way <code>sys.path</code> remains clean. O... | 0 | 2010-02-24T15:57:50Z | [
"python",
"coding-style"
] |
Where should sys.path.append('...') statement go? | 2,327,322 | <p>Just after standard pythonmodule imports?
If I postpone it to the main function and do my specific module imports before it, it gives error (which is quite obvious). Python Style guide no where mentions the correct location for it.</p>
| 2 | 2010-02-24T15:51:42Z | 2,327,804 | <p>One reason this isn't mentioned in PEP 8 or other good Python style guides is that modifying <code>sys.path</code> <em>isn't something you want to do in a real program</em>; it makes your program less robust and portable. A better solution might be to put your package somewhere that would already be in <code>sys.pat... | 3 | 2010-02-24T16:56:27Z | [
"python",
"coding-style"
] |
ctypes loading a c shared library that has dependencies | 2,327,344 | <p>On Linux, I have a c shared library that depends on other libs. LD_LIBRARY_PATH is properly set to allow the linker to load all the libraries. When I do:</p>
<pre><code>libgidcwf = ctypes.cdll.LoadLibrary(libidcwf_path)
</code></pre>
<p>I get the following error:</p>
<pre><code>Traceback (most recent call last... | 15 | 2010-02-24T15:53:21Z | 2,328,002 | <p>It would seem that libwav.so does not declare it's dependency on the library defining ODBCGeneralQuery. Try running <code>ldd path-to-my-lib/libwav.so</code> and see if there's something missing. If this is a shared library that you are building you should add <code>-llibname</code> to the linking command (the one t... | 12 | 2010-02-24T17:22:52Z | [
"python",
"linux",
"ctypes"
] |
ctypes loading a c shared library that has dependencies | 2,327,344 | <p>On Linux, I have a c shared library that depends on other libs. LD_LIBRARY_PATH is properly set to allow the linker to load all the libraries. When I do:</p>
<pre><code>libgidcwf = ctypes.cdll.LoadLibrary(libidcwf_path)
</code></pre>
<p>I get the following error:</p>
<pre><code>Traceback (most recent call last... | 15 | 2010-02-24T15:53:21Z | 9,071,896 | <p>You should use RTLD_GLOBAL. I have a mixed platform system, so my code looks something like this:</p>
<pre><code>import numpy, ctypes
try:
if "Linux" in esmfos:
_ESMF = ctypes.CDLL(libsdir+'/libesmf.so',mode=ctypes.RTLD_GLOBAL)
else:
_ESMF = numpy.ctypeslib.load_library('libesmf',libsdir)
except:
tra... | 2 | 2012-01-30T22:39:29Z | [
"python",
"linux",
"ctypes"
] |
ctypes loading a c shared library that has dependencies | 2,327,344 | <p>On Linux, I have a c shared library that depends on other libs. LD_LIBRARY_PATH is properly set to allow the linker to load all the libraries. When I do:</p>
<pre><code>libgidcwf = ctypes.cdll.LoadLibrary(libidcwf_path)
</code></pre>
<p>I get the following error:</p>
<pre><code>Traceback (most recent call last... | 15 | 2010-02-24T15:53:21Z | 12,121,131 | <p>When you compile the shared object, be sure to put all the <code>-lsomething</code> at the end of the string command. For me it solved the problem.</p>
| 4 | 2012-08-25T10:21:00Z | [
"python",
"linux",
"ctypes"
] |
ctypes loading a c shared library that has dependencies | 2,327,344 | <p>On Linux, I have a c shared library that depends on other libs. LD_LIBRARY_PATH is properly set to allow the linker to load all the libraries. When I do:</p>
<pre><code>libgidcwf = ctypes.cdll.LoadLibrary(libidcwf_path)
</code></pre>
<p>I get the following error:</p>
<pre><code>Traceback (most recent call last... | 15 | 2010-02-24T15:53:21Z | 30,845,750 | <p>I had the same problem.
Two things were required in order to solve it:</p>
<ol>
<li>use the <code>RTLD_GLOBAL</code> as other users said</li>
<li>You need to load every library that is used by your library. So if <code>ODBCGeneralQuery</code> is defined in lets say <code>libIDCodbc</code>, you need first run this l... | 2 | 2015-06-15T12:56:04Z | [
"python",
"linux",
"ctypes"
] |
It is said best way to deploy django is using wsgi, I am wondering why? | 2,327,355 | <p>We are deploying django application, I found in the documentation that it is recommended to use WSGI appoach for doing that. </p>
<p>Before deploying I wanted to know, why it is recommended over other two approaches i.e. using mod_python and fastcgi...</p>
<p>Thanks a lot.</p>
| 7 | 2010-02-24T15:54:41Z | 2,327,392 | <p>We tried <code>mod_python</code>. It's slower and harder to configure. It doesn't offer the daemon feature.</p>
<p>We couldn't get <code>fast_cgi</code> built for our combination of Apache, Red Hat and Python. I'm not sure specifically what was wrong, but we couldn't get it built properly. It wouldn't dispatch ... | 5 | 2010-02-24T15:57:45Z | [
"python",
"django",
"mod-wsgi",
"wsgi",
"django-wsgi"
] |
It is said best way to deploy django is using wsgi, I am wondering why? | 2,327,355 | <p>We are deploying django application, I found in the documentation that it is recommended to use WSGI appoach for doing that. </p>
<p>Before deploying I wanted to know, why it is recommended over other two approaches i.e. using mod_python and fastcgi...</p>
<p>Thanks a lot.</p>
| 7 | 2010-02-24T15:54:41Z | 2,327,403 | <p><code>wsgi</code> is usually preferred because it decouples your choice of framework from your choice of web server: if tomorrow you want to move, say, from Apache to nginx, or whatever, the move is trivially easy with wsgi, not so easy otherwise.</p>
<p>Furthermore, using wsgi affords you the option to add some mi... | 15 | 2010-02-24T15:58:49Z | [
"python",
"django",
"mod-wsgi",
"wsgi",
"django-wsgi"
] |
It is said best way to deploy django is using wsgi, I am wondering why? | 2,327,355 | <p>We are deploying django application, I found in the documentation that it is recommended to use WSGI appoach for doing that. </p>
<p>Before deploying I wanted to know, why it is recommended over other two approaches i.e. using mod_python and fastcgi...</p>
<p>Thanks a lot.</p>
| 7 | 2010-02-24T15:54:41Z | 2,327,419 | <p>I use mod_wsgi for any production Django app. It's fast, stable, and very configurable.</p>
<p>You may also want to look in to the FastCGI method a bit more. Eric Florenzano just did a great write up of Django with FastCGI for the Django Advent: <a href="http://djangoadvent.com/1.2/deploying-django-site-using-fastc... | 0 | 2010-02-24T16:01:06Z | [
"python",
"django",
"mod-wsgi",
"wsgi",
"django-wsgi"
] |
Outlook contacts using Python client | 2,327,584 | <p>I want to write a script which permits a user to modify his Contacts, can you help me ? </p>
<p>thanks,</p>
| 0 | 2010-02-24T16:23:26Z | 2,327,649 | <p>You can use Python-COM bindings to use Outlook's COM object and achieve what you want.</p>
<p><a href="http://www.boddie.org.uk/python/COM.html" rel="nofollow">Here</a>'s a nice tutorial on how to use Python with COM.</p>
| 3 | 2010-02-24T16:29:58Z | [
"python",
"outlook"
] |
timing block of code in Python without putting it in a function | 2,327,719 | <p>I'd like to time a block of code without putting it in a separate function. for example:</p>
<pre><code>def myfunc:
# some code here
t1 = time.time()
# block of code to time here
t2 = time.time()
print "Code took %s seconds." %(str(t2-t1))
</code></pre>
<p>however, I'd like to do this with the timeit mod... | 12 | 2010-02-24T16:42:27Z | 2,327,873 | <p>You can do this with the <code>with</code> statement. For example:</p>
<pre><code>import time
from contextlib import contextmanager
@contextmanager
def measureTime(title):
t1 = time.clock()
yield
t2 = time.clock()
print '%s: %0.2f seconds elapsed' % (title, t2-t1)
</code></pre>
<p>To be used... | 24 | 2010-02-24T17:04:14Z | [
"python",
"datetime",
"benchmarking"
] |
timing block of code in Python without putting it in a function | 2,327,719 | <p>I'd like to time a block of code without putting it in a separate function. for example:</p>
<pre><code>def myfunc:
# some code here
t1 = time.time()
# block of code to time here
t2 = time.time()
print "Code took %s seconds." %(str(t2-t1))
</code></pre>
<p>however, I'd like to do this with the timeit mod... | 12 | 2010-02-24T16:42:27Z | 2,328,226 | <p>You can set up a variable to refer to the code block you want to time by putting that block inside Python's triple quotes. Then use that variable when instantiating your timeit object. Somewhat following an example from the <a href="http://www.python.org/doc/2.6.4/library/timeit.html#examples" rel="nofollow">Pytho... | 2 | 2010-02-24T17:52:46Z | [
"python",
"datetime",
"benchmarking"
] |
timing block of code in Python without putting it in a function | 2,327,719 | <p>I'd like to time a block of code without putting it in a separate function. for example:</p>
<pre><code>def myfunc:
# some code here
t1 = time.time()
# block of code to time here
t2 = time.time()
print "Code took %s seconds." %(str(t2-t1))
</code></pre>
<p>however, I'd like to do this with the timeit mod... | 12 | 2010-02-24T16:42:27Z | 18,590,463 | <p>According with <a href="http://stackoverflow.com/users/49376/skilldrick">Skilldrick</a> <a href="http://stackoverflow.com/questions/2327719/timing-block-of-code-in-python-without-putting-it-in-a-function?answertab=active#2327873">answer</a> there is a silly module that I think can help: <a href="https://bitbucket.or... | 0 | 2013-09-03T10:54:38Z | [
"python",
"datetime",
"benchmarking"
] |
How to best use GPS data? | 2,327,813 | <p>I am currently developing an application that receives GPS data gathered using and android phone. I need to analyze that data in terms of speed, acceleration, etc...</p>
<p>My question is: Can I trust the speed values returned by the phone? Or should I use the difference in position and time between two points to g... | 6 | 2010-02-24T16:57:37Z | 2,327,837 | <p>Except using rather complicated data signal processing techniques, or by using an accelerometer and dead reckoning (which is highly inaccurate), a GPS device cannot measure its own velocity. Due to this, the velocity data provided by a GPS unit is interpolated using the exact same method you want to use. The two pro... | 9 | 2010-02-24T17:00:18Z | [
"python",
"android",
"gps",
"filtering"
] |
Best canvas for drawing in wxPython? | 2,327,918 | <p>I have to draw a graph of elements composing a topological model of a physical network. There would be nodes and arches, and the latter could be unidirectional or bidirectional.</p>
<p>I would like to capture the clicking events for the nodes and the arches (to select the element and show its properties somewhere),... | 2 | 2010-02-24T17:10:24Z | 2,352,596 | <p>It seems that OGL is not being updated, and in general FloatCanvas looks more modern. I don't really know deeply enough the two options.</p>
<p>It seems that event capturing is easier with FloatCanvas. I would try to use it before OGL.</p>
| 2 | 2010-02-28T20:44:25Z | [
"python",
"wxpython",
"canvas"
] |
Best canvas for drawing in wxPython? | 2,327,918 | <p>I have to draw a graph of elements composing a topological model of a physical network. There would be nodes and arches, and the latter could be unidirectional or bidirectional.</p>
<p>I would like to capture the clicking events for the nodes and the arches (to select the element and show its properties somewhere),... | 2 | 2010-02-24T17:10:24Z | 2,694,309 | <p>I've tried FloatCanvas, although there has been a lot of work to get everything to work. I've managed to get through mouse interaction things like connectivity, movement, automatic reconnection in case of movement, etc.</p>
<p>FloatCanvas is also quite nice in terms of performance and visual results. Anti-aliasing ... | 2 | 2010-04-22T20:41:26Z | [
"python",
"wxpython",
"canvas"
] |
IOError opening an existing file with Python | 2,327,989 | <p>Running the following code:</p>
<pre><code>import os
import datetime
import ftplib
currdate = datetime.datetime.now()
formatdate = currdate.strftime("%m-%d-%Y %H%M")
def log():
fqn = os.uname()[1]
ext_ip = urllib2.urlopen('http://whatismyip.org').read()
log = open ('/Users/admin/Documents/locatelog.t... | 0 | 2010-02-24T17:21:07Z | 2,328,012 | <p>Shouldn't it be<code>f = open('/Users/admin/Documents/%s.txt' % smush,'r')</code> ? notice the <code>/</code> in front of <code>Users</code></p>
<p>If you dont put the first <code>/</code>, the script will think the path to the file is relative to the current directory (where the script is run from)</p>
<p><strong... | 5 | 2010-02-24T17:24:05Z | [
"python",
"osx",
"file-io",
"ftp",
"ftplib"
] |
IOError opening an existing file with Python | 2,327,989 | <p>Running the following code:</p>
<pre><code>import os
import datetime
import ftplib
currdate = datetime.datetime.now()
formatdate = currdate.strftime("%m-%d-%Y %H%M")
def log():
fqn = os.uname()[1]
ext_ip = urllib2.urlopen('http://whatismyip.org').read()
log = open ('/Users/admin/Documents/locatelog.t... | 0 | 2010-02-24T17:21:07Z | 2,328,499 | <p>remove all spaces from file name .eg in <code>smush = str(fqn +' @ ' + formatdate)</code>, you are putting a space in front of and after "@". you path looks like </p>
<pre><code>/Users/admin/Documents/something @ something
</code></pre>
<p>and when you pass it to ftplib, it may have problem. another way is to try... | 1 | 2010-02-24T18:33:48Z | [
"python",
"osx",
"file-io",
"ftp",
"ftplib"
] |
IOError opening an existing file with Python | 2,327,989 | <p>Running the following code:</p>
<pre><code>import os
import datetime
import ftplib
currdate = datetime.datetime.now()
formatdate = currdate.strftime("%m-%d-%Y %H%M")
def log():
fqn = os.uname()[1]
ext_ip = urllib2.urlopen('http://whatismyip.org').read()
log = open ('/Users/admin/Documents/locatelog.t... | 0 | 2010-02-24T17:21:07Z | 2,328,619 | <p><strong>Edit:</strong> </p>
<p>This version works: Problem was that I was writing to buffer, and not to file.</p>
<pre><code>import os
import urllib2
import datetime
import ftplib
currdate = datetime.datetime.now()
formatdate = currdate.strftime("%m-%d-%Y-%H%M")
def log():
fqn = os.uname()[1]
ext_ip = u... | 0 | 2010-02-24T18:49:22Z | [
"python",
"osx",
"file-io",
"ftp",
"ftplib"
] |
Drag-and-drop to canvas in wxPython | 2,328,008 | <p>Do you know if there is an easy way to drag-and-drop elements (icons or buttons) into a canvas and create different drawings on it as a result?</p>
<p>The idea is to have a set of objects and let the user drag them into a drawing space.</p>
<p>In the worst case the user could just click on the icon/button, and the... | 3 | 2010-02-24T17:23:25Z | 3,950,054 | <p>There is an example of something more or less like this here: <a href="http://wiki.wxpython.org/wxOGL" rel="nofollow">http://wiki.wxpython.org/wxOGL</a> Although it is about wxOGL, they recommend you to use either SimpleCanvas or FloatCanvas and adapt their examples.</p>
| 1 | 2010-10-16T17:49:27Z | [
"python",
"drag-and-drop",
"wxpython",
"canvas"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.