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 |
|---|---|---|---|---|---|---|---|---|---|
What is the best way to store database settings with Django? | 1,911,652 | <p>I'm attempting to write a browser game using Django but I'm getting a bit stuck on how to store the settings for the game. For example, the game is tick based and I want to store the current tick. I have decided that I want only one game per database to avoid problems with the built-in user authorisation system (e.g... | 1 | 2009-12-16T01:17:37Z | 1,911,706 | <p>You could be a bit more generic and just have a "Setting" record. This would allow you to expand the amount of settings you could store infinitely.</p>
<pre><code>class Setting(models.Model):
name = models.CharField(max_length=50)
value = models.TextField()
# ...
# Get the current slot setting
current_sl... | 4 | 2009-12-16T01:31:32Z | [
"python",
"django"
] |
What is the best way to store database settings with Django? | 1,911,652 | <p>I'm attempting to write a browser game using Django but I'm getting a bit stuck on how to store the settings for the game. For example, the game is tick based and I want to store the current tick. I have decided that I want only one game per database to avoid problems with the built-in user authorisation system (e.g... | 1 | 2009-12-16T01:17:37Z | 1,911,707 | <p>I don't understand why you need one database per game. Why not have a Games table with one row per game, and have all other data tables reference the game_id of the game they're associated with?</p>
| 0 | 2009-12-16T01:32:03Z | [
"python",
"django"
] |
Nested SSH session with Paramiko | 1,911,690 | <p>I'm rewriting a Bash script I wrote into Python. The crux of that script was</p>
<pre><code>ssh -t first.com "ssh second.com very_remote_command"
</code></pre>
<p>I'm having a problem with the nested authentication with paramiko. I wasn't able to find any examples dealing with my precise situation, but I was able ... | 25 | 2009-12-16T01:28:06Z | 1,916,877 | <p>I managed to find a solution, but it requires a little manual work. If anyone have a better solution, please tell me.</p>
<pre><code>ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('first.com', username='luser', password='secret')
chan = ssh.invoke_shell()
# Ssh an... | 22 | 2009-12-16T18:59:53Z | [
"python",
"ssh",
"paramiko"
] |
Nested SSH session with Paramiko | 1,911,690 | <p>I'm rewriting a Bash script I wrote into Python. The crux of that script was</p>
<pre><code>ssh -t first.com "ssh second.com very_remote_command"
</code></pre>
<p>I'm having a problem with the nested authentication with paramiko. I wasn't able to find any examples dealing with my precise situation, but I was able ... | 25 | 2009-12-16T01:28:06Z | 2,510,946 | <p>For a ready made solution check out pxssh from the pxpect project. Look at the sshls.py and ssh_tunnel.py examples.</p>
<p><a href="http://www.noah.org/wiki/Pexpect" rel="nofollow">http://www.noah.org/wiki/Pexpect</a></p>
| 1 | 2010-03-24T19:54:18Z | [
"python",
"ssh",
"paramiko"
] |
Nested SSH session with Paramiko | 1,911,690 | <p>I'm rewriting a Bash script I wrote into Python. The crux of that script was</p>
<pre><code>ssh -t first.com "ssh second.com very_remote_command"
</code></pre>
<p>I'm having a problem with the nested authentication with paramiko. I wasn't able to find any examples dealing with my precise situation, but I was able ... | 25 | 2009-12-16T01:28:06Z | 10,432,669 | <p>Here is a small example using paramiko only (and port forwarding):</p>
<pre><code>import paramiko as ssh
class SSHTool():
def __init__(self, host, user, auth,
via=None, via_user=None, via_auth=None):
if via:
t0 = ssh.Transport(via)
t0.start_client()
... | 12 | 2012-05-03T13:42:53Z | [
"python",
"ssh",
"paramiko"
] |
Nested SSH session with Paramiko | 1,911,690 | <p>I'm rewriting a Bash script I wrote into Python. The crux of that script was</p>
<pre><code>ssh -t first.com "ssh second.com very_remote_command"
</code></pre>
<p>I'm having a problem with the nested authentication with paramiko. I wasn't able to find any examples dealing with my precise situation, but I was able ... | 25 | 2009-12-16T01:28:06Z | 19,728,760 | <p>Sinas's answer works well but didn't provide all the output from very long commands for me. However, using chan.makefile() allows me to retrieve all the output.</p>
<p>The below works on a system that requires tty and also prompts for sudo password</p>
<pre><code>ssh = paramiko.SSHClient()
ssh.load_system_host_ke... | 0 | 2013-11-01T14:28:21Z | [
"python",
"ssh",
"paramiko"
] |
Nested SSH session with Paramiko | 1,911,690 | <p>I'm rewriting a Bash script I wrote into Python. The crux of that script was</p>
<pre><code>ssh -t first.com "ssh second.com very_remote_command"
</code></pre>
<p>I'm having a problem with the nested authentication with paramiko. I wasn't able to find any examples dealing with my precise situation, but I was able ... | 25 | 2009-12-16T01:28:06Z | 20,118,149 | <p>You can create ssh connection using channel from another ssh connection. See <a href="http://stackoverflow.com/a/19039769">here</a> for more detail.</p>
| 5 | 2013-11-21T10:18:02Z | [
"python",
"ssh",
"paramiko"
] |
Is there an equivalent to Boost::Python for Java? | 1,911,942 | <p>I've been working with Boost::Python to expose some high-performance code to python recently, and it's just a dream to work with. I'd like to be able to maintain a single C++ codebase and expose it to Python via Boost, and to Java as well. I know about JNI, but I was wondering if there's something equivalent to Bo... | 1 | 2009-12-16T02:48:58Z | 1,911,963 | <p>There are a number of Java projects that let you call functions exposed in DLLs without writing JNI wrapper code. These include <a href="http://www.jinvoke.com/" rel="nofollow">J/Invoke</a>, <a href="http://johannburkard.de/software/nativecall/" rel="nofollow">NativeCall</a>, <a href="http://www.excelsior-usa.com/xf... | 3 | 2009-12-16T02:53:59Z | [
"java",
"python",
"boost"
] |
Is there an equivalent to Boost::Python for Java? | 1,911,942 | <p>I've been working with Boost::Python to expose some high-performance code to python recently, and it's just a dream to work with. I'd like to be able to maintain a single C++ codebase and expose it to Python via Boost, and to Java as well. I know about JNI, but I was wondering if there's something equivalent to Bo... | 1 | 2009-12-16T02:48:58Z | 1,916,257 | <p>I think <a href="http://www.swig.org" rel="nofollow">SWIG</a> can also be a choice.</p>
| 1 | 2009-12-16T17:28:55Z | [
"java",
"python",
"boost"
] |
How does this max() expression in Python work? | 1,911,981 | <p>Here's the code:</p>
<pre><code>a = [1,2,3,4]
b = {}
b[1] = 10
b[2] = 8
b[3] = 7
b[4] = 5
print max(a,key=lambda w: b[w])
</code></pre>
<p>This prints out <code>1</code>.</p>
<p>I don't understand how <code>max(a,key=lambda w: b[w])</code> is being evaluated here though; I'm guessing for each value i in a, it fin... | 2 | 2009-12-16T03:01:12Z | 1,912,002 | <p><code>max(a,...)</code> is always going to return an element of <code>a</code>. So the result will be either 1,2,3, or 4.
For each value <code>w</code> in <code>a</code>, the key value is <code>b[w]</code>. The largest key value is 10, and that corresponds with <code>w</code> equalling 1. So <code>max(a,key=lambda w... | 9 | 2009-12-16T03:07:03Z | [
"python",
"lambda",
"max"
] |
How does this max() expression in Python work? | 1,911,981 | <p>Here's the code:</p>
<pre><code>a = [1,2,3,4]
b = {}
b[1] = 10
b[2] = 8
b[3] = 7
b[4] = 5
print max(a,key=lambda w: b[w])
</code></pre>
<p>This prints out <code>1</code>.</p>
<p>I don't understand how <code>max(a,key=lambda w: b[w])</code> is being evaluated here though; I'm guessing for each value i in a, it fin... | 2 | 2009-12-16T03:01:12Z | 1,914,478 | <p>Try:</p>
<pre><code>a = [1,2,3,4]
b = {}
b[1] = 10
b[2] = 8
b[3] = 7
b[4] = 5
c = a + b.values()
print max(*c)
</code></pre>
| -3 | 2009-12-16T12:49:34Z | [
"python",
"lambda",
"max"
] |
Ruby task application (tap) python alternative | 1,912,089 | <p>I just saw this </p>
<p><a href="http://www.scribd.com/doc/13054288/Tap-Workflows" rel="nofollow">http://www.scribd.com/doc/13054288/Tap-Workflows</a></p>
<p>What I need is a replacement of make to perform computations that are dependent on each other but whose dependency is not only on something like the filename... | 2 | 2009-12-16T03:30:54Z | 1,912,102 | <p>Could you explain what the tools in the question you linked to don't do for you?</p>
<p>If you want to (ab)use a Python-based software build tool, you could try <a href="http://www.blueskyonmars.com/projects/paver/" rel="nofollow">Paver</a> or <a href="http://www.buildout.org/" rel="nofollow">Buildout</a>.</p>
<p>... | 0 | 2009-12-16T03:36:13Z | [
"python",
"workflow"
] |
deleter decorator using Property in Python | 1,912,229 | <p>I'm playing around with property in Python and I was wondering how this @propertyName.deleter decorator works. I'm probably missing something, I could not find clear answers by Google. </p>
<p>What I would like to achieve is when this <strong>deleter</strong> behavior is called, I can trigger other actions (e.g: us... | 7 | 2009-12-16T04:11:41Z | 1,912,252 | <p>Make M a new-style class:</p>
<pre><code>class M(object):
</code></pre>
<p>See <a href="http://www.python.org/download/releases/2.2.3/descrintro/#property">http://www.python.org/download/releases/2.2.3/descrintro/#property</a>:</p>
<blockquote>
<p><strong>Properties do not work for classic
classes</strong>, b... | 7 | 2009-12-16T04:16:30Z | [
"python",
"properties",
"decorator"
] |
deleter decorator using Property in Python | 1,912,229 | <p>I'm playing around with property in Python and I was wondering how this @propertyName.deleter decorator works. I'm probably missing something, I could not find clear answers by Google. </p>
<p>What I would like to achieve is when this <strong>deleter</strong> behavior is called, I can trigger other actions (e.g: us... | 7 | 2009-12-16T04:11:41Z | 1,912,265 | <p>In Python 3 you WOULD see the <code>print</code>'s result -- and then an AttributeError for the last print (because <code>_m</code> has disappeared). You may be using Python 2.6, in which case you need to change the <code>class</code> clause to <code>class M(object):</code> to make <code>M</code> new-style, and the... | 5 | 2009-12-16T04:21:01Z | [
"python",
"properties",
"decorator"
] |
Limit calls to external database with Python CGI | 1,912,253 | <p>I've got a Python CGI script that pulls data from a GPS service; I'd like this information to be updated on the webpage about once every 10s (the max allowed by the GPS service's TOS). But there could be, say, 100 users viewing the webpage at once, all calling the script.</p>
<p>I think the users' scripts need to ... | 0 | 2009-12-16T04:16:55Z | 1,912,353 | <p>Cache the results of your GPS data query in a file or database (sqlite) along with a datetime.</p>
<p>You can then do a datetime check against the last cached datetime to initiate another GPS data query.</p>
<p>You'll probably run into concurrency issues with cgi and the datetime check though...</p>
<p>To get aro... | 1 | 2009-12-16T04:44:58Z | [
"python",
"sql",
"cgi"
] |
Django: Where to put helper functions? | 1,912,351 | <p>I have a couple of functions that i wrote that I need to use in my django app. Where would I put the file with them and how would i make them callable whithin my views?</p>
| 31 | 2009-12-16T04:44:50Z | 1,912,370 | <p>I usually put such app specific helper function in file utils.py and use someting like this</p>
<pre><code>from myapp.utils import my_cool_func
def view_coolness(request):
data = my_cool_func(request)
return render_to_response("xxx.html")
</code></pre>
<p>but it depends what you helper does, may be they m... | 32 | 2009-12-16T04:50:03Z | [
"python",
"django"
] |
Django: Where to put helper functions? | 1,912,351 | <p>I have a couple of functions that i wrote that I need to use in my django app. Where would I put the file with them and how would i make them callable whithin my views?</p>
| 31 | 2009-12-16T04:44:50Z | 1,912,371 | <p>If they are related to a specific app, I usually just put them in the related app folder and name the file, 'functions.py'.</p>
<p>If they're not specific to an app, you could just make a 'functions' app folder and place them in there.</p>
| 7 | 2009-12-16T04:50:06Z | [
"python",
"django"
] |
Django: Where to put helper functions? | 1,912,351 | <p>I have a couple of functions that i wrote that I need to use in my django app. Where would I put the file with them and how would i make them callable whithin my views?</p>
| 31 | 2009-12-16T04:44:50Z | 1,914,081 | <p>create a reusable app that include your generic functions so you can share between projects.</p>
<p>use for example a git repo to store this app and manage deployments and evolution (submodule)</p>
<p>use a public git repo so you can share with the community :)</p>
| 6 | 2009-12-16T11:28:55Z | [
"python",
"django"
] |
Django: Where to put helper functions? | 1,912,351 | <p>I have a couple of functions that i wrote that I need to use in my django app. Where would I put the file with them and how would i make them callable whithin my views?</p>
| 31 | 2009-12-16T04:44:50Z | 13,270,468 | <p>I am using new python file <code>service.py</code> in app folder. The file contains mostly helper queries for specific app. Also I used to create a folder inside Django application that contains global helper functions and constants.</p>
| 0 | 2012-11-07T13:09:40Z | [
"python",
"django"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,445 | <p>You can use <a href="http://www.crummy.com/software/BeautifulSoup/">BeautifulSoup</a></p>
<pre><code>from bs4 import BeautifulSoup
x="""<foo>
<bar>
<type foobar="1"/>
<type foobar="2"/>
</bar>
</foo>"""
y=BeautifulSoup(x)
>>> y.foo.bar.type["foobar"]
... | 145 | 2009-12-16T05:12:43Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,483 | <p>I suggest <a href="http://docs.python.org/library/xml.etree.elementtree.html"><code>ElementTree</code></a>. There are other compatible implementations of the same API, such as <a href="http://lxml.de/"><code>lxml</code></a>, and <code>cElementTree</code> in the Python standard library itself; but, in this context, ... | 384 | 2009-12-16T05:21:55Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,486 | <p>I'm still a Python newbie myself, but my impression is that <a href="http://docs.python.org/library/xml.etree.elementtree.html">ElementTree</a> is the state-of-the-art in Python XML parsing and handling.</p>
<p>Mark Pilgrim has <a href="http://getpython3.com/diveintopython3/xml.html#xml-parse">a good section</a> on... | 11 | 2009-12-16T05:23:31Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,504 | <p>Python has an interface to the expat xml parser.</p>
<pre><code>xml.parsers.expat
</code></pre>
<p>It's a non-validating parser, so bad xml will not be caught. But if you know your file is correct, then this is pretty good, and you'll probably <strong>get the exact info you want and you can discard the rest on the... | 16 | 2009-12-16T05:28:00Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,510 | <p>I find the Python <strong>xml.dom</strong> and <strong><a href="http://docs.python.org/library/xml.dom.minidom.html">xml.dom.minidom</a></strong> quite easy. Keep in mind that DOM isn't good for large amounts of XML, but if your input is fairly small then this will work fine.</p>
| 6 | 2009-12-16T05:28:55Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,912,516 | <p><a href="https://docs.python.org/3/library/xml.dom.minidom.html"><code>minidom</code></a> is the quickest and pretty straight forward:</p>
<p>XML:</p>
<pre><code><data>
<items>
<item name="item1"></item>
<item name="item2"></item>
<item name="item3... | 277 | 2009-12-16T05:30:15Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 1,913,809 | <p><a href="http://lxml.de/objectify.html">lxml.objectify</a> is really simple.</p>
<p>Taking your sample text:</p>
<pre><code>from lxml import objectify
from collections import defaultdict
count = defaultdict(int)
root = objectify.fromstring(text)
for item in root.bar.type:
count[item.attrib.get("foobar")] +=... | 31 | 2009-12-16T10:42:24Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 17,535,533 | <p>Here a very simple but effective code using <code>cElementTree</code>. </p>
<pre><code>try:
import cElementTree as ET
except ImportError:
try:
# Python 2.5 need to import a different module
import xml.etree.cElementTree as ET
except ImportError:
exit_err("Failed to import cElementTree from any k... | 8 | 2013-07-08T20:35:26Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 19,302,655 | <p>There are many options out there. <a href="http://effbot.org/zone/celementtree.htm">cElementTree</a> looks excellent if speed and memory usage are an issue. It has very little overhead compared to simply reading in the file using <code>readlines</code>.</p>
<p>The relevant metrics can be found in the table below, c... | 53 | 2013-10-10T17:44:17Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 24,183,790 | <p>I suggest <a href="https://pypi.python.org/pypi/xmltodict">xmltodict</a> for simplicity.</p>
<p>It parses your xml to an OrderedDict;</p>
<pre><code>>>> e = '<foo>
<bar>
<type foobar="1"/>
<type foobar="2"/>
</bar>
... | 20 | 2014-06-12T11:57:29Z | [
"python",
"xml"
] |
How do I parse XML in Python? | 1,912,434 | <p>I have many rows in a database that contains xml and I'm trying to write a Python script that will go through those rows and count how many instances of a particular node attribute show up. For instance, my tree looks like:</p>
<pre><code><foo>
<bar>
<type foobar="1"/>
<type foob... | 522 | 2009-12-16T05:09:24Z | 37,343,199 | <p>rec.xml:-</p>
<pre><code><?xml version="1.0"?>
<nodes>
<node name="Car" child="Engine"></node>
<node name="Engine" child="Piston"></node>
<node name="Engine" child="Carb"></node>
<node name="Car" child="Wheel"></node>
<node name="Whe... | -2 | 2016-05-20T09:37:50Z | [
"python",
"xml"
] |
Best place to coerce/convert to the right type in Python | 1,912,476 | <p>I'm still fairly new to Python and I'm trying to get used to its dynamic typing. Sometimes I have a function or a class that expects a parameter of a certain type, but could get a value of another type that's coercible to it. For example, it might expect a <code>float</code> but instead receive an int or a decimal. ... | 1 | 2009-12-16T05:20:26Z | 1,912,523 | <p>You "coerce" (perhaps -- it could be a noop) when it's indispensable for you to do so, and no earlier. For example, say you have a function that takes a float and returns the sum of its sine and cosine:</p>
<pre><code>import math
def spc(x):
math.sin(x) + math.cos(x)
</code></pre>
<p>Where should you "coerce" x... | 8 | 2009-12-16T05:34:12Z | [
"python",
"dynamic-typing"
] |
Best place to coerce/convert to the right type in Python | 1,912,476 | <p>I'm still fairly new to Python and I'm trying to get used to its dynamic typing. Sometimes I have a function or a class that expects a parameter of a certain type, but could get a value of another type that's coercible to it. For example, it might expect a <code>float</code> but instead receive an int or a decimal. ... | 1 | 2009-12-16T05:20:26Z | 1,912,544 | <p>It really depends. Why do you <em>need</em> a <code>float</code>? Would an <code>int</code> break the function? If so, why?</p>
<p>If you need the parameter to support a function/property that a <code>float</code> has but an <code>int</code> does not you should check for that function/property, <em>not</em> that... | 2 | 2009-12-16T05:39:27Z | [
"python",
"dynamic-typing"
] |
Best place to coerce/convert to the right type in Python | 1,912,476 | <p>I'm still fairly new to Python and I'm trying to get used to its dynamic typing. Sometimes I have a function or a class that expects a parameter of a certain type, but could get a value of another type that's coercible to it. For example, it might expect a <code>float</code> but instead receive an int or a decimal. ... | 1 | 2009-12-16T05:20:26Z | 1,914,129 | <p>There is exactly one time when integer vs. float will be a problem. This is the only time when you will find a "simple" bug that's weird and a challenge to debug.</p>
<p>Division.</p>
<p>Everything else does the conversion you need when you need it.</p>
<p>If you are using Python 2.x and casually throwing around... | 0 | 2009-12-16T11:36:19Z | [
"python",
"dynamic-typing"
] |
A question on python GIL | 1,912,557 | <p>Does the presence of python GIL imply that in python multi threading the <strong>same</strong> operation is not so different from repeating it in a single thread?.</p>
<p>For example, If I need to upload two files, what is the advantage of doing them in two threads instead of uploading them one after another?. </p>... | 2 | 2009-12-16T05:43:19Z | 1,912,585 | <p>It depends on the native code module that's executing. Native modules can release the GIL and then go off and do their own thing allowing another thread to lock the GIL. The GIL is normally held while code, both python and native, are operating on python objects. If you want more detail you'll probably need to go an... | 3 | 2009-12-16T05:51:14Z | [
"python",
"multithreading",
"gil"
] |
A question on python GIL | 1,912,557 | <p>Does the presence of python GIL imply that in python multi threading the <strong>same</strong> operation is not so different from repeating it in a single thread?.</p>
<p>For example, If I need to upload two files, what is the advantage of doing them in two threads instead of uploading them one after another?. </p>... | 2 | 2009-12-16T05:43:19Z | 1,912,602 | <p>It really depends on the library you're using. The GIL is meant to prevent Python objects and its internal data structures to be changed at the same time. If you're doing an upload, the library you use to do the actual upload might release the GIL while it's waiting for the actual HTTP request to complete (I would a... | 3 | 2009-12-16T05:57:54Z | [
"python",
"multithreading",
"gil"
] |
A question on python GIL | 1,912,557 | <p>Does the presence of python GIL imply that in python multi threading the <strong>same</strong> operation is not so different from repeating it in a single thread?.</p>
<p>For example, If I need to upload two files, what is the advantage of doing them in two threads instead of uploading them one after another?. </p>... | 2 | 2009-12-16T05:43:19Z | 1,912,607 | <p>Python's threads get a slightly worse rap than they deserve. There are three (well, 2.5) cases where they actually get you benefits:</p>
<ul>
<li><p>If non-Python code (e.g. a C library, the kernel, etc.) is running, other Python threads can continue executing. It's only pure Python code that can't run in two threa... | 10 | 2009-12-16T05:58:56Z | [
"python",
"multithreading",
"gil"
] |
Python library to detect if a file has changed between different runs? | 1,912,567 | <p>Suppose I have a program A. I run it, and performs some operation starting from a file foo.txt. Now A terminates. </p>
<p>New run of A. It checks if the file foo.txt has changed. If the file has changed, A runs its operation again, otherwise, it quits.</p>
<p>Does a library function/external library for this exis... | 4 | 2009-12-16T05:45:36Z | 1,912,579 | <p>Cant we just check the last modified date . i.e after the first operation we store the last modified date in the db , and then before running again we compare the last modified date of the file foo.txt with the value stored in our db .. if they differ ,we perform the operation again ?</p>
| 0 | 2009-12-16T05:49:18Z | [
"python",
"file"
] |
Python library to detect if a file has changed between different runs? | 1,912,567 | <p>Suppose I have a program A. I run it, and performs some operation starting from a file foo.txt. Now A terminates. </p>
<p>New run of A. It checks if the file foo.txt has changed. If the file has changed, A runs its operation again, otherwise, it quits.</p>
<p>Does a library function/external library for this exis... | 4 | 2009-12-16T05:45:36Z | 1,912,589 | <p>This is one of those things that is both so trivial to implement and so app-specific that there really wouldn't be any point in a library, and any library intended for this purpose would grow so unwieldy trying to adapt to the many variations required, learning and using the library would take as much time as implem... | 2 | 2009-12-16T05:52:00Z | [
"python",
"file"
] |
Python library to detect if a file has changed between different runs? | 1,912,567 | <p>Suppose I have a program A. I run it, and performs some operation starting from a file foo.txt. Now A terminates. </p>
<p>New run of A. It checks if the file foo.txt has changed. If the file has changed, A runs its operation again, otherwise, it quits.</p>
<p>Does a library function/external library for this exis... | 4 | 2009-12-16T05:45:36Z | 1,912,614 | <p>It's unlikely that someone made a library for something so simple. Solution in 13 lines:</p>
<pre><code>import pickle
import md5
try:
l = pickle.load(open("db"))
except IOError:
l = []
db = dict(l)
path = "/etc/hosts"
checksum = md5.md5(open(path).read())
if db.get(path, None) != checksum:
print "file ... | 7 | 2009-12-16T06:01:45Z | [
"python",
"file"
] |
Python library to detect if a file has changed between different runs? | 1,912,567 | <p>Suppose I have a program A. I run it, and performs some operation starting from a file foo.txt. Now A terminates. </p>
<p>New run of A. It checks if the file foo.txt has changed. If the file has changed, A runs its operation again, otherwise, it quits.</p>
<p>Does a library function/external library for this exis... | 4 | 2009-12-16T05:45:36Z | 5,878,324 | <p>FYI - for those using this example who got this error: "TypeError: can't pickle HASH objects"
Simply modify the following (optionally update md5 to hashlib, md5 is deprecated): </p>
<pre><code> import pickle
import hashlib #instead of md5
try:
l = pickle.load(open("db"))
except IOError:
... | 4 | 2011-05-04T03:53:12Z | [
"python",
"file"
] |
Organizing python code for handling statistic information | 1,912,635 | <p>I'm going to create statistics based on information what builds were success or not and how much per project. </p>
<p>I create ProjectStat class per new project I see and inside handled statistics. For printing overall statistic I need to pass through all ProjectStat instances. For printing success statistics per p... | 0 | 2009-12-16T06:06:55Z | 1,912,878 | <p>I'm not sure I understand the Q, but I'll try to answer anyway :)</p>
<p>option1:</p>
<pre><code>total = sum([project.projectTotal for project in dict.values()])
success = sum([project.projectSuccess for project in dict.values()])
failed = sum([project.projectFailed for project in dict.values()])
</code></pre>
<p... | 1 | 2009-12-16T07:12:05Z | [
"python"
] |
How to use python, PyLab, NumPy, etc for my Physics lab class over excel | 1,912,743 | <p>Hey all,
I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better... | 4 | 2009-12-16T06:39:58Z | 1,912,771 | <p>The paper <a href="http://openwetware.org/wiki/Julius%5FB.%5FLucks/Projects/Python%5FAll%5FA%5FScientist%5FNeeds" rel="nofollow">Python all a scientist needs</a> comes to mind. I hope you can make the needed transformations from Biology to Physics.</p>
| 1 | 2009-12-16T06:46:08Z | [
"python",
"numpy",
"matplotlib"
] |
How to use python, PyLab, NumPy, etc for my Physics lab class over excel | 1,912,743 | <p>Hey all,
I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better... | 4 | 2009-12-16T06:39:58Z | 1,919,730 | <p>Don't reject Excel outright. It's still great for doing simple data analysis and plotting. Excel also has the considerable advantage of being installed on most engineer and scientist's computers, making it a lot easier to share your work with colleagues.</p>
<p>That said, I do use Python when Excel just won't cut i... | 0 | 2009-12-17T05:54:29Z | [
"python",
"numpy",
"matplotlib"
] |
How to use python, PyLab, NumPy, etc for my Physics lab class over excel | 1,912,743 | <p>Hey all,
I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better... | 4 | 2009-12-16T06:39:58Z | 1,923,440 | <p><a href="http://www.scipy.org/" rel="nofollow"><strong>Scipy</strong></a> will also be useful to you, as it includes many more advanced analysis tools. For example, Scipy includes a linear regression, and gets more interesting from there. Along with the other tools you mentioned, you'll probably find most of your ... | 1 | 2009-12-17T17:48:19Z | [
"python",
"numpy",
"matplotlib"
] |
How to use python, PyLab, NumPy, etc for my Physics lab class over excel | 1,912,743 | <p>Hey all,
I took a scientific programming course this semester that I really enjoyed and experimented with a lot. We used python, and all the related modules. I am taking a physics lab next semester and I just wanted to hear from some of you how python can help me in ways that excel can't or in ways that are better... | 4 | 2009-12-16T06:39:58Z | 1,928,829 | <p>I can recall 2 presentations by Jan Martinek on EuroScipy 2008, he's PhD candidate and presented some fun experiments with Physics in the background. Abstracts are <a href="http://www.scipy.org/EuroSciPy2008Abstracts#jmartinek1" rel="nofollow">here</a> and I'm sure he would't mind to share more if you contact him di... | 0 | 2009-12-18T15:21:08Z | [
"python",
"numpy",
"matplotlib"
] |
double quote escaping in os.system on windows | 1,912,818 | <p>I want to escape '"' and all other wild chars in program name and arguments, so I try to double quote them. and I can do this in cmd.exe</p>
<pre><code>C:\bay\test\go>"test.py" "a" "b" "c"
hello
['C:\\bay\\test\\go\\test.py', 'a', 'b', 'c']
</code></pre>
<p>but what's wrong with the following code using os.syt... | 3 | 2009-12-16T06:59:23Z | 1,912,840 | <p>Try with <code>os.system('python "test.py" "a" "b" "c"')</code></p>
<p>You can also use <strong>subprocess</strong> module for that kind of purpose, </p>
<p>please take a look <a href="http://stackoverflow.com/questions/1885776/python-2-6-reading-data-from-a-windows-console-application-os-system/1885778#1885778">t... | 1 | 2009-12-16T07:03:11Z | [
"python",
"windows",
"batch-file",
"double-quotes"
] |
double quote escaping in os.system on windows | 1,912,818 | <p>I want to escape '"' and all other wild chars in program name and arguments, so I try to double quote them. and I can do this in cmd.exe</p>
<pre><code>C:\bay\test\go>"test.py" "a" "b" "c"
hello
['C:\\bay\\test\\go\\test.py', 'a', 'b', 'c']
</code></pre>
<p>but what's wrong with the following code using os.syt... | 3 | 2009-12-16T06:59:23Z | 1,913,005 | <p>Actually, it just work as design.
You can NOT use os.system like that. See this:
<a href="http://mail.python.org/pipermail/python-bugs-list/2000-July/000946.html" rel="nofollow">http://mail.python.org/pipermail/python-bugs-list/2000-July/000946.html</a></p>
| 3 | 2009-12-16T07:47:41Z | [
"python",
"windows",
"batch-file",
"double-quotes"
] |
double quote escaping in os.system on windows | 1,912,818 | <p>I want to escape '"' and all other wild chars in program name and arguments, so I try to double quote them. and I can do this in cmd.exe</p>
<pre><code>C:\bay\test\go>"test.py" "a" "b" "c"
hello
['C:\\bay\\test\\go\\test.py', 'a', 'b', 'c']
</code></pre>
<p>but what's wrong with the following code using os.syt... | 3 | 2009-12-16T06:59:23Z | 1,913,064 | <p>Furthing google comes this page </p>
<p><a href="http://ss64.com/nt/syntax-esc.html" rel="nofollow">http://ss64.com/nt/syntax-esc.html</a></p>
<pre><code>To launch a batch script which itself requires "quotes"
CMD /k ""c:\batch files\test.cmd" "Parameter 1 with space" "Parameter2 with space""
</code></pre>
<p><c... | 4 | 2009-12-16T08:04:58Z | [
"python",
"windows",
"batch-file",
"double-quotes"
] |
double quote escaping in os.system on windows | 1,912,818 | <p>I want to escape '"' and all other wild chars in program name and arguments, so I try to double quote them. and I can do this in cmd.exe</p>
<pre><code>C:\bay\test\go>"test.py" "a" "b" "c"
hello
['C:\\bay\\test\\go\\test.py', 'a', 'b', 'c']
</code></pre>
<p>but what's wrong with the following code using os.syt... | 3 | 2009-12-16T06:59:23Z | 16,828,711 | <p>Enclose the arguments in brackets, it works.</p>
<pre><code>CMD /k ("c:\batch files\test.cmd" "Parameter 1 with space" "Parameter2 with space")
</code></pre>
| 0 | 2013-05-30T05:37:12Z | [
"python",
"windows",
"batch-file",
"double-quotes"
] |
Authenticated request in Google App Engine using fetch() function: how to provide the information in the header of the request? | 1,912,845 | <p>I am trying to pass automatically, using <a href="http://code.google.com/appengine/" rel="nofollow">Google App Engine</a>, my password and ID to eBay, to this page: </p>
<p><a href="https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co%5FpartnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5... | 0 | 2009-12-16T07:05:03Z | 1,913,162 | <p>I'm not sure if this helps, but ebay has an API that would be simpler to use and incorporate. Check out <a href="http://developer.ebay.com/businessbenefits/aboutus/" rel="nofollow">http://developer.ebay.com/businessbenefits/aboutus/</a></p>
| 3 | 2009-12-16T08:31:50Z | [
"python",
"google-app-engine",
"authorization",
"header",
"ebay"
] |
Authenticated request in Google App Engine using fetch() function: how to provide the information in the header of the request? | 1,912,845 | <p>I am trying to pass automatically, using <a href="http://code.google.com/appengine/" rel="nofollow">Google App Engine</a>, my password and ID to eBay, to this page: </p>
<p><a href="https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&UsingSSL=1&pUserId=&co%5FpartnerId=2&siteid=0&ru=http%3A%2F%2Fcgi5... | 0 | 2009-12-16T07:05:03Z | 1,915,386 | <p>Looks like some of the quote-characters are the wrong kind -- reversed "smart quotes" rather than normal plain ordinary ASCII quote characters. Hard to say precisely from screenshots! The error screen you're showing (from GAE's SDK) shows the exact location of the error at the very bottom -- and you're showing it ... | 2 | 2009-12-16T15:31:25Z | [
"python",
"google-app-engine",
"authorization",
"header",
"ebay"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 1,913,008 | <p>One example that is a perfect match for IronPython is when you want to include scriptability in your application. I have been working on systems where the user can interact with the whole application class model directly through the in-app python scripting layer and it allows for a great deal of flexibility for adva... | 9 | 2009-12-16T07:49:01Z | [
"python",
"ironpython"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 1,913,029 | <p>In the day job, it's my standard language for those little bits of build process that are too much for .bat files and not heavyweight enough to demand a separate executable; this includes anything that could use a little bit of XML processing or reflection -- generating Wix files with systematic handling of 32 and 6... | 3 | 2009-12-16T07:57:48Z | [
"python",
"ironpython"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 1,913,220 | <p>Created a load tool for a MS Group Chat Server plugin. The GC API is in C#. I wrapped that into a dll and had FePy load it. The main application, configuration scripts etc are all in FePy.</p>
| 0 | 2009-12-16T08:44:15Z | [
"python",
"ironpython"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 1,913,566 | <p>I've just deployed my IronPython Point-of-Sales service application at the beginning of this month. The service application is a RESTful http server serving query & transactional request to .NET WinForms client. With help of some remoting library, the service application is purely implemented in IronPython.</p... | 4 | 2009-12-16T09:57:34Z | [
"python",
"ironpython"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 10,438,778 | <p>I use IronPython for a few different purposes:</p>
<ul>
<li>An alternative to Powershell when I need to script something and invoke a .NET library, or when the script is complicated enough to warrant a real programming language.</li>
<li>Embedding in a .NET app for scriptable plugins.</li>
<li>Prototyping and testi... | 0 | 2012-05-03T20:21:43Z | [
"python",
"ironpython"
] |
IronPython: What kind of jobs you ever done with IronPython instead of standard .NET languages (e.g., C#) | 1,912,971 | <p>I am learning IronPython along wiht Python. I'm curious <strong>what kinds of tasks</strong> you tend to use IronPython to tackle more often than standard .NET languages. </p>
<p>Thanks for any example.</p>
| 8 | 2009-12-16T07:36:11Z | 10,440,546 | <p>We use it a lot for small administrative tools against SharePoint. In particular it is fantastic for exploring the API against real data (with all its real life quirks). Development iterations are faster and you can't always install Visual Studio on production servers.</p>
| 0 | 2012-05-03T23:06:52Z | [
"python",
"ironpython"
] |
xml.dom.minidom python issue | 1,913,613 | <pre><code>from xml.dom.minidom import *
resp = "<title> This is a test! </title>"
rssDoc = parseString(resp)
titles = rssDoc.getElementsByTagName('title')
moo = ""
for t in titles:
moo += t.nodeValue;
</code></pre>
<p>Gives the following error:</p>
<pre><code>main.py, line 42, in
get moo ... | 0 | 2009-12-16T10:06:09Z | 1,913,650 | <p>because <code>t.nodeType</code> is not equal to <code>t.TEXT_NODE</code> of course.</p>
| 0 | 2009-12-16T10:12:05Z | [
"python",
"xml"
] |
xml.dom.minidom python issue | 1,913,613 | <pre><code>from xml.dom.minidom import *
resp = "<title> This is a test! </title>"
rssDoc = parseString(resp)
titles = rssDoc.getElementsByTagName('title')
moo = ""
for t in titles:
moo += t.nodeValue;
</code></pre>
<p>Gives the following error:</p>
<pre><code>main.py, line 42, in
get moo ... | 0 | 2009-12-16T10:06:09Z | 1,913,661 | <p>Because is not a text node, but an element node. The text node which contains the " This is a test! " string is actually a child node of this element node.</p>
<p>So you can try this (untested, not assumes existence of the text node):</p>
<pre><code>if t.nodeType == t.ELEMENT_NODE:
moo += t.childNodes[0].data... | 1 | 2009-12-16T10:14:08Z | [
"python",
"xml"
] |
xml.dom.minidom python issue | 1,913,613 | <pre><code>from xml.dom.minidom import *
resp = "<title> This is a test! </title>"
rssDoc = parseString(resp)
titles = rssDoc.getElementsByTagName('title')
moo = ""
for t in titles:
moo += t.nodeValue;
</code></pre>
<p>Gives the following error:</p>
<pre><code>main.py, line 42, in
get moo ... | 0 | 2009-12-16T10:06:09Z | 1,913,666 | <p>The <code><title></code> node contains a text node as a subnode. Maybe you want to iterate through the subnodes instead? Something like this:</p>
<pre><code>from xml.dom.minidom import *
resp = "<title> This is a test! </title>"
rssDoc = parseString(resp)
titles = rssDoc.getElementsByTagName(... | 2 | 2009-12-16T10:14:52Z | [
"python",
"xml"
] |
db.Model class variables and __init__ | 1,913,775 | <p>(New to Python and GAE)</p>
<p>I'm looking for an explanation to the use of class variables in db.Model subclasses, which are treated like instance variables. Why are these declared in class scope and not in <code>__init__</code>? Is this some kind of special GAE requirement?</p>
| 2 | 2009-12-16T10:36:20Z | 1,914,013 | <p>Yes, this is a programming model special to GAE. You can think of the class properties as the table definition. The instance properties are the contents of a row, they are populated on the fly by the metclass db.PropertiedClass.</p>
<p>There is a lot going on under the hood, if you are interested always have a look... | 3 | 2009-12-16T11:16:43Z | [
"python",
"google-app-engine"
] |
Python date formatting without space? | 1,913,798 | <p>How to display the following without any space also could we substitute a separator instead of space?</p>
<pre><code>> log_time=datetime.datetime.now()
> print log_time
2009-12-16 16:10:03.558991
</code></pre>
| 0 | 2009-12-16T10:40:43Z | 1,913,811 | <p>Use <code><a href="http://docs.python.org/library/datetime.html#datetime.date.strftime" rel="nofollow">datetime.date.strftime()</a></code>.</p>
| 2 | 2009-12-16T10:43:35Z | [
"python",
"time"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,913,860 | <p><a href="http://www.cython.org" rel="nofollow">Cython</a> can help you. The usual way to use cython is to speed up modules by having part of them compiled to C. However it is perfectly possible to use cython to output pure C files from pythonlike syntax if you are careful.</p>
<p>This also has an advantage of lett... | 1 | 2009-12-16T10:51:31Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,913,945 | <p>Cython is designed to write python extensions, not full-fledged programs. The same is true for Pyrex.</p>
<p>Even though it's quite different from your example, <a href="http://codespeak.net/pypy/" rel="nofollow">PyPy</a> might be what you're looking for. It uses a Python subset (called RPython, a kind of more stat... | 7 | 2009-12-16T11:06:30Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,913,988 | <p>Have a look at "Go"....</p>
<p><a href="http://golang.org/" rel="nofollow">http://golang.org/</a></p>
| 0 | 2009-12-16T11:11:58Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,914,054 | <p>If you want to type less C, you don't need syntax tricks.</p>
<p>You need a library of better, higher-level constructs so you actually type less C, not fewer characters to create pseudo-C.</p>
<p>If you had a library of better, higher-level constructs, you could write properly object-oriented programs in a short, ... | 1 | 2009-12-16T11:25:35Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,914,075 | <p>Have you profiled what you actually spend time on --- you really want to trade maintainability for saving a few keystrokes?</p>
<p>When I write code, I spend most my time <em>reading</em> code.</p>
<p>Perhaps you're just a <em>very</em> slow typer... ;-)</p>
| 4 | 2009-12-16T11:28:15Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,914,144 | <p>I agree with what Alan Franzoni said "What are you asking for is really a different and somewhat easier C dialect" and since you are already prepared to use such a different dialect as your proposed, might I suggest the <a href="http://www.digitalmars.com/d/2.0/overview.html" rel="nofollow">computer language D</a>? ... | 0 | 2009-12-16T11:39:22Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,918,780 | <p>I've written a few Vim scripts for various things. I also had to write a lexical analyzer, parser, and interpreter from scratch for a class. This is a <em>very</em> bad idea.</p>
<ol>
<li><p>Writing a vim script to translate you syntax to C syntax is not a trivial thing. Ever written a lexical analyzer? a parser? ... | 0 | 2009-12-17T00:35:02Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 1,919,622 | <p>It sounds like you need to devote some time to perfecting usage of snippets, abbreviations, macros, autocompletes for C. You will gain speed with hard work and practise. </p>
<p>The closest sane analogy to what you are suggesting is perhaps writing HAML to generate HTML. But that is for a declarative language not a... | 0 | 2009-12-17T05:19:00Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 2,529,857 | <p>If C++ is OK for you, unlike Cython and Pyrex, <a href="http://shed-skin.blogspot.com/" rel="nofollow">Shed Skin</a> is used to <em>convert</em> a subset of Python to C++ and compile it with make/g++. The "subset of Python" means that everything you code is still Python, but you can not use all of the modules of Pyt... | 0 | 2010-03-27T15:41:08Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
Speedup writing C programs using a subset of the Python syntax | 1,913,837 | <p>I am constantly trying to optimize my time. Writing a C code takes a lot of time and requires much more keyboard touches than say writing a Python program. </p>
<p>However, in order to speed up the time required to create a C program, one can automatize many things. I'd like to write my programs using smth. like P... | 5 | 2009-12-16T10:48:52Z | 11,987,467 | <p>I have done a small Python script that lets me use C in Python syntax, like so:</p>
<pre><code>void quicksort(int* lst, int left, int right):
int i, j, p, tmp
i = left
j = right
p = lst[(i + j) / 2]
while i <= j:
while lst[i] < p: i++
while lst[j] > p: j--
if i <= j:
tmp = l... | 6 | 2012-08-16T12:47:18Z | [
"python",
"c",
"vim",
"syntax",
"scripting"
] |
How to open a webpage and search for a word in python | 1,913,871 | <p>How to open a webpage and search for a word in python?</p>
| 1 | 2009-12-16T10:53:13Z | 1,913,910 | <p>This is a little simplified:</p>
<pre><code>>>> import urllib
>>> import re
>>> page = urllib.urlopen("http://google.com").read()
# => via regular expression
>>> re.findall("Shopping", page)
['Shopping']
# => via string.find, returns the position ...
>>> page.fi... | 1 | 2009-12-16T10:59:00Z | [
"python",
"http"
] |
How to open a webpage and search for a word in python | 1,913,871 | <p>How to open a webpage and search for a word in python?</p>
| 1 | 2009-12-16T10:53:13Z | 1,913,927 | <p>you can use urllib2</p>
<pre><code>import urllib2
webp=urllib2.urlopen("the_page").read()
webp.find("the_word")
</code></pre>
<p>hope that helps :D</p>
| 0 | 2009-12-16T11:02:18Z | [
"python",
"http"
] |
How to open a webpage and search for a word in python | 1,913,871 | <p>How to open a webpage and search for a word in python?</p>
| 1 | 2009-12-16T10:53:13Z | 1,914,679 | <p>How to open a webpage?</p>
<p>I think the most convinient way is:</p>
<pre><code>from urllib2 import urlopen
page = urlopen('http://www.example.com').read()
</code></pre>
<p>How to search for a word?</p>
<p>I guess you are going to search for some pattern in the page next, so here we go:</p>
<pre><code>import ... | 0 | 2009-12-16T13:34:06Z | [
"python",
"http"
] |
Django model ON DELETE CASCADE policy, emulate ON DELETE RESTRICT instead, general solution | 1,913,875 | <p>I'd like to delete an instance of a model, but only if it doesn't have any other instance of another class with a foreign key pointing to it. From Django documentation:</p>
<blockquote>
<p>When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other words, any object... | 3 | 2009-12-16T10:54:19Z | 1,915,015 | <p>Check the related objects length</p>
<pre><code>t=TestA.objects.get(name="textA1")
if not t.testB_set.all().count():#related members
t.delete()
</code></pre>
| 0 | 2009-12-16T14:33:53Z | [
"python",
"django",
"django-models"
] |
Django model ON DELETE CASCADE policy, emulate ON DELETE RESTRICT instead, general solution | 1,913,875 | <p>I'd like to delete an instance of a model, but only if it doesn't have any other instance of another class with a foreign key pointing to it. From Django documentation:</p>
<blockquote>
<p>When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other words, any object... | 3 | 2009-12-16T10:54:19Z | 1,927,008 | <p>I finally solved it using this <a href="http://stackoverflow.com/questions/681497/nullable-foreignkeys-and-deleting-a-referenced-model-instance">http://stackoverflow.com/questions/681497/nullable-foreignkeys-and-deleting-a-referenced-model-instance</a>, the solution looks like:</p>
<pre><code> # Check foreign ke... | 2 | 2009-12-18T08:28:57Z | [
"python",
"django",
"django-models"
] |
Django model ON DELETE CASCADE policy, emulate ON DELETE RESTRICT instead, general solution | 1,913,875 | <p>I'd like to delete an instance of a model, but only if it doesn't have any other instance of another class with a foreign key pointing to it. From Django documentation:</p>
<blockquote>
<p>When Django deletes an object, it emulates the behavior of the SQL constraint ON DELETE CASCADE -- in other words, any object... | 3 | 2009-12-16T10:54:19Z | 26,111,801 | <p>CollectedObjects() was removed in Django 1.3 -- here's a current method:</p>
<pre><code>from compiler.ast import flatten
from django.db import DEFAULT_DB_ALIAS
from django.contrib.admin.util import NestedObjects
def delete_obj_if_no_references(obj):
collector = NestedObjects(using=DEFAULT_DB_ALIAS)
collect... | 0 | 2014-09-30T02:26:23Z | [
"python",
"django",
"django-models"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,914,032 | <p>Here's what's interesting.</p>
<ul>
<li><p>Data Structure</p></li>
<li><p>Algorithm</p></li>
</ul>
<p>Those will yield dramatic improvements. </p>
<p>Your list is good for -- at best -- a few single-digit performance improvements.</p>
<p>You need to fundamentally rethink your data structures if you want to see ... | 4 | 2009-12-16T11:20:20Z | [
"python",
"performance"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,914,152 | <p>S.Lott is right: the big effects are data structures and algorithms. Also, if you are doing a lot of I/O, how you manage it will make a big difference.</p>
<p>But if you are curious about the compiler internals: it will fold constants, but it will not inline functions or unroll loops. Inlining functions is a hard ... | 6 | 2009-12-16T11:40:45Z | [
"python",
"performance"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,914,174 | <p>If you already know that your algorithm is as fast as possible, and you know that C would be much faster, then you may want to implement the core of your code in C as a <a href="http://nedbatchelder.com/text/whirlext.html" rel="nofollow">C extension to Python</a>. You can pragmatically decide which part of the code... | 4 | 2009-12-16T11:44:51Z | [
"python",
"performance"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,914,205 | <p>The speed of your code might be automatically improved by using the <a href="http://psyco.sourceforge.net/psycoguide/node8.html" rel="nofollow">Psyco</a> module.</p>
<p>As for Numpy, it generally speeds things up by a significant factor. I consider it a must when manipulating numerical arrays.</p>
<p>You might al... | 6 | 2009-12-16T11:50:37Z | [
"python",
"performance"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,915,951 | <p>Python's compiler is deliberately dirt-simple -- this makes it fast and highly predictable. Apart from some constant folding, it basically generates bytecode that faithfully mimics your sources. Somebody else already suggested <a href="http://docs.python.org/library/dis.html?highlight=dis#module-dis">dis</a>, and i... | 20 | 2009-12-16T16:40:18Z | [
"python",
"performance"
] |
Python performance characteristics | 1,913,906 | <p>I'm in the process of tuning a pet project of mine to improve its performance. I've already busted out the profiler to identify hotspots but I'm thinking understanding Pythons performance characteristics a little better would be quite useful going forward.</p>
<p>There are a few things I'd like to know:</p>
<h1>Ho... | 13 | 2009-12-16T10:58:41Z | 1,977,573 | <p>I'm the author of Arauna. I know nothing about Python, but I do know that Arauna is extremely optimized, both high level (data structures & algorithms) and low-level (cache friendly code, SIMD, multithreading). It's a hard target to go for...</p>
| 4 | 2009-12-29T23:30:39Z | [
"python",
"performance"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,305 | <p>How about subbing out the known text, and then splitting?</p>
<pre><code>import re
[re.sub('(sometxt|moretxt)', ',', x).split(',') for x in lst]
# results in
[['a', '0', ''], ['b', '1', ''], ['aa', '10', ''], ['zz', '999', '']]
</code></pre>
| -1 | 2009-12-16T12:14:44Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,385 | <p>I guess you should start by identifying substrings (patterns) that frequently occur in the strings. Since naively counting substrings in a set of strings is rather computationally expensive, you'll need to come up with something smart.</p>
<p>I've done substring counting on a large amount of data using <a href="htt... | 1 | 2009-12-16T12:30:30Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,391 | <p>Here is a scary one to get the ball rolling.</p>
<pre><code>>>> import re
>>> makere = lambda n: ''.join(['(.*?)(.+)(.*?)(.+)(.*?)'] + ['(.*)(\\2)(.*)(\\4)(.*)'] * (n - 1))
>>> inp = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
>>> re.matc... | 3 | 2009-12-16T12:31:44Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,394 | <p>This solution finds the two longest common substrings and uses them to delimit the input strings:</p>
<pre><code>def an_answer_to_stackoverflow_question_1914394(lst):
"""
>>> lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
>>> an_answer_to_st... | 4 | 2009-12-16T12:31:59Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,460 | <p>This look much like the <a href="http://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch" rel="nofollow">LZW</a> algorithm for data (text) compression. There should be python implementations out there, which you may be able to adapt to your need.</p>
<p>I assume you have no a priori knowledge of these sub str... | 1 | 2009-12-16T12:46:51Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
Python string pattern recognition/compression | 1,914,236 | <p>I can do basic regex alright, but this is slightly different, namely I don't know what the pattern is going to be.</p>
<p>For example, I have a list of similar strings:</p>
<pre><code>lst = ['asometxt0moretxt', 'bsometxt1moretxt', 'aasometxt10moretxt', 'zzsometxt999moretxt']
</code></pre>
<p>In this case the comm... | 7 | 2009-12-16T11:57:32Z | 1,914,471 | <p>This seems to be an example of the <a href="http://en.wikipedia.org/wiki/Longest%5Fcommon%5Fsubsequence%5Fproblem" rel="nofollow">longest common subsequence problem</a>. One way could be to look at how <a href="http://en.wikipedia.org/wiki/Diff" rel="nofollow">diffs</a> are generated. The <a href="http://en.wikipedi... | 2 | 2009-12-16T12:48:35Z | [
"python",
"string",
"compression",
"pattern-recognition"
] |
How can I use TOR as a proxy? | 1,914,254 | <p>I'm trying to use TOR as a generic proxy but it fails</p>
<p>Right now I'm trying with python but I'm pretty sure it would be the same with any other language. I can connect to other proxies with python so I get how it "should" be done.</p>
<p>I found a list of TOR entry nodes</p>
<pre><code>h = httplib.HTTPConne... | 2 | 2009-12-16T12:01:53Z | 1,914,332 | <p>First, make sure you are using the correct node location and port. Most proxies use ports other than 80. Second, specify the protocol to use with the correct URL on your request string.</p>
<p>Under normal circumstances, your code should work if it looks something like this one:</p>
<pre><code>h = httplib.HTTPConn... | 4 | 2009-12-16T12:19:47Z | [
"python",
"language-agnostic",
"proxy",
"tor",
"proxies"
] |
Pickling a staticmethod in Python | 1,914,261 | <p>I've been trying to pickle an object which contains references to static class methods.
Pickle fails (for example on <code>module.MyClass.foo</code>) stating it cannot be pickled, as <code>module.foo</code> does not exist.<br>
I have come up with the following solution, using a wrapper object to locate the function ... | 2 | 2009-12-16T12:03:46Z | 1,914,617 | <p>EDIT: modified after Jason comment.</p>
<p>I think python is correct in not letting pickling a staticmethod object - as it is impossible to pickle instance or class methods! Such an object would make very little sense outside of its context:</p>
<p>Check this: <a href="http://users.rcn.com/python/download/Descript... | 0 | 2009-12-16T13:19:31Z | [
"python",
"static-methods",
"pickle"
] |
Pickling a staticmethod in Python | 1,914,261 | <p>I've been trying to pickle an object which contains references to static class methods.
Pickle fails (for example on <code>module.MyClass.foo</code>) stating it cannot be pickled, as <code>module.foo</code> does not exist.<br>
I have come up with the following solution, using a wrapper object to locate the function ... | 2 | 2009-12-16T12:03:46Z | 1,914,798 | <p>This seems to work.</p>
<pre><code>class PickleableStaticMethod(object):
def __init__(self, fn, cls=None):
self.cls = cls
self.fn = fn
def __call__(self, *args, **kwargs):
return self.fn(*args, **kwargs)
def __get__(self, obj, cls):
return PickleableStaticMethod(self.fn, ... | 4 | 2009-12-16T13:57:50Z | [
"python",
"static-methods",
"pickle"
] |
Why there are not any real lightweight threads for python? | 1,914,341 | <p>I'm new to Python and seems that the multiprocessing and threads module are not very interesting and suffer from the same problems such as threads in Perl. Is there a technical reason why the interpreter can't use lightweight threads such as posix threads to make an efficient thread implementation that really runs o... | 9 | 2009-12-16T12:20:42Z | 1,914,362 | <p>It <em>is</em> using POSIX threads. The problem is the <a href="http://www.dabeaz.com/python/GIL.pdf" rel="nofollow">GIL</a>.</p>
<p>Note that the GIL is not part of the Python spec --- it's part of the CPython reference implementation. Jython, for example, does not suffer from this problem.</p>
<p>That said, look... | 22 | 2009-12-16T12:25:57Z | [
"python",
"multithreading",
"pthreads"
] |
Why there are not any real lightweight threads for python? | 1,914,341 | <p>I'm new to Python and seems that the multiprocessing and threads module are not very interesting and suffer from the same problems such as threads in Perl. Is there a technical reason why the interpreter can't use lightweight threads such as posix threads to make an efficient thread implementation that really runs o... | 9 | 2009-12-16T12:20:42Z | 1,916,822 | <p>Piotr,</p>
<p>You might want to take a look at stackless (<a href="http://www.stackless.com/" rel="nofollow">http://www.stackless.com/</a>) which is a modified version of python running lightweight tasklets in message passing (erlang style) fashion.</p>
<p>I'm not sure if you're looking for a multicore solution, b... | 0 | 2009-12-16T18:50:53Z | [
"python",
"multithreading",
"pthreads"
] |
What does Python's GIL have to do with the garbage collector? | 1,914,605 | <p>I just saw <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan#Global%5FInterpreter%5FLock" rel="nofollow">this section of Unladen Swallow's documentation</a> come up on Hacker News. Basically, it's the Google engineers saying that they're not optimistic about removing the GIL. However, it seems as ... | 10 | 2009-12-16T13:16:57Z | 1,914,762 | <p>The really short version is that currently python manages memory with a reference counting+a mark&sweep cycle collector scheme, optimized for latency (instead of throughput). </p>
<p>This is all fine when there is only a single mutating thread, but in a multi-threaded system, you need to synchronize all the tim... | 15 | 2009-12-16T13:51:19Z | [
"python",
"garbage-collection",
"gil",
"unladen-swallow"
] |
What does Python's GIL have to do with the garbage collector? | 1,914,605 | <p>I just saw <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan#Global%5FInterpreter%5FLock" rel="nofollow">this section of Unladen Swallow's documentation</a> come up on Hacker News. Basically, it's the Google engineers saying that they're not optimistic about removing the GIL. However, it seems as ... | 10 | 2009-12-16T13:16:57Z | 1,914,814 | <p>Tuna-Fish's answer basically covers it. If you want more details, there was a discussion about how the GIL could be removed without having <em>too</em> much of an effect on the reference counting here: <a href="http://mail.python.org/pipermail/python-ideas/2009-October/006264.html" rel="nofollow">http://mail.python... | 1 | 2009-12-16T14:01:03Z | [
"python",
"garbage-collection",
"gil",
"unladen-swallow"
] |
What does Python's GIL have to do with the garbage collector? | 1,914,605 | <p>I just saw <a href="http://code.google.com/p/unladen-swallow/wiki/ProjectPlan#Global%5FInterpreter%5FLock" rel="nofollow">this section of Unladen Swallow's documentation</a> come up on Hacker News. Basically, it's the Google engineers saying that they're not optimistic about removing the GIL. However, it seems as ... | 10 | 2009-12-16T13:16:57Z | 1,921,565 | <p>I just found another point of view on this subject here: <a href="http://renesd.blogspot.com/2009/12/python-gil-unladen-swallow-reference.html" rel="nofollow">http://renesd.blogspot.com/2009/12/python-gil-unladen-swallow-reference.html</a></p>
| 1 | 2009-12-17T12:50:09Z | [
"python",
"garbage-collection",
"gil",
"unladen-swallow"
] |
Alphabetizing functions in a Python class | 1,914,761 | <p>Warning, this is a sheer-laziness query! As my project develops, so also do the number of functions within a class. I also have a number of classes per .py file. So what I would like to do is re-sort them to that the function names are organised [sorry, UK here, I've already compromised hugely with the 'z' in Alphab... | 4 | 2009-12-16T13:51:00Z | 1,914,795 | <p>I don't have a solution to your question, but I have a very strong opinion: if the number of methods in your classes becomes so large you have trouble finding them, you should consider reducing the number, perhaps by splitting the class into smaller ones.</p>
<p>The same principles of cohesion that apply to functio... | 10 | 2009-12-16T13:57:11Z | [
"python",
"class",
"visualization",
"publishing",
"alphabetized"
] |
Alphabetizing functions in a Python class | 1,914,761 | <p>Warning, this is a sheer-laziness query! As my project develops, so also do the number of functions within a class. I also have a number of classes per .py file. So what I would like to do is re-sort them to that the function names are organised [sorry, UK here, I've already compromised hugely with the 'z' in Alphab... | 4 | 2009-12-16T13:51:00Z | 1,914,848 | <p>I am not sure sorting methods by name is such a great idea : </p>
<p>That's what you see when browsing OLE objects and it is really hard to understand anything as related methods are all over the place because they dont start by the same letter.</p>
<p>I'd rather see "open" just before "close", for example, withou... | 4 | 2009-12-16T14:06:47Z | [
"python",
"class",
"visualization",
"publishing",
"alphabetized"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.