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
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
213,572
<p>Consider reconsidering your design. Maintaining that much state in your webserver is probably a bad idea. Multi-process is a much better way to go for stability. </p> <p>Is there another way to share state between separate processes? What about a service? Database? Index? </p> <p>It seems unlikely that maintaining...
7
2008-10-17T19:35:04Z
[ "python", "apache", "webserver", "mod-python" ]
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
213,736
<p>Just to point out something different from the usual suspects...</p> <p>Some years ago while I was using <a href="http://zope.org/" rel="nofollow">Zope</a> 2.x I read about <a href="http://www.nightmare.com/medusa/medusa.html" rel="nofollow">Medusa</a> as it was the web server used for the platform. They advertised...
0
2008-10-17T20:31:57Z
[ "python", "apache", "webserver", "mod-python" ]
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
213,742
<p>Its hard to give a definitive answer without knowing what kind of site you are working on and what kind of load you are expecting. Sub second performance may be a serious requirement or it may not. If you really need to save that last millisecond then you absolutely need to keep your arrays in memory. However as ...
3
2008-10-17T20:34:06Z
[ "python", "apache", "webserver", "mod-python" ]
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
214,495
<p><a href="http://twistedmatrix.com/" rel="nofollow">Twisted</a> can serve as such a web server. While not multithreaded itself, there is a (not yet released) multithreaded WSGI container present in the current trunk. You can check out the SVN repository and then run:</p> <pre><code>twistd web --wsgi=your.wsgi.appl...
6
2008-10-18T03:32:42Z
[ "python", "apache", "webserver", "mod-python" ]
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
215,288
<p>I actually had the same issue recently. Namely: we wrote a simple server using BaseHTTPServer and found that the fact that it's not multi-threaded was a big drawback.</p> <p>My solution was to port the server to Pylons (<a href="http://pylonshq.com/" rel="nofollow">http://pylonshq.com/</a>). The port was fairly eas...
1
2008-10-18T17:04:14Z
[ "python", "apache", "webserver", "mod-python" ]
A good multithreaded python webserver?
213,483
<p>I am looking for a python webserver which is multithreaded instead of being multi-process (as in case of mod_python for apache). I want it to be multithreaded because I want to have an in memory object cache that will be used by various http threads. My webserver does a lot of expensive stuff and computes some large...
13
2008-10-17T19:12:38Z
215,292
<p>web.py has made me happy in the past. Consider checking it out.</p> <p>But it does sound like an architectural redesign might be the proper, though more expensive, solution.</p>
2
2008-10-18T17:12:17Z
[ "python", "apache", "webserver", "mod-python" ]
How to convert a C string (char array) into a Python string when there are non-ASCII characters in the string?
213,628
<p>I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8). How do I decode the contents of this char array into a Python string?</p> ...
7
2008-10-17T19:58:07Z
213,639
<p>You don't want to decode the string into a Unicode representation, you just want to treat it as an array of bytes, right?</p> <p>Just use <code>PyString_FromString</code>:</p> <pre><code>char *cstring; PyObject *pystring = PyString_FromString(cstring); </code></pre> <p>That's all. Now you have a Python <code>str...
3
2008-10-17T20:00:47Z
[ "python", "c", "character-encoding", "embedding" ]
How to convert a C string (char array) into a Python string when there are non-ASCII characters in the string?
213,628
<p>I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8). How do I decode the contents of this char array into a Python string?</p> ...
7
2008-10-17T19:58:07Z
213,795
<p>Try calling <a href="https://docs.python.org/c-api/exceptions.html" rel="nofollow"><code>PyErr_Print()</code></a> in the "<code>if (!py_string)</code>" clause. Perhaps the python exception will give you some more information.</p>
2
2008-10-17T20:47:20Z
[ "python", "c", "character-encoding", "embedding" ]
How to convert a C string (char array) into a Python string when there are non-ASCII characters in the string?
213,628
<p>I have embedded a Python interpreter in a C program. Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8). How do I decode the contents of this char array into a Python string?</p> ...
7
2008-10-17T19:58:07Z
215,507
<p>PyString_Decode does this:</p> <pre><code>PyObject *PyString_Decode(const char *s, Py_ssize_t size, const char *encoding, const char *errors) { PyObject *v, *str; str = PyString_FromStringAndSize(s, size); if (str == NULL) return NULL; v = PyString_AsDecodedString(str, e...
6
2008-10-18T19:59:25Z
[ "python", "c", "character-encoding", "embedding" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
213,810
<p>Python is well suited for these tasks, and I would guess much easier to develop in and debug than Windows batch files.</p> <p>The question is, I think, how easy and painless it is to ensure that all the computers that you have to run these scripts on, have Python installed.</p>
17
2008-10-17T20:50:57Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
213,812
<p>Are you aware of <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" rel="nofollow">PowerShell</a>?</p>
4
2008-10-17T20:51:13Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
213,820
<p>Sure, python is a pretty good choice for those tasks (I'm sure many will recommend PowerShell instead).</p> <p>Here is a fine introduction from that point of view:</p> <p><a href="http://www.redhatmagazine.com/2008/02/07/python-for-bash-scripters-a-well-kept-secret/">http://www.redhatmagazine.com/2008/02/07/python...
7
2008-10-17T20:54:39Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
213,827
<p>Python is certainly well suited to that. If you're going down that road, you might also want to investigate <a href="http://scons.org" rel="nofollow">SCons</a> which is a build system itself built with Python. The cool thing is the build scripts are actually full-blown Python scripts themselves, so you can do anythi...
2
2008-10-17T20:57:23Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
213,832
<p>Anything is a good replacement for the Batch file system in windows. Perl, Python, Powershell are all good choices.</p>
4
2008-10-17T20:59:11Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
214,287
<p>@BKB definitely has a valid concern. Here's a couple links you'll want to check if you run into any issues that can't be solved with the standard library:</p> <ul> <li><a href="http://sourceforge.net/projects/pywin32/">Pywin32</a> is a package for working with low-level win32 APIs (advanced file system modification...
5
2008-10-18T00:45:15Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
214,294
<p>I've been using a lot of <a href="http://msdn.microsoft.com/en-us/library/15x4407c.aspx" rel="nofollow">Windows Script Files</a> lately. More powerful than batch scripts, and since it uses Windows scripting, there's nothing to install.</p>
0
2008-10-18T00:47:48Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
214,333
<p>Python, along with <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">Pywin32</a>, would be fine for Windows automation. However, VBScript or JScript used with the Winows Scripting Host works just as well, and requires nothing additional to install.</p>
1
2008-10-18T01:14:20Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
214,412
<p>As much as I love python, I don't think it a good choice to replace basic windows batch scripts. </p> <p>I can't see see someone having to import modules like sys, os or getopt to do basic things you can do with shell like call a program, check environment variable or an argument.</p> <p>Also, in my experience, go...
-2
2008-10-18T02:12:40Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
214,428
<p>I've done a decent amount of scripting in both Linux/Unix and Windows environments, in Python, Perl, batch files, Bash, etc. My advice is that if it's possible, install Cygwin and use Bash (it sounds from your description like installing a scripting language or env isn't a problem?). You'll be more comfortable with ...
0
2008-10-18T02:27:51Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
216,285
<h2>Summary</h2> <p><strong>Windows</strong>: no need to think, use Python. <strong>Unix</strong>: quick or run-it-once scripts are for Bash, serious and/or long life time scripts are for Python.</p> <h2>The big talk</h2> <p>In a Windows environment, Python is definitely the best choice since <a href="http://en.wiki...
9
2008-10-19T11:14:49Z
[ "python", "command-line", "scripting" ]
Would Python make a good substitute for the Windows command-line/batch scripts?
213,798
<p>I've got some experience with <a href="http://en.wikipedia.org/wiki/Bash_%28Unix_shell%29">Bash</a>, which I don't mind, but now that I'm doing a lot of Windows development I'm needing to do basic stuff/write basic scripts using the Windows command-line language. For some reason said language really irritates me, s...
20
2008-10-17T20:48:26Z
496,964
<p>As a follow up, after some experimentation the thing I've found Python most useful for is any situation involving text manipulation (yourStringHere.replace(), regexes for more complex stuff) or testing some basic concept really quickly, which it is excellent for.</p> <p>For stuff like SQL DB restore scripts I find ...
1
2009-01-30T19:52:36Z
[ "python", "command-line", "scripting" ]
How to improve Trac's performance
213,838
<p>I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).</p> <p><strong>Setup Info:</strong> This is via a SELinux system hosted by WebFaction. It is behind Apache, and ...
3
2008-10-17T21:02:43Z
214,162
<p>It's hard to say without knowing more about your setup, but one easy win is to make sure that Trac is running in something like <code>mod_python</code>, which keeps the Python runtime in memory. Otherwise, every HTTP request will cause Python to run, import all the modules, and then finally handle the request. Using...
5
2008-10-17T23:19:49Z
[ "python", "performance", "trac" ]
How to improve Trac's performance
213,838
<p>I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).</p> <p><strong>Setup Info:</strong> This is via a SELinux system hosted by WebFaction. It is behind Apache, and ...
3
2008-10-17T21:02:43Z
215,084
<p>We've had the best luck with FastCGI. Another critical factor was to only use <code>https</code> for authentication but use <code>http</code> for all other traffic -- I was really surprised how much that made a difference.</p>
3
2008-10-18T14:13:36Z
[ "python", "performance", "trac" ]
How to improve Trac's performance
213,838
<p>I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).</p> <p><strong>Setup Info:</strong> This is via a SELinux system hosted by WebFaction. It is behind Apache, and ...
3
2008-10-17T21:02:43Z
636,060
<p>Serving the chrome files statically with and expires-header could help too. See the end of <a href="http://bannister.us/weblog/2007/07/23/example-of-configuring-trac-and-subversion-on-ubuntu/" rel="nofollow">this page</a>.</p>
1
2009-03-11T19:48:30Z
[ "python", "performance", "trac" ]
How to improve Trac's performance
213,838
<p>I have noticed that my particular instance of Trac is not running quickly and has big lags. This is at the very onset of a project, so not much is in Trac (except for plugins and code loaded into SVN).</p> <p><strong>Setup Info:</strong> This is via a SELinux system hosted by WebFaction. It is behind Apache, and ...
3
2008-10-17T21:02:43Z
806,271
<p>I have noticed that if </p> <pre><code>select disctinct name from wiki </code></pre> <p>takes more than 5 seconds (for example due to a million rows in this table - this is a true story (We had a script that filled it)), browsing wiki pages becomes very slow and takes over <code>2*t*n</code>, where <code>t</code> ...
2
2009-04-30T10:13:03Z
[ "python", "performance", "trac" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,149
<p>It shouldn't be too hard if you have the answer <a href="http://stackoverflow.com/questions/213901/in-perl-how-do-i-process-input-as-soon-as-it-arrives-instead-of-waiting-for-new">this question</a>.</p> <p>(Essentially, read one character at a time and if it's a hash, print it. If it isn't a hash, save the charact...
1
2008-10-17T23:12:53Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,186
<p>Ah, forget it. This is too much of a pain. It was a lot easier to get the source to ngrep and make it print the hash marks to stderr:</p> <pre><code>--- ngrep.c 2006-11-28 05:38:43.000000000 -0800 +++ ngrep.c.new 2008-10-17 16:28:29.000000000 -0700 @@ -687,8 +687,7 @@ } if (quiet &lt; 1) { - p...
3
2008-10-17T23:30:24Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,198
<p>This is easy in python.</p> <pre><code>#!/usr/bin/env python import sys, re keyword = 'RED' while 1: c = sys.stdin.read(1) if not c: break if c in '#\n': sys.stdout.write(c) else: sys.stdout.write( (c+sys.stdin.readline()).replace( keyword, '\x1b[31m...
0
2008-10-17T23:40:02Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,557
<p>You could also pipe the output through <a href="http://petdance.com/ack/" rel="nofollow">ack</a>. The --passthru flag will help.</p>
3
2008-10-18T04:13:42Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,635
<p>See the script at <a href="http://www.mail-archive.com/linux-il@cs.huji.ac.il/msg52876.html" rel="nofollow">this post to Linux-IL where someone asked a similar question</a>. It's written in Perl and uses the CPAN Term::ANSIColor module.</p>
-1
2008-10-18T05:30:13Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
214,782
<p>This seems to do the trick, at least comparing two windows, one running a straight ngrep (e.g. ngrep whatever) and one being piped into the following program (with ngrep whatever | ngrephl target-string).</p> <pre><code>#! /usr/bin/perl use strict; use warnings; $| = 1; # autoflush on my $keyword = shift or die ...
4
2008-10-18T08:57:37Z
[ "python", "perl", "unix", "networking" ]
How can I write a wrapper around ngrep that highlights matches?
214,059
<p>I just learned about <a href="http://ngrep.sourceforge.net/" rel="nofollow">ngrep</a>, a cool program that lets you easily sniff packets that match a particular string.</p> <p>The only problem is that it can be hard to see the match in the big blob of output. I'd like to write a wrapper script to highlight these ma...
2
2008-10-17T22:32:58Z
513,068
<p>why not just call ngrep with the -q parameter to eliminate the hash marks?</p>
0
2009-02-04T20:08:55Z
[ "python", "perl", "unix", "networking" ]
Using trellis as a framework for managing UI interaction rules
214,430
<p>Does anyone have experience with <a href="http://pypi.python.org/pypi/Trellis" rel="nofollow">trellis</a>? Looking at it as a framework for defining rules for field interaction and validation in grids and data entry screens.</p>
1
2008-10-18T02:29:02Z
3,280,594
<p>It seems this project has died. No new stuff to the page has been added to it since your question. Also I think that new language features in Python 2.6 and Python 3 are removing the need of some of the offered constructs.</p>
1
2010-07-19T11:23:55Z
[ "python", "user-interface" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
214,665
<p>I personally found <a href="http://www.cheetahtemplate.org/" rel="nofollow">Cheetah templates</a> to be very designer-friendly. What needed some time was the idea of templates subclassing, and this was something hard to get at the beginning. But a designer creates a full template, duplicating his code... Then you ca...
2
2008-10-18T06:14:20Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
214,666
<p><a href="http://docs.djangoproject.com/en/dev/topics/templates/#topics-templates" rel="nofollow">Django's templating engine</a> is quite decent. It's pretty robust while not stepping on too many toes. If you're working with Python I would recommend it. I don't know how to divorce it from Django, but I doubt it wo...
6
2008-10-18T06:14:36Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
214,932
<p>Look at <a href="http://www.makotemplates.org/">Mako</a>.</p> <p>Here's how I cope with web designers.</p> <ol> <li>Ask them to mock up the page. In HTML.</li> <li>Use the HTML as the basis for the template, replacing the mocked-up content with <code>${...}</code> replacements.</li> <li>Fold in loops to handle re...
5
2008-10-18T11:35:15Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
214,956
<p>I had good votes when <a href="http://stackoverflow.com/questions/98245/what-is-your-single-favorite-python-templating-engine#98285">answering this same question's duplicate</a>.</p> <p>My answer was:</p> <p><a href="http://jinja.pocoo.org/2">Jinja2</a>.</p> <p>Nice <a href="http://jinja.pocoo.org/2/documentation...
6
2008-10-18T12:00:40Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
214,972
<p>Mi vote goes to <a href="http://www.clearsilver.net/" rel="nofollow">Clearsilver</a>, it is the template engine used in Trac before 0.11, it's also used in pages like Google Groups or Orkut. The main benefits of this template engine is that it's very fast and language-independent.</p>
1
2008-10-18T12:25:04Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
215,300
<p>To add to @Jaime Soriano's comment, <a href="http://genshi.edgewall.org/" rel="nofollow">Genshi</a> is the template engine used in Trac post- 0.11. It's can be used as a generic templating solution, but has a focus on HTML/XHTML. It has automatic escaping for reducing XSS vulnerabilities.</p>
2
2008-10-18T17:24:16Z
[ "python", "templating" ]
Python templates for web designers
214,536
<p>What are some good templating engines for web designers? I definitely have my preferences as to what I'd prefer to work with as a programmer. But web designers seem to have a different way of thinking about things and thus may prefer a different system.</p> <p>So:</p> <ul> <li>Web designers: what templating eng...
5
2008-10-18T03:56:06Z
215,700
<p>I've played both roles and at heart I prefer more of a programmer's templating language. However, I freelance for a few graphic designers doing the "heavy lifting" backed and db programming and can tell you that I've had the best luck with XML templating languages (SimpleTAL, Genshi, etc). </p> <p>When I'm trying t...
1
2008-10-18T23:16:03Z
[ "python", "templating" ]
How to create a numpy record array from C
214,549
<p>On the Python side, I can create new numpy record arrays as follows:</p> <pre><code>numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')]) </code></pre> <p>How do I do the same from a C program? I suppose I have to call <code>PyArray_SimpleNewFromDescr(nd, dims, descr)</code>, but how do I construct a <code>PyArray_...
7
2008-10-18T04:03:35Z
214,574
<p>See the <a href="http://csc.ucdavis.edu/~chaos/courses/nlp/Software/NumPyBook.pdf" rel="nofollow">Guide to NumPy</a>, section 13.3.10. There's lots of different ways to make a descriptor, although it's not nearly as easy as writing <code>[('a', 'i4'), ('b', 'U5')]</code>.</p>
4
2008-10-18T04:33:02Z
[ "python", "c", "numpy" ]
How to create a numpy record array from C
214,549
<p>On the Python side, I can create new numpy record arrays as follows:</p> <pre><code>numpy.zeros((3,), dtype=[('a', 'i4'), ('b', 'U5')]) </code></pre> <p>How do I do the same from a C program? I suppose I have to call <code>PyArray_SimpleNewFromDescr(nd, dims, descr)</code>, but how do I construct a <code>PyArray_...
7
2008-10-18T04:03:35Z
215,090
<p>Use <code>PyArray_DescrConverter</code>. Here's an example:</p> <pre><code>#include &lt;Python.h&gt; #include &lt;stdio.h&gt; #include &lt;numpy/arrayobject.h&gt; int main(int argc, char *argv[]) { int dims[] = { 2, 3 }; PyObject *op, *array; PyArray_Descr *descr; Py_Initialize(); import...
8
2008-10-18T14:19:14Z
[ "python", "c", "numpy" ]
How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
18
2008-10-18T08:53:02Z
214,786
<pre><code>&gt;&gt;&gt; import time &gt;&gt;&gt; timestamp = "2008-09-26T01:51:42.000Z" &gt;&gt;&gt; ts = time.strptime(timestamp[:19], "%Y-%m-%dT%H:%M:%S") &gt;&gt;&gt; time.strftime("%m/%d/%Y", ts) '09/26/2008' </code></pre> <p>See the documentation of the Python <a href="http://python.org/doc/2.5/lib/module-time.ht...
14
2008-10-18T09:01:59Z
[ "python", "datetime" ]
How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
18
2008-10-18T08:53:02Z
215,083
<p><code>2008-09-26T01:51:42.000Z</code> is an ISO8601 date and the format can be very diverse. If you want to parse these dates see the python wiki on <a href="http://wiki.python.org/moin/WorkingWithTime" rel="nofollow">working with time</a>. It contains some useful links to modules.</p>
2
2008-10-18T14:13:19Z
[ "python", "datetime" ]
How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
18
2008-10-18T08:53:02Z
215,313
<p>The easiest way is to use <a href="http://labix.org/python-dateutil">dateutil</a>.parser.parse() to parse the date string into a timezone aware datetime object, then use strftime() to get the format you want.</p> <pre><code>import datetime, dateutil.parser d = dateutil.parser.parse('2008-09-26T01:51:42.000Z') prin...
24
2008-10-18T17:33:30Z
[ "python", "datetime" ]
How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
18
2008-10-18T08:53:02Z
2,904,561
<pre><code>def datechange(datestr): dateobj=datestr.split('-') y=dateobj[0] m=dateobj[1] d=dateobj[2] datestr=d +'-'+ m +'-'+y return datestr </code></pre> <p>U can make a function like this which take date object andd returns you date in desired dateFormat....</p>
0
2010-05-25T12:32:41Z
[ "python", "datetime" ]
How do you convert YYYY-MM-DDTHH:mm:ss.000Z time format to MM/DD/YYYY time format in Python?
214,777
<p>For example, I'm trying to convert 2008-09-26T01:51:42.000Z to 09/26/2008. What's the simplest way of accomplishing this?</p>
18
2008-10-18T08:53:02Z
39,155,014
<p>I know this is really old question, but you can do it with python datetime.strptime()</p> <pre><code>&gt;&gt;&gt; from datetime import datetime &gt;&gt;&gt; date_format = "%Y-%m-%dT%H:%M:%S.%fZ" &gt;&gt;&gt; datetime.strptime('2008-09-26T01:51:42.000Z', date_format) datetime.datetime(2008, 9, 26, 1, 51, 42) </code...
1
2016-08-25T21:30:54Z
[ "python", "datetime" ]
python module dlls
214,852
<p>Is there a way to make a python module load a dll in my application directory rather than the version that came with the python installation, without making changes to the python installation (which would then require I made an installer, and be careful I didn't break other apps for people by overwrting python modul...
11
2008-10-18T10:17:58Z
214,855
<p>If your version of sqlite is in sys.path <em>before</em> the systems version it will use that. So you can either put it in the current directory or change the <code>PYTHONPATH</code> environment variable to do that.</p>
0
2008-10-18T10:20:18Z
[ "python", "module" ]
python module dlls
214,852
<p>Is there a way to make a python module load a dll in my application directory rather than the version that came with the python installation, without making changes to the python installation (which would then require I made an installer, and be careful I didn't break other apps for people by overwrting python modul...
11
2008-10-18T10:17:58Z
214,868
<p>If you're talking about Python module DLLs, then simply modifying <code>sys.path</code> should be fine. However, if you're talking about DLLs <em>linked</em> against those DLLs; i.e. a <code>libfoo.dll</code> which a <code>foo.pyd</code> depends on, then you need to modify your PATH environment variable. I wrote a...
14
2008-10-18T10:33:08Z
[ "python", "module" ]
python module dlls
214,852
<p>Is there a way to make a python module load a dll in my application directory rather than the version that came with the python installation, without making changes to the python installation (which would then require I made an installer, and be careful I didn't break other apps for people by overwrting python modul...
11
2008-10-18T10:17:58Z
214,901
<p>Ok it terns out python always loads the dll in the same directory as the pyd file, regardless of what the python and os paths are set to.</p> <p>So I needed to copy the _sqlite3.pyd from python/v2.5/DLLS to my apps directory where the new sqlite3.dll is, making it load my new dll, rather than the one that comes wit...
5
2008-10-18T11:04:43Z
[ "python", "module" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
214,902
<p>Ten years ago you couldn't, and I doubt that's changed. However, it wasn't that hard to modify the syntax back then if you were prepared to recompile python, and I doubt that's changed, either.</p>
0
2008-10-18T11:10:15Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
214,910
<p>Short of changing and recompiling the source code (which <em>is</em> possible with open source), changing the base language is not really possible.</p> <p>Even if you do recompile the source, it wouldn't be python, just your hacked-up changed version which you need to be very careful not to introduce bugs into.</p>...
12
2008-10-18T11:16:45Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
214,912
<p>Not without modifying the interpreter. I know a lot of languages in the past several years have been described as "extensible", but not in the way you're describing. You extend Python by adding functions and classes.</p>
2
2008-10-18T11:18:17Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
215,042
<p>I've found a guide on adding new statements, converted from PDF to HTML by Google:</p> <p><a href="http://209.85.173.104/search?q=cache:IjUb82taSq0J:www.troeger.eu/teaching/pythonvm08lab.pdf+python+add+statement&amp;hl=en&amp;ct=clnk&amp;cd=10">http://209.85.173.104/search?q=cache:IjUb82taSq0J:www.troeger.eu/teachi...
5
2008-10-18T13:26:37Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
215,697
<p>One way to do things like this is to preprocess the source and modify it, translating your added statement to python. There are various problems this approach will bring, and I wouldn't recommend it for general usage, but for experimentation with language, or specific-purpose metaprogramming, it can occassionally b...
44
2008-10-18T23:15:04Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
216,174
<p>There is a language based on python called <a href="http://www.livelogix.net/logix/" rel="nofollow">Logix</a> with which you CAN do such things. It hasn't been under development for a while, but the features that you asked for <b>do work</b> with the latest version. </p>
2
2008-10-19T08:36:50Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
216,795
<p>Yes, to some extent it is possible. There is a <a href="http://entrian.com/goto/">module</a> out there that uses <code>sys.settrace()</code> to implement <code>goto</code> and <code>comefrom</code> "keywords":</p> <pre><code>from goto import goto, label for i in range(1, 10): for j in range(1, 20): print i, j...
15
2008-10-19T18:52:00Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
217,373
<p>It's possible to do this using <a href="http://www.fiber-space.de/EasyExtend/doc/EE.html" rel="nofollow">EasyExtend</a>:</p> <blockquote> <p>EasyExtend (EE) is a preprocessor generator and metaprogramming framework written in pure Python and integrated with CPython. The main purpose of EasyExtend is the c...
3
2008-10-20T02:29:20Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
220,857
<p>General answer: you need to preprocess your source files. </p> <p>More specific answer: install <a href="http://pypi.python.org/pypi/EasyExtend">EasyExtend</a>, and go through following steps</p> <p>i) Create a new langlet ( extension language )</p> <pre><code>import EasyExtend EasyExtend.new_langlet("mystmts", p...
10
2008-10-21T05:26:58Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
4,572,994
<p>Here's a very simple but crappy way to add new statements, <em>in interpretive mode only</em>. I'm using it for little 1-letter commands for editing gene annotations using only sys.displayhook, but just so I could answer this question I added sys.excepthook for the syntax errors as well. The latter is really ugly, f...
7
2011-01-01T02:23:19Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
9,108,164
<p>You may find this useful - <a href="http://eli.thegreenplace.net/2010/06/30/python-internals-adding-a-new-statement-to-python/">Python internals: adding a new statement to Python</a>, quoted here:</p> <hr> <p>This article is an attempt to better understand how the front-end of Python works. Just reading documentat...
77
2012-02-02T06:39:44Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
27,841,742
<p>Some things can be done with decorators. Let's e.g. assume, Python had no <code>with</code> statement. We could then implement a similar behaviour like this: </p> <pre><code># ====== Implementation of "mywith" decorator ====== def mywith(stream): def decorator(function): try: function(stream) f...
1
2015-01-08T13:53:13Z
[ "python", "syntax" ]
Can you add new statements to Python's syntax?
214,881
<p>Can you add new statements (like <code>print</code>, <code>raise</code>, <code>with</code>) to Python's syntax?</p> <p>Say, to allow..</p> <pre><code>mystatement "Something" </code></pre> <p>Or,</p> <pre><code>new_if True: print "example" </code></pre> <p>Not so much if you <em>should</em>, but rather if it...
72
2008-10-18T10:47:21Z
31,151,217
<p>It's not exactly adding new statements to the language syntax, but macros are a powerful tool: <a href="https://github.com/lihaoyi/macropy" rel="nofollow">https://github.com/lihaoyi/macropy</a></p>
1
2015-07-01T01:34:23Z
[ "python", "syntax" ]
Efficient Image Thumbnail Control for Python?
215,052
<p>What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user. </p>
3
2008-10-18T13:36:15Z
215,175
<p>If you had to resort to writing your own, I've had good results using the Python Imaging Library to create thumbnails in the past. <a href="http://www.pythonware.com/products/pil/" rel="nofollow">http://www.pythonware.com/products/pil/</a></p>
1
2008-10-18T15:40:32Z
[ "python", "image", "wxpython", "pyqt", "thumbnails" ]
Efficient Image Thumbnail Control for Python?
215,052
<p>What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user. </p>
3
2008-10-18T13:36:15Z
215,257
<p>In <a href="http://wxpython.org/" rel="nofollow">wxPython</a> you can use <a href="http://docs.wxwidgets.org/stable/wx_wxgrid.html#wxgrid" rel="nofollow">wxGrid</a> for this as it supports virtual mode and custom cell renderers.</p> <p><a href="http://docs.wxwidgets.org/stable/wx_wxgridtablebase.html#wxgridtablebas...
2
2008-10-18T16:48:04Z
[ "python", "image", "wxpython", "pyqt", "thumbnails" ]
Efficient Image Thumbnail Control for Python?
215,052
<p>What is the best choice for a Python GUI application to display large number of thumbnails, e.g. 10000 or more? For performance reasons such thumbnail control must support virtual items, i.e. request application for those thumbnails only which are currently visible to user. </p>
3
2008-10-18T13:36:15Z
455,191
<p>Just for completeness: there is a <a href="http://xoomer.alice.it/infinity77/main/freeware.html#thumbnailctrl" rel="nofollow">thumbnailCtrl</a> written in/for wxPython, which might be a good starting point.</p>
1
2009-01-18T14:10:15Z
[ "python", "image", "wxpython", "pyqt", "thumbnails" ]
wxpython - Expand list control vertically not horizontally
215,132
<p>I have a ListCtrl that displays a list of items for the user to select. This works fine except that when the ctrl is not large enough to show all the items, I want it to expand downwards with a vertical scoll bar rather than using a horizontal scroll bar as it expands to the right.</p> <p>The ListCtrl's creation:</...
2
2008-10-18T15:02:48Z
215,216
<p>Use the <a href="http://docs.wxwidgets.org/stable/wx_wxlistctrl.html#wxlistctrl" rel="nofollow">wxLC_REPORT</a> style.</p> <pre><code>import wx class Test(wx.Frame): def __init__(self): wx.Frame.__init__(self, None) self.test = wx.ListCtrl(self, style = wx.LC_REPORT | wx.LC_NO_HEADER) ...
3
2008-10-18T16:18:05Z
[ "python", "wxpython", "wxwidgets" ]
wxpython - Expand list control vertically not horizontally
215,132
<p>I have a ListCtrl that displays a list of items for the user to select. This works fine except that when the ctrl is not large enough to show all the items, I want it to expand downwards with a vertical scoll bar rather than using a horizontal scroll bar as it expands to the right.</p> <p>The ListCtrl's creation:</...
2
2008-10-18T15:02:48Z
215,335
<p>Try this:</p> <pre><code>import wx class Test(wx.Frame): def __init__(self): wx.Frame.__init__(self, None) self.test = wx.ListCtrl(self, style = wx.LC_ICON | wx.LC_AUTOARRANGE) for i in range(100): self.test.InsertStringItem(self.test.GetItemCount(), str(i)) self.S...
1
2008-10-18T17:53:14Z
[ "python", "wxpython", "wxwidgets" ]
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache T...
1
2008-10-18T16:51:02Z
215,298
<p>That should be fixed in 0.11 according to their <a href="http://trac.edgewall.org/ticket/7320" rel="nofollow">bug tracking system</a>. </p> <p>If that's not the case you should try to pass the environment var to apache, since doing a SetEnv in the configuration file doesn't work. Adding something like </p> <pre><c...
3
2008-10-18T17:19:00Z
[ "python", "configuration", "trac", "python-egg-cache" ]
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache T...
1
2008-10-18T16:51:02Z
215,303
<p>I ran into the same problem when upgrading from Trac 10.4 to 0.11 earlier this year. Something must have changed for this problem to have just suddenly appeared -- an updated Python or Apache installation?</p> <p>I don't remember all of the permutations I tried to solve this, but I ended up having to use <code>SetE...
0
2008-10-18T17:25:16Z
[ "python", "configuration", "trac", "python-egg-cache" ]
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache T...
1
2008-10-18T16:51:02Z
215,401
<p>I have wrestled many a battle with <code>PYTHON_EGG_CACHE</code> and I never figured out the correct way of setting it - apache's envvars, httpd.conf (SetEnv and PythonOption), nothing worked. In the end I just unpacked all python eggs manually, there were only two or three anyway - problem gone. I never understood ...
1
2008-10-18T18:40:52Z
[ "python", "configuration", "trac", "python-egg-cache" ]
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache T...
1
2008-10-18T16:51:02Z
219,233
<p>I had the same problem. In my case the directory wasn't there so I created and chown'ed it over to the apache user (apache on my centos 4.3 box). Then made sure it had read-write permissions on the directory. You could get by with giving rw rights to the directory if the group that owns the directory contains the...
0
2008-10-20T17:28:49Z
[ "python", "configuration", "trac", "python-egg-cache" ]
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,267
<p>We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in:</p> <pre> PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache T...
1
2008-10-18T16:51:02Z
406,119
<p>I found that using the PythonOption directive in the site config <em>did not</em> work, but SetEnv did. The environment variable route will also work though.</p>
0
2009-01-02T05:39:07Z
[ "python", "configuration", "trac", "python-egg-cache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
215,546
<p>This is the ultimate Apache configurator:</p> <p><a href="http://perl.apache.org/" rel="nofollow">http://perl.apache.org/</a></p> <p>exposes many if not all Apache internals to programs written in Perl.</p> <p>For instance: <a href="http://perl.apache.org/docs/2.0/api/Apache2/Directive.html" rel="nofollow">http:/...
2
2008-10-18T20:47:04Z
[ "java", "python", "perl", "apache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
215,552
<p>Rather than manipulate the config files, you can use <a href="http://perl.apache.org/" rel="nofollow">mod_perl</a> to embed Perl directly into the config files. This could allow you, for example, to read required vhosts out of a database.</p> <p>See <a href="http://perl.apache.org/start/tips/config.html" rel="nofo...
7
2008-10-18T20:52:03Z
[ "java", "python", "perl", "apache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
215,652
<p>Try the <a href="http://search.cpan.org/~nwiger/Apache-ConfigFile-1.18/ConfigFile.pm" rel="nofollow">Apache::ConfigFile Perl module</a>.</p>
2
2008-10-18T22:21:13Z
[ "java", "python", "perl", "apache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
215,695
<p>In Perl, you've got at least 2 modules for that:</p> <p><a href="http://search.cpan.org/~nwiger/Apache-ConfigFile-1.18/ConfigFile.pm" rel="nofollow">Apache::ConfigFile</a></p> <p><a href="https://metacpan.org/pod/Apache%3a%3aAdmin%3a%3aConfig" rel="nofollow">Apache::Admin::Config</a> </p>
7
2008-10-18T23:13:14Z
[ "java", "python", "perl", "apache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
215,932
<p>Look at <a href="http://augeas.net/" rel="nofollow">Augeas</a>, it's not specifically for Apache-httpd config. files it's just a generic config. file "editor" API. One of it's major selling points is that it will keep comments/etc. is happy for other tools to alter the files and will refuse to let you save broken fi...
3
2008-10-19T03:02:08Z
[ "java", "python", "perl", "apache" ]
What's a good library to manipulate Apache2 config files?
215,542
<p>I'd like to create a script to manipulate Apache2 configuration directly, reading and writing its properties (like adding a new VirtualHost, changing settings of one that already exists).</p> <p>Are there any libs out there, for Perl, Python or Java that automates that task?</p>
7
2008-10-18T20:38:57Z
217,879
<p>Also see <a href="http://search.cpan.org/perldoc?Config::General" rel="nofollow">Config::General</a>, which claims to be fully compatible with Apache configuration files. I use it to parse my Apache configuration files for automatic regression testing after configuration changes.</p>
0
2008-10-20T09:26:09Z
[ "java", "python", "perl", "apache" ]
What's the difference between a parent and a reference property in Google App Engine?
215,570
<p>From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID comp...
10
2008-10-18T21:12:07Z
215,902
<p>The only purpose of entity groups (defined by the parent attribute) is to enable transactions among different entities. If you don't need the transactions, don't use the entity group relationships.</p> <p>I suggest you re-reading the <a href="http://code.google.com/appengine/docs/datastore/keysandentitygroups.html"...
8
2008-10-19T02:23:47Z
[ "python", "api", "google-app-engine" ]
What's the difference between a parent and a reference property in Google App Engine?
215,570
<p>From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID comp...
10
2008-10-18T21:12:07Z
216,187
<p>There are several differences:</p> <ul> <li>All entities with the same ancestor are in the same entity group. Transactions can only affect entities inside a single entity group.</li> <li>All writes to a single entity group are serialized, so throughput is limited.</li> <li>The parent entity is set on creation and i...
15
2008-10-19T08:56:43Z
[ "python", "api", "google-app-engine" ]
What is the purpose of the colon before a block in Python?
215,581
<p>What is the purpose of the colon before a block in Python?</p> <p>Example:</p> <pre><code>if n == 0: print "The end" </code></pre>
44
2008-10-18T21:18:46Z
215,676
<p>The colon is there to declare the start of an indented block.</p> <p>Technically, it's not necessary; you could just indent and de-indent when the block is done. However, based on the <a href="http://www.python.org/dev/peps/pep-0020/">Python koan</a> “explicit is better than implicit” (EIBTI), I believe that Gu...
56
2008-10-18T22:49:32Z
[ "python", "syntax" ]
What is the purpose of the colon before a block in Python?
215,581
<p>What is the purpose of the colon before a block in Python?</p> <p>Example:</p> <pre><code>if n == 0: print "The end" </code></pre>
44
2008-10-18T21:18:46Z
216,060
<p>Three reasons:</p> <ol> <li>To increase readability. The colon helps the code flow into the following indented block.</li> <li>To help text editors/IDEs, they can automatically indent the next line if the previous line ended with a colon.</li> <li>To make parsing by python slightly easier.</li> </ol>
12
2008-10-19T05:40:07Z
[ "python", "syntax" ]
What is the purpose of the colon before a block in Python?
215,581
<p>What is the purpose of the colon before a block in Python?</p> <p>Example:</p> <pre><code>if n == 0: print "The end" </code></pre>
44
2008-10-18T21:18:46Z
1,464,645
<p>Consider the following list of things to buy from the grocery store, written in Pewprikanese.</p> <pre><code>pewkah lalala chunkykachoo pewpewpew skunkybacon </code></pre> <p>When I read that, I'm confused, Are chunkykachoo and pewpewpew a kind of lalala? Or what if chunkykachoo and pewpewpew are indented ...
15
2009-09-23T08:13:16Z
[ "python", "syntax" ]
What is the purpose of the colon before a block in Python?
215,581
<p>What is the purpose of the colon before a block in Python?</p> <p>Example:</p> <pre><code>if n == 0: print "The end" </code></pre>
44
2008-10-18T21:18:46Z
3,075,389
<p>As far as I know, it's an intentional design to make it more obvious, that the reader should expect an indentation after the colon.</p> <p>It also makes constructs like this possible:</p> <pre><code>if expression: action() code_continues() </code></pre> <p>Note (as a commenter did) that this is not exactly the sh...
4
2010-06-19T12:00:59Z
[ "python", "syntax" ]
How do I find all cells with a particular attribute in BeautifulSoup?
215,667
<p>Hi I am trying to develop a script to pull some data from a large number of html tables. One problem is that the number of rows that contain the information to create the column headings is indeterminate. I have discovered that the last row of the set of header rows has the attribute border-bottom for each cell wi...
2
2008-10-18T22:37:05Z
215,720
<p>Is there any reason </p> <blockquote> <p><code>borderCells = soup.findAll("td", style=re.compile("border-bottom")})</code></p> </blockquote> <p>wouldn't work? It's kind of hard to figure out exactly what you're asking for, since your description of the original tables is pretty ambiguous, and it's not really cl...
2
2008-10-18T23:35:32Z
[ "python", "parsing", "beautifulsoup" ]
How do I find all cells with a particular attribute in BeautifulSoup?
215,667
<p>Hi I am trying to develop a script to pull some data from a large number of html tables. One problem is that the number of rows that contain the information to create the column headings is indeterminate. I have discovered that the last row of the set of header rows has the attribute border-bottom for each cell wi...
2
2008-10-18T22:37:05Z
215,727
<p>Well you know computers are always right. The answer is that the attrs are on different things in the html. What I was modeling on what some html that looked like this:</p> <pre><code>&lt;TD nowrap align="left" valign="bottom"&gt; &lt;DIV style="border-bottom: 1px solid #000000; width: 1%; padding-bottom: 1px"&gt...
0
2008-10-18T23:36:05Z
[ "python", "parsing", "beautifulsoup" ]
How do I find all cells with a particular attribute in BeautifulSoup?
215,667
<p>Hi I am trying to develop a script to pull some data from a large number of html tables. One problem is that the number of rows that contain the information to create the column headings is indeterminate. I have discovered that the last row of the set of header rows has the attribute border-bottom for each cell wi...
2
2008-10-18T22:37:05Z
215,737
<p>Someone took away one of their answers though I tested it and it worked for me. Thanks for the help. Both answers worked and I learned a little bit more about how to post questions and after I stare at the code for a while I might learn more about Python and BeautifulSoup</p>
0
2008-10-18T23:45:51Z
[ "python", "parsing", "beautifulsoup" ]
Why Python decorators rather than closures?
215,689
<p>I still haven't got my head around decorators in Python.</p> <p>I've already started using a lot of closures to do things like customize functions and classes in my coding.</p> <p>Eg.</p> <pre><code>class Node : def __init__(self,val,children) : self.val = val self.children = children def mak...
13
2008-10-18T23:07:28Z
215,782
<p>Are your examples real code, or just examples?</p> <p>If they're real code, I think you overuse decorators, probably because of your background (i.e. you are used to other programming languages)</p> <h3>Stage 1: avoiding decorators</h3> <pre><code>def run(rootnode, func): def _run(node): # recursive internal ...
7
2008-10-19T00:34:16Z
[ "python", "decorator" ]
Why Python decorators rather than closures?
215,689
<p>I still haven't got my head around decorators in Python.</p> <p>I've already started using a lot of closures to do things like customize functions and classes in my coding.</p> <p>Eg.</p> <pre><code>class Node : def __init__(self,val,children) : self.val = val self.children = children def mak...
13
2008-10-18T23:07:28Z
335,442
<p>While it is true that syntactically, decorators are just "sugar", that is not the best way to think about them.</p> <p>Decorators allow you to weave functionality into your existing code without actually modifying it. And they allow you to do it in a way that is declarative.</p> <p>This allows you to use decorator...
13
2008-12-02T21:03:22Z
[ "python", "decorator" ]
Why Python decorators rather than closures?
215,689
<p>I still haven't got my head around decorators in Python.</p> <p>I've already started using a lot of closures to do things like customize functions and classes in my coding.</p> <p>Eg.</p> <pre><code>class Node : def __init__(self,val,children) : self.val = val self.children = children def mak...
13
2008-10-18T23:07:28Z
26,626,194
<p>Following up Dutch Master's AOP reference, you'll find that using decorators becomes especially useful when you start <strong>adding parameters</strong> to modify the behaviour of the decorated function/method, and reading that above the function definition is so much easier.</p> <p>In one project I recall, we need...
0
2014-10-29T09:01:05Z
[ "python", "decorator" ]
How can you use BeautifulSoup to get colindex numbers?
215,702
<p>I had a problem a week or so ago. Since I think the solution was cool I am sharing it here while I am waiting for an answer to the question I posted earlier. I need to know the relative position for the column headings in a table so I know how to match the column heading up with the data in the rows below. I foun...
1
2008-10-18T23:17:38Z
219,000
<p>The code below produces [3, 7, 11, 15] which is what I understand you seek</p> <pre><code>from BeautifulSoup import BeautifulSoup from re import compile soup = BeautifulSoup( '''&lt;HTML&gt;&lt;BODY&gt; &lt;TABLE&gt; &lt;TR style="font-size: 1pt" valign="bottom"&gt; &lt;TD width="60%"&gt; &lt;/TD&g...
1
2008-10-20T16:13:14Z
[ "python", "html", "parsing", "beautifulsoup" ]
Python embedded in CPP: how to get data back to CPP
215,752
<p>While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.</p> <p>The C++ code ...
11
2008-10-18T23:59:37Z
215,772
<p>You should be able to return the result from MyFunc, which would then end up in the variable you are currently calling "ignored". This eliminates the need to access it in any other way.</p>
0
2008-10-19T00:19:55Z
[ "c++", "python", "boost-python" ]
Python embedded in CPP: how to get data back to CPP
215,752
<p>While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.</p> <p>The C++ code ...
11
2008-10-18T23:59:37Z
215,843
<p>I think what you need is either <code>PyObject_CallObject(&lt;py function&gt;, &lt;args&gt;)</code>, which returns the return value of the function you call as a PyObject, or <code>PyRun_String(&lt;expression&gt;, Py_eval_input, &lt;globals&gt;, &lt;locals&gt;)</code> which evaluates a single expression and returns ...
1
2008-10-19T01:20:35Z
[ "c++", "python", "boost-python" ]
Python embedded in CPP: how to get data back to CPP
215,752
<p>While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.</p> <p>The C++ code ...
11
2008-10-18T23:59:37Z
215,874
<p>First of all, change your function to <code>return</code> the value. <code>print</code>ing it will complicate things since you want to get the value back. Suppose your <code>MyModule.py</code> looks like this:</p> <pre><code>import thirdparty def MyFunc(some_arg): result = thirdparty.go() return result </c...
6
2008-10-19T01:53:32Z
[ "c++", "python", "boost-python" ]
Python embedded in CPP: how to get data back to CPP
215,752
<p>While working on a C++ project, I was looking for a third party library for something that is not my core business. I found a really good library, doing exactly what's needed, but it is written in Python. I decided to experiment with embedding Python code in C++, using the Boost.Python library.</p> <p>The C++ code ...
11
2008-10-18T23:59:37Z
216,224
<p>Based on ΤΖΩΤΖΙΟΥ, Josh and Nosklo's answers i finally got it work using boost.python:</p> <p>Python:</p> <pre><code>import thirdparty def MyFunc(some_arg): result = thirdparty.go() return result </code></pre> <p>C++:</p> <pre><code>#include &lt;string&gt; #include &lt;iostream&gt; #include &lt;...
3
2008-10-19T09:47:47Z
[ "c++", "python", "boost-python" ]
How do I coherently organize modules for a PyGTK desktop application?
216,093
<p>I am working on a desktop application in PyGTK and seem to be bumping up against some limitations of my file organization. Thus far I've structured my project this way:</p> <ul> <li>application.py - holds the primary application class (most functional routines)</li> <li>gui.py - holds a loosely coupled GTK gui imp...
7
2008-10-19T06:07:28Z
216,098
<p>This has likely nothing to do with PyGTK, but rather a general code organization issue. You would probably benefit from applying some MVC (Model-View-Controller) design patterns. See <a href="http://en.wikipedia.org/wiki/Design_Patterns" rel="nofollow">Design Patterns</a>, for example.</p>
2
2008-10-19T06:15:00Z
[ "python", "gtk", "module", "pygtk", "organization" ]
How do I coherently organize modules for a PyGTK desktop application?
216,093
<p>I am working on a desktop application in PyGTK and seem to be bumping up against some limitations of my file organization. Thus far I've structured my project this way:</p> <ul> <li>application.py - holds the primary application class (most functional routines)</li> <li>gui.py - holds a loosely coupled GTK gui imp...
7
2008-10-19T06:07:28Z
216,113
<p>Python 2.6 supports <a href="http://docs.python.org/whatsnew/2.6.html#pep-366-explicit-relative-imports-from-a-main-module" rel="nofollow">explicit relative imports</a>, which make using packages even easier than previous versions. I suggest you look into breaking your app into smaller modules inside a package. You ...
0
2008-10-19T06:41:46Z
[ "python", "gtk", "module", "pygtk", "organization" ]
How do I coherently organize modules for a PyGTK desktop application?
216,093
<p>I am working on a desktop application in PyGTK and seem to be bumping up against some limitations of my file organization. Thus far I've structured my project this way:</p> <ul> <li>application.py - holds the primary application class (most functional routines)</li> <li>gui.py - holds a loosely coupled GTK gui imp...
7
2008-10-19T06:07:28Z
216,145
<p>In the project <a href="http://wader-project.org">Wader</a> we use <a href="http://pygtkmvc.sourceforge.net/">python gtkmvc</a>, that makes much easier to apply the MVC patterns when using pygtk and glade, you can see the file organization of our project in the <a href="http://trac.wader-project.org/browser/trunk/wa...
7
2008-10-19T07:39:33Z
[ "python", "gtk", "module", "pygtk", "organization" ]
How do I coherently organize modules for a PyGTK desktop application?
216,093
<p>I am working on a desktop application in PyGTK and seem to be bumping up against some limitations of my file organization. Thus far I've structured my project this way:</p> <ul> <li>application.py - holds the primary application class (most functional routines)</li> <li>gui.py - holds a loosely coupled GTK gui imp...
7
2008-10-19T06:07:28Z
216,386
<p>"holds the primary application class (most functional routines)"</p> <p>As in singular -- one class?</p> <p>I'm not surprised that the <strong>One Class Does Everything</strong> design isn't working. It might not be what I'd call object-oriented. It doesn't sound like it follows the typical MVC design pattern i...
2
2008-10-19T12:53:42Z
[ "python", "gtk", "module", "pygtk", "organization" ]