title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
Can I damage the system by running time.sleep() with this newbie code in Python? | 1,169,185 | <p>Im sure there is a better way to do this, but I am quite the newbie so I did it the only way I could figure it out. The thing is, I have a script that updates a textfile with the newest posts from an RSS feed (I got some help from you guys to figure it out). But I want this script to be automated, so I made this:</p... | 1 | 2009-07-23T01:53:46Z | 1,169,195 | <p>Use xrange please, don't copying your code 24x times.</p>
<pre><code>for loop in xrange(240):
time.sleep(seconds)
os.system(kjor)
</code></pre>
<p>It will not damage your system, as far as I know.</p>
| 1 | 2009-07-23T01:57:53Z | [
"python",
"while-loop"
] |
Can I damage the system by running time.sleep() with this newbie code in Python? | 1,169,185 | <p>Im sure there is a better way to do this, but I am quite the newbie so I did it the only way I could figure it out. The thing is, I have a script that updates a textfile with the newest posts from an RSS feed (I got some help from you guys to figure it out). But I want this script to be automated, so I made this:</p... | 1 | 2009-07-23T01:53:46Z | 1,169,205 | <p>To answer your question, no, this won't hurt anything. While the time.sleeps are sleeping, the program will take very little processing power and the rest of the system can run normally.</p>
<p>Now, as for your looping issue. If you want the code run forever (or until you stop the program) the code you want is</p>
... | 9 | 2009-07-23T02:04:56Z | [
"python",
"while-loop"
] |
Can I damage the system by running time.sleep() with this newbie code in Python? | 1,169,185 | <p>Im sure there is a better way to do this, but I am quite the newbie so I did it the only way I could figure it out. The thing is, I have a script that updates a textfile with the newest posts from an RSS feed (I got some help from you guys to figure it out). But I want this script to be automated, so I made this:</p... | 1 | 2009-07-23T01:53:46Z | 1,169,288 | <p>It does not damage any system and it is pretty common as well.</p>
<p>Just create a loop so as your application will gently stop running after some time;
Or better yet, make it check for a condition, maybe listen to a tcp port waiting for someone to ask it to quit (then you'll need to create a second application t... | 1 | 2009-07-23T02:34:25Z | [
"python",
"while-loop"
] |
Python Wiki Style Doc Generator | 1,169,357 | <p>Looking for something like PyDoc that can generate a set of Wiki style pages vs the current HTML ones that export out of PyDoc. I would like to be able to export these in Google Code's Wiki as an extension to the current docs up there now.</p>
| 3 | 2009-07-23T02:55:40Z | 1,169,664 | <p>Take a look at pydoc.TextDoc. If this contains too little markup, you can inherit from it and make it generate markup according to your wiki's syntax.</p>
| 1 | 2009-07-23T04:49:58Z | [
"python",
"documentation",
"wiki"
] |
Python Wiki Style Doc Generator | 1,169,357 | <p>Looking for something like PyDoc that can generate a set of Wiki style pages vs the current HTML ones that export out of PyDoc. I would like to be able to export these in Google Code's Wiki as an extension to the current docs up there now.</p>
| 3 | 2009-07-23T02:55:40Z | 1,170,041 | <p>Have you taken a look at <a href="http://sphinx.pocoo.org/" rel="nofollow">Sphinx</a>?</p>
| 0 | 2009-07-23T06:51:10Z | [
"python",
"documentation",
"wiki"
] |
Rearrange equations for solver | 1,169,593 | <p>I am looking for a generic python way to manipulate text into solvable equations.</p>
<p>For example:</p>
<p>there may be some constants to initialize</p>
<pre><code>e1,e2=0.58,0.62
ma1,ma2=0.85,1.15
mw=0.8
Cpa,Cpw=1.023,4.193
dba,dbr=0.0,25.0
</code></pre>
<p>and a set of equations (written here for readability... | 1 | 2009-07-23T04:22:39Z | 1,169,643 | <p>If you don't want to write a parser for your own expression language, you can indeed try to use the Python syntax. Don't use the compiler module; instead, use some kind of abstract syntax. Since 2.5, you can use the _ast module:</p>
<pre><code>py> import _ast ... | 1 | 2009-07-23T04:41:15Z | [
"python",
"equation",
"solver"
] |
Rearrange equations for solver | 1,169,593 | <p>I am looking for a generic python way to manipulate text into solvable equations.</p>
<p>For example:</p>
<p>there may be some constants to initialize</p>
<pre><code>e1,e2=0.58,0.62
ma1,ma2=0.85,1.15
mw=0.8
Cpa,Cpw=1.023,4.193
dba,dbr=0.0,25.0
</code></pre>
<p>and a set of equations (written here for readability... | 1 | 2009-07-23T04:22:39Z | 1,181,358 | <p>Actually, I've implemented exactly the same thing in python. I'm also familiar with the Eureka and the other programs you mentioned. You can see my implementation at xyzsolve.appspot.com (Sorry for the shameless plug). The implementation is in all python. I'll list the iterations the code went through: </p>
<p>Iter... | 2 | 2009-07-25T06:17:07Z | [
"python",
"equation",
"solver"
] |
Comparing MD5s in Python | 1,169,717 | <p>For a programming exercise I designed for myself, and for use in a pretty non-secure system later on, I'm trying to compare MD5 hashes. The one that is stored in a plain text file and is pulled out by the <code>check_pw()</code> function and the one that is created from the submitted password from a CGI form. <code>... | 0 | 2009-07-23T05:14:31Z | 1,169,734 | <p>Your <code>pair[1]</code> probably has a trailing newline. Try:</p>
<pre><code>for line in f:
line = line.rstrip()
pair = line.split(":")
# ...etc
</code></pre>
| 2 | 2009-07-23T05:19:10Z | [
"python",
"md5"
] |
Comparing MD5s in Python | 1,169,717 | <p>For a programming exercise I designed for myself, and for use in a pretty non-secure system later on, I'm trying to compare MD5 hashes. The one that is stored in a plain text file and is pulled out by the <code>check_pw()</code> function and the one that is created from the submitted password from a CGI form. <code>... | 0 | 2009-07-23T05:14:31Z | 1,169,776 | <p>My guess is that there's an problem with the file loading/parsing, most likely caused by a newline character. By paring your code down, I was able to find that your logic was sound:</p>
<pre><code>def md5_pw(pw):
m = md5.new()
m.update("4hJ2Yq7qdHd9sdjFASh9"+pw)
return m.hexdigest()
def check_pw(pw):
... | 1 | 2009-07-23T05:31:55Z | [
"python",
"md5"
] |
Adding Values From Tuples of Same Length | 1,169,725 | <p>In a graphical program I'm writing using pygame I use a tuple representing a coordinate like this: (50, 50).</p>
<p>Sometimes, I call a function which returns another tuple such as (3, -5), which represents the change in coordinate.</p>
<p>What is the best way to add the change value to the coordinate value. It wo... | 10 | 2009-07-23T05:15:44Z | 1,169,738 | <p>My two cents, hope this helps</p>
<pre><code>>>> coord = (50, 50)
>>> change = (3, -5)
>>> tuple(sum(item) for item in zip(coord, change))
(53, 45)
</code></pre>
| 1 | 2009-07-23T05:20:34Z | [
"python"
] |
Adding Values From Tuples of Same Length | 1,169,725 | <p>In a graphical program I'm writing using pygame I use a tuple representing a coordinate like this: (50, 50).</p>
<p>Sometimes, I call a function which returns another tuple such as (3, -5), which represents the change in coordinate.</p>
<p>What is the best way to add the change value to the coordinate value. It wo... | 10 | 2009-07-23T05:15:44Z | 1,169,760 | <p>List comprehension is probably more readable, but here's another way:</p>
<pre><code>>>> a = (1,2)
>>> b = (3,4)
>>> tuple(map(sum,zip(a,b)))
(4,6)
</code></pre>
| 10 | 2009-07-23T05:26:00Z | [
"python"
] |
Adding Values From Tuples of Same Length | 1,169,725 | <p>In a graphical program I'm writing using pygame I use a tuple representing a coordinate like this: (50, 50).</p>
<p>Sometimes, I call a function which returns another tuple such as (3, -5), which represents the change in coordinate.</p>
<p>What is the best way to add the change value to the coordinate value. It wo... | 10 | 2009-07-23T05:15:44Z | 1,169,769 | <p>Well, one way would be</p>
<pre><code>coord = tuple(sum(x) for x in zip(coord, change))
</code></pre>
<p>If you are doing a lot of math, you may want to investigate using <a href="http://numpy.scipy.org/">NumPy</a>, which has much more powerful array support and better performance.</p>
| 13 | 2009-07-23T05:29:15Z | [
"python"
] |
Adding Values From Tuples of Same Length | 1,169,725 | <p>In a graphical program I'm writing using pygame I use a tuple representing a coordinate like this: (50, 50).</p>
<p>Sometimes, I call a function which returns another tuple such as (3, -5), which represents the change in coordinate.</p>
<p>What is the best way to add the change value to the coordinate value. It wo... | 10 | 2009-07-23T05:15:44Z | 1,169,959 | <p>This is a work in progress as I am learning Python myself. Can we use classes here, could simplify some operations later. I propose to use a coord class to store the coordinates. It would override add and sub so you could do addition and subtraction by simply using operators + and -. You could get the tuple represen... | 3 | 2009-07-23T06:29:15Z | [
"python"
] |
Adding Values From Tuples of Same Length | 1,169,725 | <p>In a graphical program I'm writing using pygame I use a tuple representing a coordinate like this: (50, 50).</p>
<p>Sometimes, I call a function which returns another tuple such as (3, -5), which represents the change in coordinate.</p>
<p>What is the best way to add the change value to the coordinate value. It wo... | 10 | 2009-07-23T05:15:44Z | 1,170,017 | <p>To get your "+" and "+=" behaviour you can define your own class and implement the <code>__add__()</code> method. The following is an incomplete sample:</p>
<pre><code># T.py
class T(object):
def __init__(self, *args):
self._t = args
def __add__(self, other):
return T(*([sum(x) for x in zip(... | 3 | 2009-07-23T06:41:13Z | [
"python"
] |
Bug with Python UTF-16 output and Windows line endings? | 1,169,742 | <p>With this code:</p>
<p><strong>test.py</strong></p>
<pre><code>import sys
import codecs
sys.stdout = codecs.getwriter('utf-16')(sys.stdout)
print "test1"
print "test2"
</code></pre>
<p>Then I run it as:</p>
<pre><code>test.py > test.txt
</code></pre>
<p>In Python 2.6 on Windows 2000, I'm finding that the n... | 2 | 2009-07-23T05:21:50Z | 1,169,911 | <p>The newline translation is happening inside the stdout file. You're writing "test1\n" to sys.stdout (a StreamWriter). StreamWriter translates this to "t\x00e\x00s\x00t\x001\x00\n\x00", and sends it to the real file, the original sys.stderr.</p>
<p>That file doesn't know that you've converted the data to UTF-16; a... | 3 | 2009-07-23T06:15:35Z | [
"python",
"windows",
"utf-16"
] |
Bug with Python UTF-16 output and Windows line endings? | 1,169,742 | <p>With this code:</p>
<p><strong>test.py</strong></p>
<pre><code>import sys
import codecs
sys.stdout = codecs.getwriter('utf-16')(sys.stdout)
print "test1"
print "test2"
</code></pre>
<p>Then I run it as:</p>
<pre><code>test.py > test.txt
</code></pre>
<p>In Python 2.6 on Windows 2000, I'm finding that the n... | 2 | 2009-07-23T05:21:50Z | 1,170,342 | <p>I've found two solutions so far, but not one that gives output of UTF-16 <strong>with</strong> Windows-style line endings.</p>
<p>First, to redirect Python <strong><code>print</code></strong> statements to a file with UTF-16 encoding (output Unix style line-endings):</p>
<pre><code>import sys
import codecs
sys.st... | 0 | 2009-07-23T08:07:41Z | [
"python",
"windows",
"utf-16"
] |
Bug with Python UTF-16 output and Windows line endings? | 1,169,742 | <p>With this code:</p>
<p><strong>test.py</strong></p>
<pre><code>import sys
import codecs
sys.stdout = codecs.getwriter('utf-16')(sys.stdout)
print "test1"
print "test2"
</code></pre>
<p>Then I run it as:</p>
<pre><code>test.py > test.txt
</code></pre>
<p>In Python 2.6 on Windows 2000, I'm finding that the n... | 2 | 2009-07-23T05:21:50Z | 1,170,469 | <p>Try this:</p>
<pre><code>import sys
import codecs
if sys.platform == "win32":
import os, msvcrt
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
class CRLFWrapper(object):
def __init__(self, output):
self.output = output
def write(self, s):
self.output.write(s.replace("\n", "\r\n"... | 3 | 2009-07-23T08:44:36Z | [
"python",
"windows",
"utf-16"
] |
Profiling Python Scripts running on Mod_wsgi | 1,169,833 | <p>How can I profile a python script running on mod_wsgi on apache</p>
<p>I would like to use cProfile but it seems it requires me to invoke a function manually. Is there a way to enable cProfile globally and have it keep on logging results. </p>
| 5 | 2009-07-23T05:52:07Z | 1,169,914 | <p>You need to wrap you wsgi application function inside another function that just calls your function using cProfile and use that as the application. Or you can reuse existing WSGI middleware to do that for you, for example <a href="http://repoze.org/repoze%5Fcomponents.html">repoze.profile</a> does pretty much what ... | 9 | 2009-07-23T06:16:45Z | [
"python",
"profiling",
"wsgi"
] |
Profiling Python Scripts running on Mod_wsgi | 1,169,833 | <p>How can I profile a python script running on mod_wsgi on apache</p>
<p>I would like to use cProfile but it seems it requires me to invoke a function manually. Is there a way to enable cProfile globally and have it keep on logging results. </p>
| 5 | 2009-07-23T05:52:07Z | 1,177,812 | <p>Here is the WSGI profile middleware for <a href="http://whiff.sourceforge.net" rel="nofollow">WHIFF</a> (currently only available from the mercurial repository):
<a href="http://aaron.oirt.rutgers.edu/cgi-bin/whiffRepo.cgi/file/3929e9c62c84/whiff/middleware/profile.py" rel="nofollow">profile.py</a>. That should get... | 0 | 2009-07-24T13:49:57Z | [
"python",
"profiling",
"wsgi"
] |
Python 2 CSV writer produces wrong line terminator on Windows | 1,170,214 | <p>According to the <a href="http://docs.python.org/library/csv.html#csv.Dialect.lineterminator">its documentation</a> csv.writer should use '\r\n' as lineterminator by default.</p>
<pre><code>import csv
with open("test.csv", "w") as f:
writer = csv.writer(f)
rows = [(0,1,2,3,4),
(-0,-1,-2,-3,-4),... | 31 | 2009-07-23T07:34:11Z | 1,170,297 | <p>In Python 2.x, always open your file in <strong>binary</strong> mode, as documented. <code>csv</code> writes <code>\r\n</code> as you expected, but then the underlying Windows text file mechanism cuts in and changes that <code>\n</code> to <code>\r\n</code> ... total effect: <code>\r\r\n</code></p>
<p>From the <a h... | 53 | 2009-07-23T07:53:18Z | [
"python",
"windows",
"csv",
"python-2.x",
"line-endings"
] |
Python 2 CSV writer produces wrong line terminator on Windows | 1,170,214 | <p>According to the <a href="http://docs.python.org/library/csv.html#csv.Dialect.lineterminator">its documentation</a> csv.writer should use '\r\n' as lineterminator by default.</p>
<pre><code>import csv
with open("test.csv", "w") as f:
writer = csv.writer(f)
rows = [(0,1,2,3,4),
(-0,-1,-2,-3,-4),... | 31 | 2009-07-23T07:34:11Z | 11,235,483 | <p>Unfortunately, it's a bit different with the csv module for Python 3, but this code will work on both Python 2 and Python 3:</p>
<pre><code>if sys.version_info >= (3,0,0):
f = open(filename, 'w', newline='')
else:
f = open(filename, 'wb')
</code></pre>
| 12 | 2012-06-27T22:08:27Z | [
"python",
"windows",
"csv",
"python-2.x",
"line-endings"
] |
Python 2 CSV writer produces wrong line terminator on Windows | 1,170,214 | <p>According to the <a href="http://docs.python.org/library/csv.html#csv.Dialect.lineterminator">its documentation</a> csv.writer should use '\r\n' as lineterminator by default.</p>
<pre><code>import csv
with open("test.csv", "w") as f:
writer = csv.writer(f)
rows = [(0,1,2,3,4),
(-0,-1,-2,-3,-4),... | 31 | 2009-07-23T07:34:11Z | 31,418,457 | <p>To change the line terminator in Python 2.7 csv writer use </p>
<p><code>writer = csv.writer(f, delimiter = '|', lineterminator='\n')</code></p>
<p>This is a much simpler way to change the default delimiter from \r\n.</p>
| 11 | 2015-07-14T22:24:24Z | [
"python",
"windows",
"csv",
"python-2.x",
"line-endings"
] |
Duplicate django query set? | 1,170,235 | <p>I have a simple django's query set like:</p>
<pre><code>qs = AModel.objects.exclude(state="F").order_by("order")
</code></pre>
<p>I'd like to use it as follows:</p>
<pre><code>qs[0:3].update(state='F')
expected = qs[3] # throws error here
</code></pre>
<p>But last statement throws:
"Cannot update a query once a ... | 1 | 2009-07-23T07:37:58Z | 1,170,288 | <p>It's the first line throwing the error: you can't do qs[0:3].update(). qs[0:3] is taking a slice; update() is updating the query.</p>
<p>update() is meant for bulk updates, resulting in SQL queries like</p>
<pre><code>UPDATE app_model SET state = 'F' WHERE state <> 'F';
</code></pre>
<p>You're trying to up... | 2 | 2009-07-23T07:51:07Z | [
"python",
"django",
"django-models"
] |
Duplicate django query set? | 1,170,235 | <p>I have a simple django's query set like:</p>
<pre><code>qs = AModel.objects.exclude(state="F").order_by("order")
</code></pre>
<p>I'd like to use it as follows:</p>
<pre><code>qs[0:3].update(state='F')
expected = qs[3] # throws error here
</code></pre>
<p>But last statement throws:
"Cannot update a query once a ... | 1 | 2009-07-23T07:37:58Z | 1,170,363 | <p>There have been some talks about making it possible to do slices of a queryset and then be able to use update on them before, but AFAIK there have never been made anything. I don't think you can copy a slice of a queryset, but in this case you wont need to. If your order is an unique integer, you would be able to do... | 0 | 2009-07-23T08:12:57Z | [
"python",
"django",
"django-models"
] |
Duplicate django query set? | 1,170,235 | <p>I have a simple django's query set like:</p>
<pre><code>qs = AModel.objects.exclude(state="F").order_by("order")
</code></pre>
<p>I'd like to use it as follows:</p>
<pre><code>qs[0:3].update(state='F')
expected = qs[3] # throws error here
</code></pre>
<p>But last statement throws:
"Cannot update a query once a ... | 1 | 2009-07-23T07:37:58Z | 2,529,522 | <p>You can do this:</p>
<p><code>qs = AModel.objects.filter(id__in=
AModel.objects.exclude(state="F").order_by("order")[10]).update()</code></p>
| 1 | 2010-03-27T13:58:50Z | [
"python",
"django",
"django-models"
] |
Problem running functions from a DLL file using ctypes in Object-oriented Python | 1,170,372 | <p>I sure hope this won't be an already answered question or a stupid one. Recently I've been programming with several instruments. Trying to communicate between them in order to create a testing program.
However I've encoutered some problems with one specific instrument when I'm trying to call functions that I've "mas... | 2 | 2009-07-23T08:16:38Z | 1,171,141 | <p>I'm not sure about your exact problem, but here's a couple general tips:</p>
<p>For those functions that you are calling outside of the constructor, I would strongly recommend setting their <a href="http://docs.python.org/library/ctypes.html#specifying-the-required-argument-types-function-prototypes" rel="nofollow"... | 1 | 2009-07-23T11:29:01Z | [
"python",
"dll",
"oop",
"automation",
"ctypes"
] |
Problem running functions from a DLL file using ctypes in Object-oriented Python | 1,170,372 | <p>I sure hope this won't be an already answered question or a stupid one. Recently I've been programming with several instruments. Trying to communicate between them in order to create a testing program.
However I've encoutered some problems with one specific instrument when I'm trying to call functions that I've "mas... | 2 | 2009-07-23T08:16:38Z | 1,171,533 | <p>Are any of the parameters in add-controller or add-tuner actually return values?</p>
<p>Strongly recommend that you define prototypes of your functions, rather than calling them direct with casts of all the parameters.</p>
<p><a href="http://docs.python.org/library/ctypes.html" rel="nofollow">I'm sure you've read ... | 0 | 2009-07-23T12:55:15Z | [
"python",
"dll",
"oop",
"automation",
"ctypes"
] |
Problem running functions from a DLL file using ctypes in Object-oriented Python | 1,170,372 | <p>I sure hope this won't be an already answered question or a stupid one. Recently I've been programming with several instruments. Trying to communicate between them in order to create a testing program.
However I've encoutered some problems with one specific instrument when I'm trying to call functions that I've "mas... | 2 | 2009-07-23T08:16:38Z | 1,226,235 | <p>I found out that the only way to call the functions in the exported DLL was to use the DLL through a parameter in each method. (the program exports the dll and in each method called it will send it as a parameter).
It looks pretty ugly but that's the only way I found to be working for me. I even tried exporting the ... | 0 | 2009-08-04T08:08:56Z | [
"python",
"dll",
"oop",
"automation",
"ctypes"
] |
How to create an optimized packing function in python? | 1,170,478 | <p>So I have been given the task to create a shipping module for a webshop system. It may be a bit overkill, but I would really like to create one that can figure out how to pack parcels in the most optimized way. Having learned programming simply by doing it, this is an area where I have no knowledge - yet! Anyways I ... | 15 | 2009-07-23T08:47:06Z | 1,170,498 | <p>Thatâs your typical <a href="http://en.wikipedia.org/wiki/Knapsack%5Fproblem">knapsack problem</a>. Many solutions for different languages can be found at <a href="http://www.rosettacode.org/wiki/Knapsack%5FProblem">Rosetta Code</a>.</p>
| 6 | 2009-07-23T08:53:19Z | [
"python",
"algorithm",
"optimization"
] |
How to create an optimized packing function in python? | 1,170,478 | <p>So I have been given the task to create a shipping module for a webshop system. It may be a bit overkill, but I would really like to create one that can figure out how to pack parcels in the most optimized way. Having learned programming simply by doing it, this is an area where I have no knowledge - yet! Anyways I ... | 15 | 2009-07-23T08:47:06Z | 1,170,541 | <p>This seems a good problem to which to apply <a href="http://en.wikipedia.org/wiki/Simplex%5Falgorithm" rel="nofollow">the simplex algorithm</a> or some sort of <a href="http://en.wikipedia.org/wiki/Genetic%5Falgorithm" rel="nofollow">genetic algorithm</a>. If you never heard of the latter, I highly recommend you to ... | 2 | 2009-07-23T09:04:43Z | [
"python",
"algorithm",
"optimization"
] |
How to create an optimized packing function in python? | 1,170,478 | <p>So I have been given the task to create a shipping module for a webshop system. It may be a bit overkill, but I would really like to create one that can figure out how to pack parcels in the most optimized way. Having learned programming simply by doing it, this is an area where I have no knowledge - yet! Anyways I ... | 15 | 2009-07-23T08:47:06Z | 1,177,246 | <p>The fact that you have height, length and width makes it harder than a simple knapsack problem. Here's an interesting discussion of a <a href="http://www.cirm.univ-mrs.fr/videos/2006/exposes/14/Thursday%20Morning/Diedrich.pdf">3D knapsack problem</a>.</p>
<p>Here's a <a href="http://books.google.com/books?id=mhrOkx... | 5 | 2009-07-24T12:05:02Z | [
"python",
"algorithm",
"optimization"
] |
need to create a .pem file | 1,170,700 | <p>What the <code>.pem</code> file contain? simply a key or a function which generate the key.</p>
<p>I need to create a <code>.pem</code> file and also need to call this file in a function.</p>
<p>here is code to which I have to proceed:</p>
<pre><code>pk = open( 'public_key.pem', 'rb' ).read()
rsa = M2Crypto.RSA.l... | 2 | 2009-07-23T09:48:31Z | 1,170,768 | <p>You can use <a href="http://www.openssl.org/" rel="nofollow">openssl</a> to create a pem file. You will need to supply it the correct parameters to get the correct type of key. The <a href="http://www.openssl.org/docs/apps/genpkey.html#" rel="nofollow">genkey</a> command of openssl looks like what you want to use.... | 1 | 2009-07-23T10:01:47Z | [
"python"
] |
need to create a .pem file | 1,170,700 | <p>What the <code>.pem</code> file contain? simply a key or a function which generate the key.</p>
<p>I need to create a <code>.pem</code> file and also need to call this file in a function.</p>
<p>here is code to which I have to proceed:</p>
<pre><code>pk = open( 'public_key.pem', 'rb' ).read()
rsa = M2Crypto.RSA.l... | 2 | 2009-07-23T09:48:31Z | 6,878,312 | <p>You can use this code to create a public key pair, then save them unencrypted to two files. </p>
<pre><code> from M2Crypto import RSA
key=RSA.gen_key(2048, 65537)
key.save_pem('./privkey',cipher=None)
key.save_pub_key('./pubkey')
</code></pre>
<p>To read it, do:</p>
<pre><code>rsa=RSA.load_pub_key(... | 1 | 2011-07-29T19:52:15Z | [
"python"
] |
How can I run telnet command in the python GUI? | 1,170,713 | <p>How can I run telnet command in the python GUI?</p>
| 0 | 2009-07-23T09:51:56Z | 1,170,750 | <p>Sounds like you need <a href="http://docs.python.org/library/telnetlib.html" rel="nofollow">telnetlib</a> </p>
| 2 | 2009-07-23T09:57:21Z | [
"python"
] |
How can I run telnet command in the python GUI? | 1,170,713 | <p>How can I run telnet command in the python GUI?</p>
| 0 | 2009-07-23T09:51:56Z | 1,172,218 | <p>You may also be interested in <a href="http://www.secdev.org/projects/scapy/" rel="nofollow">Scapy</a>, though it may be too low-level for what you want.</p>
| 0 | 2009-07-23T14:37:49Z | [
"python"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,758 | <p>The overloading of the constructor (or any other function) is not allowed in python. So you cannot define two <code>__init__</code> functions for your class.</p>
<p>You can have a look to <a href="http://stackoverflow.com/questions/312695/python-problem-with-overloaded-constructors">this post</a> or <a href="http:/... | 11 | 2009-07-23T09:58:54Z | [
"python",
"constructor"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,759 | <p>Define a single constructor with optional arguments.</p>
<pre><code>def __init__(self,host='host',usr='user',pwd='pwd',database='db',connection=None,sql=None,path=None):
if connection:
# however you want to store your connection
self.sql=sql
self.path=path
else:
self.host=host
self.usr.usr
... | 4 | 2009-07-23T09:59:19Z | [
"python",
"constructor"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,767 | <p>In Python the functions in a class are stored internally in a dictionary (remember that constructors are just regular functions), and so only one function of the same name can exist. Therefore, when defining more than one functions with the same name the last one will overwrite all the previously defined ones and yo... | 1 | 2009-07-23T10:01:44Z | [
"python",
"constructor"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,803 | <p>maybe you can use len() to choose the right branch:</p>
<pre><code>class Foo(object):
def __init__(self, *args):
if len(args) == 4: # network
self.host = args[0]
self.user = args[1]
self.pwd = args[2]
self.database = args[3]
elif len(args) == 3: # ... | 1 | 2009-07-23T10:10:15Z | [
"python",
"constructor"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,819 | <p>Here's one way to achieve this:</p>
<pre><code>class FileDetails:
def __init__(self, *args, **kwargs):
if len(args) == 3:
self.conn, self.sql, self.path = args
elif len(args) == 4:
self.host, self.usr, self.pw, self.db = args
else:
# handle appropriate... | 0 | 2009-07-23T10:13:41Z | [
"python",
"constructor"
] |
Error when using a Python constructor | 1,170,731 | <pre><code>class fileDetails :
def __init__(self,host,usr,pwd,database):
self.host=host
self.usr.usr
self.pwd=pwd
self.database=database
def __init__(self,connection,sql,path):
self.connection=mysql_connection()
self.sql=sql
self.path=path
</code></pre>
... | 1 | 2009-07-23T09:54:47Z | 1,170,820 | <p>On the side note: if you really, really, reallllllyyy must do JiP (Java in Python) then multiple dispatch methods <strong>are</strong> possible with some additional code eg. <a href="http://www.ibm.com/developerworks/library/l-pydisp.html" rel="nofollow">here</a> and even beter: <a href="http://www.artima.com/weblog... | 0 | 2009-07-23T10:13:46Z | [
"python",
"constructor"
] |
How do I get urllib2 to log ALL transferred bytes | 1,170,744 | <p>I'm writing a web-app that uses several 3rd party web APIs, and I want to keep track of the low level request and responses for ad-hock analysis. So I'm looking for a recipe that will get Python's urllib2 to log all bytes transferred via HTTP. Maybe a sub-classed Handler?</p>
| 18 | 2009-07-23T09:56:43Z | 1,181,585 | <p>Well, I've found how to setup the built-in debugging mechanism of the library:</p>
<pre><code>import logging, urllib2, sys
hh = urllib2.HTTPHandler()
hsh = urllib2.HTTPSHandler()
hh.set_http_debuglevel(1)
hsh.set_http_debuglevel(1)
opener = urllib2.build_opener(hh, hsh)
logger = logging.getLogger()
logger.addHandl... | 11 | 2009-07-25T08:22:36Z | [
"python",
"http",
"logging",
"urllib2"
] |
How do I get urllib2 to log ALL transferred bytes | 1,170,744 | <p>I'm writing a web-app that uses several 3rd party web APIs, and I want to keep track of the low level request and responses for ad-hock analysis. So I'm looking for a recipe that will get Python's urllib2 to log all bytes transferred via HTTP. Maybe a sub-classed Handler?</p>
| 18 | 2009-07-23T09:56:43Z | 1,844,608 | <p>This looks pretty tricky to do. There are no hooks in urllib2, urllib, or httplib (which this builds on) for intercepting either input or output data.</p>
<p>The only thing that occurs to me, other than switching tactics to use an external tool (of which there are many, and most people use such things), would be t... | 2 | 2009-12-04T03:11:00Z | [
"python",
"http",
"logging",
"urllib2"
] |
Unable to find the Python PIL library.Google App Engine | 1,170,898 | <p>Installed the Google App Engine SDK.Python 2.6 perfect.
Wanted to go into images, and test locally.Installed PIL</p>
<p>Installed Python, then ran the PIL install, worked this time.</p>
<p>Things seemed good, but trying to do localhost image manipulation
gives:
"NotImplementedError: Unable to find the Python PIL l... | 9 | 2009-07-23T10:31:42Z | 1,170,930 | <p>We're probably going to need more information, so here are some questions and things to try.</p>
<p>How are you trying to access the PIL? Are you trying to use the google.appengine.api.images module, or PIL directly? It sounds like the former, but it's not clear.</p>
<p>Did you follow <a href="http://code.google.c... | 2 | 2009-07-23T10:40:21Z | [
"python",
"google-app-engine",
"python-imaging-library"
] |
Unable to find the Python PIL library.Google App Engine | 1,170,898 | <p>Installed the Google App Engine SDK.Python 2.6 perfect.
Wanted to go into images, and test locally.Installed PIL</p>
<p>Installed Python, then ran the PIL install, worked this time.</p>
<p>Things seemed good, but trying to do localhost image manipulation
gives:
"NotImplementedError: Unable to find the Python PIL l... | 9 | 2009-07-23T10:31:42Z | 1,971,095 | <p>As far as I know Google AppEngine does not allow to use PIL directly, but instead provides a limited <a href="http://code.google.com/appengine/docs/python/images/overview.html" rel="nofollow">Images API</a>.</p>
<p>It can resize/rotate/crop and flip images. More or less what Picasaweb can do. But it cannot create ... | 4 | 2009-12-28T19:25:21Z | [
"python",
"google-app-engine",
"python-imaging-library"
] |
Unable to find the Python PIL library.Google App Engine | 1,170,898 | <p>Installed the Google App Engine SDK.Python 2.6 perfect.
Wanted to go into images, and test locally.Installed PIL</p>
<p>Installed Python, then ran the PIL install, worked this time.</p>
<p>Things seemed good, but trying to do localhost image manipulation
gives:
"NotImplementedError: Unable to find the Python PIL l... | 9 | 2009-07-23T10:31:42Z | 4,237,803 | <p>On Ubuntu with python2.5 the following helps:</p>
<p>new repo: ppa.launchpad.net/fkrull/deadsnakes/ubuntu</p>
<p>sudo apt-get install python2.5 python2.5-dev libjpeg62 libjpeg62-dev</p>
<p>untar: <a href="http://effbot.org/media/downloads/Imaging-1.1.6.tar.gz" rel="nofollow">http://effbot.org/media/downloads/Imag... | 3 | 2010-11-21T12:28:37Z | [
"python",
"google-app-engine",
"python-imaging-library"
] |
Unable to find the Python PIL library.Google App Engine | 1,170,898 | <p>Installed the Google App Engine SDK.Python 2.6 perfect.
Wanted to go into images, and test locally.Installed PIL</p>
<p>Installed Python, then ran the PIL install, worked this time.</p>
<p>Things seemed good, but trying to do localhost image manipulation
gives:
"NotImplementedError: Unable to find the Python PIL l... | 9 | 2009-07-23T10:31:42Z | 4,821,894 | <p>If you clear your GAE log window (assuming you're using the launcher) then restart your server, you might see something in the log. In my case I got</p>
<p><PRE>
WARNING 2011-01-27 21:04:11,856 dev_appserver.py:3698]
Could not initialize images API; you are likely missing the Python "PIL" module.
ImportErro... | 1 | 2011-01-27T21:08:13Z | [
"python",
"google-app-engine",
"python-imaging-library"
] |
Unable to find the Python PIL library.Google App Engine | 1,170,898 | <p>Installed the Google App Engine SDK.Python 2.6 perfect.
Wanted to go into images, and test locally.Installed PIL</p>
<p>Installed Python, then ran the PIL install, worked this time.</p>
<p>Things seemed good, but trying to do localhost image manipulation
gives:
"NotImplementedError: Unable to find the Python PIL l... | 9 | 2009-07-23T10:31:42Z | 14,057,571 | <p>I took a while to get PIL working. Mainly because I forgot to tell app engine to load it in the yaml file:</p>
<pre><code> libraries:
- name: PIL
version: 1.1.7
</code></pre>
<p>Maybe this step is obvious, but I did not see it documented well on google documentation and I found all kinds of messages h... | 5 | 2012-12-27T16:06:17Z | [
"python",
"google-app-engine",
"python-imaging-library"
] |
Fit algorithm does not accept my data | 1,170,962 | <p>I'm using the algorithm described <a href="http://www.scipy.org/Cookbook/FittingData" rel="nofollow">here</a> to fit Gaussian bell curves to my data.</p>
<p>If I generate my data array with:</p>
<pre><code>x=linspace(1.,100.,100)
data= 17*exp(-((x-10)/3)**2)
</code></pre>
<p>everything works fine.</p>
<p>But if ... | 0 | 2009-07-23T10:48:38Z | 1,171,090 | <p>The fit function expects the data as a numpy Array (which has a shape attribute) and not a list (which does not), hence the AttributeError.</p>
<p>Convert your data:</p>
<pre><code>def column(matrix,i):
return numpy.asarray([row[i] for row in matrix])
</code></pre>
| 4 | 2009-07-23T11:16:13Z | [
"python",
"arrays",
"file-io"
] |
Fit algorithm does not accept my data | 1,170,962 | <p>I'm using the algorithm described <a href="http://www.scipy.org/Cookbook/FittingData" rel="nofollow">here</a> to fit Gaussian bell curves to my data.</p>
<p>If I generate my data array with:</p>
<pre><code>x=linspace(1.,100.,100)
data= 17*exp(-((x-10)/3)**2)
</code></pre>
<p>everything works fine.</p>
<p>But if ... | 0 | 2009-07-23T10:48:38Z | 1,171,270 | <p>The solution of balpha is not correct; the solution is simply to convert my list to a numpy array via numpy.array.</p>
<p>Thanks for giving me a hint!</p>
| 4 | 2009-07-23T11:57:40Z | [
"python",
"arrays",
"file-io"
] |
How can I profile a SQLAlchemy powered application? | 1,171,166 | <p>Does anyone have experience profiling a Python/SQLAlchemy app? And what are the best way to find bottlenecks and design flaws?</p>
<p>We have a Python application where the database layer is handled by SQLAlchemy. The application uses a batch design, so a lot of database requests is done sequentially and in a limit... | 38 | 2009-07-23T11:33:39Z | 1,171,280 | <p>I have had some success in using cprofile and looking at the results in runsnakerun. This at least told me what functions and calls where taking a long time and if the database was the issue.
The documentation is <a href="http://www.vrplumber.com/programming/runsnakerun/" rel="nofollow">here</a>. You need wxpython.... | 3 | 2009-07-23T12:00:32Z | [
"python",
"sqlalchemy",
"profiler"
] |
How can I profile a SQLAlchemy powered application? | 1,171,166 | <p>Does anyone have experience profiling a Python/SQLAlchemy app? And what are the best way to find bottlenecks and design flaws?</p>
<p>We have a Python application where the database layer is handled by SQLAlchemy. The application uses a batch design, so a lot of database requests is done sequentially and in a limit... | 38 | 2009-07-23T11:33:39Z | 1,175,677 | <p>Sometimes just plain SQL logging (enabled via python's logging module or via the <code>echo=True</code> argument on <code>create_engine()</code>) can give you an idea how long things are taking. For example if you log something right after a SQL operation, you'd see something like this in your log:</p>
<pre><code>1... | 59 | 2009-07-24T03:54:46Z | [
"python",
"sqlalchemy",
"profiler"
] |
How can I profile a SQLAlchemy powered application? | 1,171,166 | <p>Does anyone have experience profiling a Python/SQLAlchemy app? And what are the best way to find bottlenecks and design flaws?</p>
<p>We have a Python application where the database layer is handled by SQLAlchemy. The application uses a batch design, so a lot of database requests is done sequentially and in a limit... | 38 | 2009-07-23T11:33:39Z | 8,428,546 | <p>There's an extremely useful profiling recipe on the <a href="http://www.sqlalchemy.org/trac/wiki/UsageRecipes/Profiling">SQLAlchemy wiki</a></p>
<p>With a couple of minor modifications,</p>
<pre><code>from sqlalchemy import event
from sqlalchemy.engine import Engine
import time
import logging
logging.basicConfig(... | 34 | 2011-12-08T09:06:54Z | [
"python",
"sqlalchemy",
"profiler"
] |
Change Flash source by Python | 1,171,170 | <p>I have flash with big image library inside, is there way to manipulate this content by python?</p>
| 1 | 2009-07-23T11:34:03Z | 1,171,291 | <p>Python Flash Tools intended to be a level up from the Ming SWF library and a step down from a Flash GUI see <a href="http://pyswftools.sourceforge.net/" rel="nofollow">http://pyswftools.sourceforge.net/</a></p>
| 0 | 2009-07-23T12:02:38Z | [
"python",
"flash"
] |
How to increase connection pool size for Twisted? | 1,171,519 | <p>I'm using Twisted 8.1.0 as socket server engine. Reactor - epoll. Database server is MySQL 5.0.67. OS - Ubuntu Linux 8.10 32-bit </p>
<p>in <code>/etc/mysql/my.cnf</code> :</p>
<pre><code>max_connections = 1000
</code></pre>
<p>in source code:</p>
<pre><code>adbapi.ConnectionPool("MySQLdb", ..., use_unico... | 3 | 2009-07-23T12:52:37Z | 1,175,408 | <p>As you suspect, this is probably a threading issue. <code>cp_max</code> sets an upper limit for the number of threads in the thread pool, however, your process is very likely running out of memory well below this limit, in your case around 200 threads. Because each thread has its own stack, the total memory being us... | 7 | 2009-07-24T01:38:48Z | [
"python",
"connection-pooling",
"twisted"
] |
How can I parse JSON in Google App Engine? | 1,171,584 | <p>I'd like to parse a JSON string into an object under Google App Engine (python). What do you recommend? Something to encode/stringify would be nice too. Is what you recommend built in, or a library that I have to include in my app? Is it secure? Thanks.</p>
| 77 | 2009-07-23T13:09:20Z | 1,171,620 | <p>Include the <a href="http://www.undefined.org/python/" rel="nofollow">simplejson</a> library with your app? </p>
| 6 | 2009-07-23T13:13:50Z | [
"python",
"json",
"google-app-engine"
] |
How can I parse JSON in Google App Engine? | 1,171,584 | <p>I'd like to parse a JSON string into an object under Google App Engine (python). What do you recommend? Something to encode/stringify would be nice too. Is what you recommend built in, or a library that I have to include in my app? Is it secure? Thanks.</p>
| 77 | 2009-07-23T13:09:20Z | 1,171,625 | <p>Look at the python section of <a href="http://json.org/" rel="nofollow">json.org</a>. The standard library support for JSON started at python 2.6, which I believe is newer than what the app engine provides. Maybe one of the other options listed?</p>
| 0 | 2009-07-23T13:14:54Z | [
"python",
"json",
"google-app-engine"
] |
How can I parse JSON in Google App Engine? | 1,171,584 | <p>I'd like to parse a JSON string into an object under Google App Engine (python). What do you recommend? Something to encode/stringify would be nice too. Is what you recommend built in, or a library that I have to include in my app? Is it secure? Thanks.</p>
| 77 | 2009-07-23T13:09:20Z | 1,171,631 | <p>If you're using Python2.6 or greater, I've used with success the built-in <a href="http://docs.python.org/library/json.html" rel="nofollow">json</a>.load function. Otherwise, <a href="http://code.google.com/p/simplejson/" rel="nofollow">simplejson</a> works on 2.4 without dependencies. </p>
| 1 | 2009-07-23T13:15:38Z | [
"python",
"json",
"google-app-engine"
] |
How can I parse JSON in Google App Engine? | 1,171,584 | <p>I'd like to parse a JSON string into an object under Google App Engine (python). What do you recommend? Something to encode/stringify would be nice too. Is what you recommend built in, or a library that I have to include in my app? Is it secure? Thanks.</p>
| 77 | 2009-07-23T13:09:20Z | 1,171,730 | <p>Consider using <a href="http://docs.djangoproject.com/en/dev/topics/serialization/">Django's json lib</a>, which is included with GAE.</p>
<pre><code>from django.utils import simplejson as json
# load the object from a string
obj = json.loads( string )
</code></pre>
<p>The link above has examples of Django's seri... | 111 | 2009-07-23T13:29:33Z | [
"python",
"json",
"google-app-engine"
] |
How can I parse JSON in Google App Engine? | 1,171,584 | <p>I'd like to parse a JSON string into an object under Google App Engine (python). What do you recommend? Something to encode/stringify would be nice too. Is what you recommend built in, or a library that I have to include in my app? Is it secure? Thanks.</p>
| 77 | 2009-07-23T13:09:20Z | 3,948,103 | <p>Google App Engine now supports python 2.7. If using python 2.7, you can do the following:</p>
<pre><code>import json
structured_dictionary = json.loads(string_received)
</code></pre>
| 18 | 2010-10-16T07:58:42Z | [
"python",
"json",
"google-app-engine"
] |
Trying to understand Django's sorl-thumbnail | 1,171,680 | <p>I have been playing around with <code>sorl-thumbnail</code> for Django. And trying to understand how it works better. </p>
<p>I've read the guide for it, installed it in my site-packages, made sure PIL is installed correctly, put <code>sorl.thumbnail</code> in the <code>INSTALLED APPS</code> in my <strong>settings.... | 6 | 2009-07-23T13:22:30Z | 1,232,375 | <p>I'm one of the sorl-thumbnail developers.</p>
<p>Firstly, you don't need to <code>{% load thumbnail %}</code> unless you're just using the thumbnail tag rather than a thumbnail field.</p>
<p>Currently, a thumbnail is only ever created the first time it is used - even if you use the field [I'll get around to changi... | 2 | 2009-08-05T10:29:15Z | [
"python",
"django",
"image-processing"
] |
Trying to understand Django's sorl-thumbnail | 1,171,680 | <p>I have been playing around with <code>sorl-thumbnail</code> for Django. And trying to understand how it works better. </p>
<p>I've read the guide for it, installed it in my site-packages, made sure PIL is installed correctly, put <code>sorl.thumbnail</code> in the <code>INSTALLED APPS</code> in my <strong>settings.... | 6 | 2009-07-23T13:22:30Z | 2,178,420 | <p>how about adding some jCrop in the admin to specify area of thumbnail ? Woul be pretty cool :) </p>
| 0 | 2010-02-01T16:51:31Z | [
"python",
"django",
"image-processing"
] |
Comparison of the multiprocessing module and pyro? | 1,171,767 | <p>I use <a href="http://pyro.sourceforge.net/">pyro</a> for basic management of parallel jobs on a compute cluster. I just moved to a cluster where I will be responsible for using all the cores on each compute node. (On previous clusters, each core has been a separate node.) The python <a href="http://docs.python.... | 8 | 2009-07-23T13:34:07Z | 1,955,757 | <p>EDIT: I'm changing my answer so you avoid pain. multiprocessing is immature, the docs on BaseManager are <strong>INCORRECT</strong>, and if you're an object-oriented thinker that wants to create shared objects on the fly at run-time, <strong>USE PYRO OR YOU WILL SERIOUSLY REGRET IT!</strong> If you are just doing ... | 14 | 2009-12-23T22:51:01Z | [
"python",
"rpc",
"multiprocessing",
"pyro"
] |
How to solve this complex recursive problem, pyramid point system | 1,171,926 | <p>I'm trying to program a pyramid like score system for an ARG game and have come up with a problem. When users get into the game they start a new "pyramid" but if one start the game with a referer code from another player they become a child of this user and then kick points up the ladder.</p>
<p>The issue here is n... | 1 | 2009-07-23T13:55:35Z | 1,171,993 | <p>I think your problem could be that you aren't setting the child(s) of <code>profile</code> to now have <code>parent</code> as it's/their parent, unless children with parents can't also be parents in your system (which I do not believe to be the case).</p>
<p>Alternatively (or possibly together with the previous), y... | 1 | 2009-07-23T14:04:13Z | [
"python",
"django",
"recursion"
] |
How to solve this complex recursive problem, pyramid point system | 1,171,926 | <p>I'm trying to program a pyramid like score system for an ARG game and have come up with a problem. When users get into the game they start a new "pyramid" but if one start the game with a referer code from another player they become a child of this user and then kick points up the ladder.</p>
<p>The issue here is n... | 1 | 2009-07-23T13:55:35Z | 1,172,115 | <p>[correction according to your comment]</p>
<p>If the result of the "move" never intends to change the topology of the tree(i.e. when X becomes the parent of its old parent Y, it gives all its children to Y), then the simplest might be to decouple the notion "pyramid nodes" from the "users", with one-to-one relation... | 1 | 2009-07-23T14:23:13Z | [
"python",
"django",
"recursion"
] |
django - circular import problem when executing a command | 1,172,386 | <p>I'm developing a django application. Modules of importance to my problem are given below:</p>
<p><strong>globals.py</strong> --> contains constants that are used throughout the application. <code>SITE_NAME</code> and <code>SITE_DOMAIN</code> are two of those and are used to fill some strings. Here is how I define t... | 2 | 2009-07-23T15:00:34Z | 1,172,453 | <p>Is there any particular reason you need to store SITE_DOMAIN and SITE_NAME in globals.py? These are already available directly from the sites framework.</p>
<p>According to <a href="http://docs.djangoproject.com/en/dev/ref/contrib/sites/?from=olddocs#caching-the-current-site-object" rel="nofollow">the docs</a>, th... | 1 | 2009-07-23T15:10:39Z | [
"python",
"django",
"import",
"circular-reference"
] |
Django-admin : How to display link to object info page instead of edit form , in records change list? | 1,172,584 | <p>I am customizing Django-admin for an application am working on . so
far the customization is working file , added some views . but I am
wondering how to change the records link in change_list display to
display an info page instead of change form ?!</p>
<p>in this blog post :<a href="http://www.theotherblog.com/Art... | 7 | 2009-07-23T15:26:41Z | 1,172,814 | <p>If I understand your question right you want to add your own link to the listing view, and you want that link to point to some info page you have created.</p>
<p>To do that, create a function to return the link HTML in your Admin object. Then use that function in your list. Like this:</p>
<pre><code>class ModelAdm... | 19 | 2009-07-23T16:04:54Z | [
"python",
"django",
"django-admin",
"admin"
] |
Django-admin : How to display link to object info page instead of edit form , in records change list? | 1,172,584 | <p>I am customizing Django-admin for an application am working on . so
far the customization is working file , added some views . but I am
wondering how to change the records link in change_list display to
display an info page instead of change form ?!</p>
<p>in this blog post :<a href="http://www.theotherblog.com/Art... | 7 | 2009-07-23T15:26:41Z | 1,172,841 | <p>Take a look at: <a href="http://docs.djangoproject.com/en/dev/ref/contrib/admin/">http://docs.djangoproject.com/en/dev/ref/contrib/admin/</a>, ModelAdmin.list_display part, it says: A string representing an attribute on the model. This behaves almost the same as the callable, but self in this context is the model in... | 7 | 2009-07-23T16:08:31Z | [
"python",
"django",
"django-admin",
"admin"
] |
Python file at GAE | 1,172,725 | <p>I have added a python file at google app engine. how to send a request to this file. Is this file needed to b executed explicitly?</p>
| 0 | 2009-07-23T15:49:49Z | 1,173,195 | <p>Your app.yaml file decides which python script to run, depending on the request URL.</p>
<p>See examples at the <a href="http://code.google.com/appengine/docs/python/config/appconfig.html" rel="nofollow">Google Docs</a>. You can even use regexp.</p>
| 2 | 2009-07-23T17:11:52Z | [
"python",
"google-app-engine"
] |
Tokenizing blocks of code in Python | 1,172,738 | <p>I have this string: </p>
<pre><code>[a [a b] [c e f] d]
</code></pre>
<p>and I want a list like this</p>
<pre><code>lst[0] = "a"
lst[1] = "a b"
lst[2] = "c e f"
lst[3] = "d"
</code></pre>
<p>My current implementation that I don't think is elegant/pythonic is two recursive functions (one splitting with '['
and th... | 1 | 2009-07-23T15:51:24Z | 1,172,764 | <p>Well, if it's a recursive data structure you're going to need a recursive function to cleanly navigate it.</p>
<p>But Python does have a tokenizer library which might be useful:
<a href="http://docs.python.org/library/tokenize.html" rel="nofollow">http://docs.python.org/library/tokenize.html</a></p>
| 1 | 2009-07-23T15:56:43Z | [
"python",
"regex",
"list-comprehension",
"tokenize"
] |
Tokenizing blocks of code in Python | 1,172,738 | <p>I have this string: </p>
<pre><code>[a [a b] [c e f] d]
</code></pre>
<p>and I want a list like this</p>
<pre><code>lst[0] = "a"
lst[1] = "a b"
lst[2] = "c e f"
lst[3] = "d"
</code></pre>
<p>My current implementation that I don't think is elegant/pythonic is two recursive functions (one splitting with '['
and th... | 1 | 2009-07-23T15:51:24Z | 1,172,898 | <p>Actually this really isn't a recursive data structure, note that <code>a</code> and <code>d</code> are in separate lists. You're just splitting the string over the bracket characters and getting rid of some white space.</p>
<p>I'm sure somebody can find something cleaner, but if you want a one-liner something like... | 4 | 2009-07-23T16:20:25Z | [
"python",
"regex",
"list-comprehension",
"tokenize"
] |
Tokenizing blocks of code in Python | 1,172,738 | <p>I have this string: </p>
<pre><code>[a [a b] [c e f] d]
</code></pre>
<p>and I want a list like this</p>
<pre><code>lst[0] = "a"
lst[1] = "a b"
lst[2] = "c e f"
lst[3] = "d"
</code></pre>
<p>My current implementation that I don't think is elegant/pythonic is two recursive functions (one splitting with '['
and th... | 1 | 2009-07-23T15:51:24Z | 1,173,033 | <p>If it's a recursive data structure, then recursion is good to traverse it. <em>However</em>, parsing the string to create the structure does not need to be recursive. One alternative way I would do it is iterative:</p>
<pre><code>origString = "[a [a b] [c [x z] d e] f]".split(" ")
stack = []
for element in origSt... | 1 | 2009-07-23T16:45:24Z | [
"python",
"regex",
"list-comprehension",
"tokenize"
] |
Connecting to APNS for iPhone Using Python | 1,172,769 | <p>I'm trying to send push notifications to an iPhone using Python. I've exported my <strong>certificate and private key</strong> into a p12 file from keychain access and then converted it into pem file using the following command:</p>
<pre><code>openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
</code></pre>
... | 12 | 2009-07-23T15:57:29Z | 1,173,457 | <p>Have you considered the <a href="http://twistedmatrix.com/trac/" rel="nofollow">Twisted</a> package? The below code is taken from <a href="http://blog.nuclearbunny.org/2009/05/11/connecting-to-apple-push-notification-services-using-python-twisted/" rel="nofollow">here</a>:</p>
<pre><code>from struct import pack
fr... | 2 | 2009-07-23T18:00:23Z | [
"iphone",
"python",
"ssl",
"push-notification"
] |
Connecting to APNS for iPhone Using Python | 1,172,769 | <p>I'm trying to send push notifications to an iPhone using Python. I've exported my <strong>certificate and private key</strong> into a p12 file from keychain access and then converted it into pem file using the following command:</p>
<pre><code>openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
</code></pre>
... | 12 | 2009-07-23T15:57:29Z | 1,254,027 | <p>I recently did this using Django - <a href="http://leecutsco.de/2009/07/14/push-on-the-iphone/" rel="nofollow">http://leecutsco.de/2009/07/14/push-on-the-iphone/</a></p>
<p>May be useful? It's making use of no extra libraries other than those included with Python already. Wouldn't take much to extract the send_mess... | 8 | 2009-08-10T09:58:26Z | [
"iphone",
"python",
"ssl",
"push-notification"
] |
Connecting to APNS for iPhone Using Python | 1,172,769 | <p>I'm trying to send push notifications to an iPhone using Python. I've exported my <strong>certificate and private key</strong> into a p12 file from keychain access and then converted it into pem file using the following command:</p>
<pre><code>openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
</code></pre>
... | 12 | 2009-07-23T15:57:29Z | 1,282,565 | <p>there were a few bugs in the originally posted code, so here's a corrected version that works for me.</p>
<pre><code>from struct import pack
from OpenSSL import SSL
from twisted.internet import reactor
from twisted.internet.protocol import ClientFactory, Protocol
from twisted.internet.ssl import ClientContextFactor... | 1 | 2009-08-15T18:59:00Z | [
"iphone",
"python",
"ssl",
"push-notification"
] |
Connecting to APNS for iPhone Using Python | 1,172,769 | <p>I'm trying to send push notifications to an iPhone using Python. I've exported my <strong>certificate and private key</strong> into a p12 file from keychain access and then converted it into pem file using the following command:</p>
<pre><code>openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
</code></pre>
... | 12 | 2009-07-23T15:57:29Z | 1,398,617 | <p>I tried both <code>APNSWrapper</code> and Lee Peckham's code and couldn't get it to work under Snow Leopard with Python 2.6. After a lot of trial and error it finally worked with <code>pyOpenSSL</code>. </p>
<p>I already did a post with details and code snippets <a href="http://ramin.firoozye.com/2009/09/09/push-no... | 0 | 2009-09-09T09:44:32Z | [
"iphone",
"python",
"ssl",
"push-notification"
] |
Connecting to APNS for iPhone Using Python | 1,172,769 | <p>I'm trying to send push notifications to an iPhone using Python. I've exported my <strong>certificate and private key</strong> into a p12 file from keychain access and then converted it into pem file using the following command:</p>
<pre><code>openssl pkcs12 -in cred.p12 -out cert.pem -nodes -clcerts
</code></pre>
... | 12 | 2009-07-23T15:57:29Z | 1,745,843 | <p>Try to update to latest APNSWrapper version (0.4). There is build-in support of openssl command line tool (openssl s_client) now.</p>
| 1 | 2009-11-17T00:33:04Z | [
"iphone",
"python",
"ssl",
"push-notification"
] |
Python Graphing Utility for GUI with Animations | 1,172,776 | <p>I am trying to create a GUI interface in VB to track... oh, nevermind.</p>
<p>Basically, I want to create a GUI in python to display data, but I am finding that mathplotlib is not suiting my needs. I would like to be able to highlight certain datapoints, have more freedom in the text drawn to the screen, have anima... | 4 | 2009-07-23T15:58:15Z | 1,172,978 | <p>QGraphicsScene/View from PyQt4 is a fantastic piece of code. Although your description makes me think that some upfront work will be necessary to make things work. </p>
<p>...don 't trust me, I'm biased ;) Get the library <a href="http://www.riverbankcomputing.co.uk/software/pyqt/download" rel="nofollow">here</a> a... | 0 | 2009-07-23T16:35:41Z | [
"python"
] |
Python Graphing Utility for GUI with Animations | 1,172,776 | <p>I am trying to create a GUI interface in VB to track... oh, nevermind.</p>
<p>Basically, I want to create a GUI in python to display data, but I am finding that mathplotlib is not suiting my needs. I would like to be able to highlight certain datapoints, have more freedom in the text drawn to the screen, have anima... | 4 | 2009-07-23T15:58:15Z | 1,173,117 | <p>The equivalent of matplotlib in the PyQt world is PyQwt (matplotlib integrates with PyQt also, but with PyQwt the integration is smoother). Take a look at this comparison between matplotlib and PyQwt:</p>
<p><a href="http://eli.thegreenplace.net/2009/06/05/plotting-in-python-matplotlib-vs-pyqwt/" rel="nofollow">htt... | 0 | 2009-07-23T16:58:50Z | [
"python"
] |
Python Graphing Utility for GUI with Animations | 1,172,776 | <p>I am trying to create a GUI interface in VB to track... oh, nevermind.</p>
<p>Basically, I want to create a GUI in python to display data, but I am finding that mathplotlib is not suiting my needs. I would like to be able to highlight certain datapoints, have more freedom in the text drawn to the screen, have anima... | 4 | 2009-07-23T15:58:15Z | 1,173,870 | <p>I haven't used it myself but <a href="http://code.enthought.com/projects/chaco/" rel="nofollow">Chaco</a> seems to fit some of your needs. It is more interactive than matplotlib and can be used to make quite interactive applications. </p>
<blockquote>
<p>Chaco is a Python plotting application toolkit that facili... | 2 | 2009-07-23T19:11:28Z | [
"python"
] |
Python Graphing Utility for GUI with Animations | 1,172,776 | <p>I am trying to create a GUI interface in VB to track... oh, nevermind.</p>
<p>Basically, I want to create a GUI in python to display data, but I am finding that mathplotlib is not suiting my needs. I would like to be able to highlight certain datapoints, have more freedom in the text drawn to the screen, have anima... | 4 | 2009-07-23T15:58:15Z | 6,274,686 | <p>PyQt + <a href="http://mathgl.sf.net/" rel="nofollow">MathGL</a> can do it easily. See this <a href="http://mathgl.sourceforge.net/mathgl_en/mathgl_en_15.html#MathGL-and-PyQt" rel="nofollow">sample</a>.</p>
| 0 | 2011-06-08T05:49:17Z | [
"python"
] |
Mismatch between MySQL and Python | 1,172,790 | <p><em>I know the mismatch between Object Oriented Technology and the Relational Technology, <a href="http://www.lalitbhatt.com/tiki-index.php?page=Introduction+to+ORM" rel="nofollow">generally here</a>.</em> </p>
<p>But I do not know the mismatch between MySQL and Python, and other tools, not just ORMs, to deal with ... | -1 | 2009-07-23T16:00:53Z | 1,173,052 | <p>ORM is the standard solution for making the object-oriented world of Python match the Relational world of MySQL.</p>
<p>There are at least 3 popular ORM components.</p>
<ul>
<li><p><a href="http://www.sqlalchemy.org/" rel="nofollow">SQLAlchemy</a></p></li>
<li><p><a href="http://www.sqlobject.org/" rel="nofollow">... | 3 | 2009-07-23T16:48:23Z | [
"python",
"mysql",
"google-app-engine",
"mismatch"
] |
Mismatch between MySQL and Python | 1,172,790 | <p><em>I know the mismatch between Object Oriented Technology and the Relational Technology, <a href="http://www.lalitbhatt.com/tiki-index.php?page=Introduction+to+ORM" rel="nofollow">generally here</a>.</em> </p>
<p>But I do not know the mismatch between MySQL and Python, and other tools, not just ORMs, to deal with ... | -1 | 2009-07-23T16:00:53Z | 1,177,910 | <p>As was once said on comp.lang.python ORM's are like morphine -- it can save you pain if you are really hurting, but if you use it regularly you will end up with really big problems.</p>
<p>It's not hard to build relatively low level interfaces between a relational database and an object model. It's extremely hard ... | 1 | 2009-07-24T14:04:49Z | [
"python",
"mysql",
"google-app-engine",
"mismatch"
] |
Python Server Pages Implementations | 1,173,184 | <p>I've been a PHP developer for quite awhile, and I've heard good things about using Python for web scripting. After a bit of research, I found mod_python, which integrates with Apache to allow Python Server Pages, which seem very similar to the PHP pages I'm used to. I also found a mod_wsgi which looks similar.</p>
... | 3 | 2009-07-23T17:09:22Z | 1,173,209 | <p>I believe <strong>mod_wsgi</strong> is the preferred option to mod_python:</p>
<p><a href="http://code.google.com/p/modwsgi/" rel="nofollow">http://code.google.com/p/modwsgi/</a></p>
<p>Some performance benchmarks seem to suggest that mod_wsgi performs much better also. </p>
<p><a href="http://code.google.com/p/... | 3 | 2009-07-23T17:13:52Z | [
"php",
"python",
"apache",
"mod-python"
] |
Does Python unittest report errors immediately? | 1,173,310 | <p>Does Python's unittest module always report errors in strict correspondence to the execution order of the lines in the code tested? Do errors create the possibility of unexpected changes into the code's variables?</p>
<p>I was baffled by a KeyError reported by unittest. The line itself looks okay. On the last li... | 1 | 2009-07-23T17:33:52Z | 1,173,664 | <p>I think you're seeing the error at the NEXT leg of your for loop, compared to the one with which you see all the output -- try changing the plain <code>print</code> to <code>print>>stderr,</code> statements so that buffering and possible suppression of output is not a risk.</p>
| 1 | 2009-07-23T18:33:36Z | [
"python",
"unit-testing",
"testing"
] |
python namespace hierarchy above object | 1,173,401 | <p>For example, if this code were contained in a module called some_module</p>
<pre><code>class C:
class C2:
def g(self):
@printNamespaceAbove
def f():
pass
</code></pre>
<p>then printNamespaceAbove would be defined so that this code would output something like</p>
... | 0 | 2009-07-23T17:50:57Z | 1,173,815 | <p>There is no way to make this code, as presented, have any output -- the body of g (including the decorator you'd like to do the printing) simply <em>DOESN'T</em> execute until g is called. I assume you do not literally intend for "this code" on its own to output anything, but rather intend to add a call such as C.C2... | 2 | 2009-07-23T19:00:41Z | [
"python",
"namespaces"
] |
Randomness in Jython | 1,173,520 | <p>When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class?</p>
| 8 | 2009-07-23T18:10:07Z | 1,173,613 | <p>Python's version is much faster in a simple test on my Mac:</p>
<pre><code>jython -m timeit -s "import random" "random.random()"
</code></pre>
<p>1000000 loops, best of 3: 0.266 usec per loop</p>
<p>vs</p>
<pre><code> jython -m timeit -s "import java.util.Random; random=java.util.Random()" "random.nextDouble()"
... | 9 | 2009-07-23T18:26:53Z | [
"java",
"python",
"random",
"jython"
] |
Randomness in Jython | 1,173,520 | <p>When using (pseudo) random numbers in Jython, would it be more efficient to use the Python random module or Java's random class?</p>
| 8 | 2009-07-23T18:10:07Z | 1,173,628 | <p>Java's Random class uses (and indeed must use by Java's specs) a linear congruential algorithm, while Python's uses Mersenne Twister. Mersenne guarantees extremely high quality (though not <em>crypto</em> quality!) random numbers and a ridiculously long period (53-bit precision floats, period 2**19937-1); linear co... | 4 | 2009-07-23T18:28:41Z | [
"java",
"python",
"random",
"jython"
] |
Wxpython: Positioning a menu under a toolbar button | 1,173,642 | <p>I have a CheckLabelTool in a wx.ToolBar and I want a menu to popup directly beneath it on mouse click. I'm trying to get the location of the tool so I can set the position of the menu, but everything I've tried (GetEventObject, GetPosition, etc) gives me the position of the toolbar, so consequently the menu pops un... | 4 | 2009-07-23T18:30:38Z | 1,175,271 | <p>Read the section on the <a href="http://www.wxpython.org/docs/api/wx.Window-class.html#PopupMenu">PopupMenu</a> method on wxpython.org:</p>
<blockquote>
<p>"Pops up the given menu at the
specified coordinates, relative to
this window, and returns control when
the user has dismissed the menu. If a
menu ite... | 6 | 2009-07-24T00:43:28Z | [
"python",
"menu",
"toolbar",
"wx"
] |
using pyunit on a network thread | 1,173,767 | <p>I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.</p>
<p>For example: The server it connects to could be on any port, an... | 2 | 2009-07-23T18:52:24Z | 1,173,880 | <p>It depends on how your network software is layered and how detailed you want your tests to be, but it's certainly feasible in some scenarios to make server setup and tear-down part of the test. For example, when I was working on the Python logging package (before it became part of Python), I had a test (I didn't use... | 0 | 2009-07-23T19:13:46Z | [
"python",
"unit-testing",
"networking",
"pyunit"
] |
using pyunit on a network thread | 1,173,767 | <p>I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.</p>
<p>For example: The server it connects to could be on any port, an... | 2 | 2009-07-23T18:52:24Z | 1,174,306 | <p>I've some test cases that run a server in the setUp and close it in the tearDown. I don't know if it is very elegant way to do it but it works of for me.</p>
<p>I am happy to have it and it helps me a lot. </p>
<p>If the server init is very long, an alternative would be to automate it with ant. ant would run/stop ... | 0 | 2009-07-23T20:34:18Z | [
"python",
"unit-testing",
"networking",
"pyunit"
] |
using pyunit on a network thread | 1,173,767 | <p>I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.</p>
<p>For example: The server it connects to could be on any port, an... | 2 | 2009-07-23T18:52:24Z | 1,174,498 | <p>I would try to introduce a factory into your existing code that purports to create socket objects. Then in a test pass in a mock factory which creates mock sockets which just pretend they've connected to a server (or not for error cases, which you also want to test, don't you?) and log the message traffic to prove ... | 1 | 2009-07-23T21:09:50Z | [
"python",
"unit-testing",
"networking",
"pyunit"
] |
using pyunit on a network thread | 1,173,767 | <p>I am tasked with writing unit tests for a suite of networked software written in python. Writing units for message builders and other static methods is very simple, but I've hit a wall when it comes to writing a tests for network looped threads.</p>
<p>For example: The server it connects to could be on any port, an... | 2 | 2009-07-23T18:52:24Z | 1,178,659 | <p>You would need to create mock sockets. The exact way to do that would depend on how you create sockets and creating a socket generator would be a good idea. You can also use a mocking library like <a href="http://code.google.com/p/pymox/" rel="nofollow">pymox</a> to make your life easier. It can also possibly elimin... | 0 | 2009-07-24T16:10:50Z | [
"python",
"unit-testing",
"networking",
"pyunit"
] |
Django (?) really slow with large datasets after doing some python profiling | 1,173,798 | <p>I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one.</p>
<p>First, some context: I have a page that spits out reports of sales data... | 5 | 2009-07-23T18:58:09Z | 1,173,991 | <p>There is a lot of things to assume about your problem as you don't have any type of code sample.</p>
<p>Here are my assumptions: You are using Django's built-in ORM tools and models (i.e. sales-data = modelobj.objects().all() ) and on the PHP side you are dealing with direct SQL queries and working with a query_set... | 6 | 2009-07-23T19:37:52Z | [
"python",
"django",
"optimization"
] |
Django (?) really slow with large datasets after doing some python profiling | 1,173,798 | <p>I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one.</p>
<p>First, some context: I have a page that spits out reports of sales data... | 5 | 2009-07-23T18:58:09Z | 1,175,178 | <p>"tokenize.py comes out on top, which can make some sense as I am doing a lot of number formatting. "</p>
<p>Makes no sense at all.</p>
<p>See <a href="http://docs.python.org/library/tokenize.html" rel="nofollow">http://docs.python.org/library/tokenize.html</a>.</p>
<blockquote>
<p>The tokenize module provides a... | 2 | 2009-07-24T00:08:42Z | [
"python",
"django",
"optimization"
] |
Django (?) really slow with large datasets after doing some python profiling | 1,173,798 | <p>I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one.</p>
<p>First, some context: I have a page that spits out reports of sales data... | 5 | 2009-07-23T18:58:09Z | 1,177,600 | <p>When dealing with large sets of data, you can also save a lot of CPU and memory by using the <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields" rel="nofollow">ValuesQuerySet</a> that accesses the query results more directly instead of creating a model object instance for each row in t... | 2 | 2009-07-24T13:19:01Z | [
"python",
"django",
"optimization"
] |
Django (?) really slow with large datasets after doing some python profiling | 1,173,798 | <p>I was comparing an old PHP script of mine versus the newer, fancier Django version and the PHP one, with full spitting out of HTML and all was functioning faster. MUCH faster to the point that something has to be wrong on the Django one.</p>
<p>First, some context: I have a page that spits out reports of sales data... | 5 | 2009-07-23T18:58:09Z | 1,200,171 | <p>In such a scenario the database is often the bottleneck. Also, using an ORM might result in sub-optimal SQL queries.</p>
<p>As some pointed out it's not possible to tell what the probem really is, just with the information you provided.</p>
<p>I just can give you some general advice:</p>
<ul>
<li>If your view is ... | 1 | 2009-07-29T13:14:55Z | [
"python",
"django",
"optimization"
] |
What is a basic example of single inheritance using the super() keyword in Python? | 1,173,992 | <p>Let's say I have the following classes set up:</p>
<pre><code>class Foo:
def __init__(self, frob, frotz):
self.frobnicate = frob
self.frotz = frotz
class Bar:
def __init__(self, frob, frizzle):
self.frobnicate = frob
self.frotz = 34
self.frazzle = frizzle
... | 22 | 2009-07-23T19:38:02Z | 1,174,118 | <p>Assuming you want class Bar to set the value 34 within its constructor, this would work:</p>
<pre><code>class Foo(object):
def __init__(self, frob, frotz):
self.frobnicate = frob
self.frotz = frotz
class Bar(Foo):
def __init__(self, frob, frizzle):
super(Bar, self).__init__(... | 28 | 2009-07-23T19:57:25Z | [
"python",
"inheritance",
"constructor",
"super"
] |
What is a basic example of single inheritance using the super() keyword in Python? | 1,173,992 | <p>Let's say I have the following classes set up:</p>
<pre><code>class Foo:
def __init__(self, frob, frotz):
self.frobnicate = frob
self.frotz = frotz
class Bar:
def __init__(self, frob, frizzle):
self.frobnicate = frob
self.frotz = 34
self.frazzle = frizzle
... | 22 | 2009-07-23T19:38:02Z | 1,174,124 | <p>In Python >=3.0, like this:</p>
<pre><code>class Foo():
def __init__(self, frob, frotz)
self.frobnicate = frob
self.frotz = frotz
class Bar(Foo):
def __init__(self, frob, frizzle)
super().__init__(frob, 34)
self.frazzle = frizzle
</code></pre>
<p>Read more here: <a href="ht... | 23 | 2009-07-23T19:58:31Z | [
"python",
"inheritance",
"constructor",
"super"
] |
appengine: cached reference property? | 1,174,075 | <p>How can I cache a Reference Property in Google App Engine?</p>
<p>For example, let's say I have the following models:</p>
<pre><code>class Many(db.Model):
few = db.ReferenceProperty(Few)
class Few(db.Model):
year = db.IntegerProperty()
</code></pre>
<p>Then I create many <code>Many</code>'s that point t... | 2 | 2009-07-23T19:51:30Z | 1,174,224 | <p>The question is:</p>
<ol>
<li>Will each access to many.few trigger a database lookup? Yes. Not sure if its 1 or 2 calls</li>
<li>If yes, is it possible to cache somewhere, as only one lookup should be enough to bring the same entity every time? You should be able to use the memcache repository to do this. This is i... | 1 | 2009-07-23T20:18:06Z | [
"python",
"database",
"performance",
"google-app-engine",
"gae-datastore"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.