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 |
|---|---|---|---|---|---|---|---|---|---|
Using Jython with Django? | 2,179,395 | <p>I am planning to use Jython with Django. I want to know how stable the Jython project is, how easy to use it is, and how large its developer community is.</p>
| 4 | 2010-02-01T19:19:42Z | 2,191,492 | <p>I use Jython in testing and rapid-development.
From my point of view it is stable.</p>
| 2 | 2010-02-03T11:26:49Z | [
"python",
"jython"
] |
Using Jython with Django? | 2,179,395 | <p>I am planning to use Jython with Django. I want to know how stable the Jython project is, how easy to use it is, and how large its developer community is.</p>
| 4 | 2010-02-01T19:19:42Z | 2,192,172 | <p>Django is proven to work with Jython:</p>
<ul>
<li>Special focus in Jython 2.5 was to make it compatible with modern web frameworks like Django</li>
<li>There is also a special project, <a href="http://code.google.com/p/django-jython/" rel="nofollow">django-jython</a>, that focuses on making database backends and e... | 5 | 2010-02-03T13:32:26Z | [
"python",
"jython"
] |
Basic google app engine (python) templating issue | 2,179,481 | <p>after going through some basic tutorials on the app engine and the webapp framework, I'm attempting to display documents that are related to a project construct I've created (e.g {% ifequal project.key doc.parentproject %} ) I have created several documents that do indeed have a doc.parentproject identical to keys f... | 0 | 2010-02-01T19:35:13Z | 2,179,564 | <p>Without seeing the controller code that provides the values to this template, it is difficult to really diagnose the problem that you are having, but I would guess that the <em>docs</em> variable isn't getting the list of <em>doc</em> entities that it clearly expects.</p>
<p>From a good design standpoint, I would ... | 1 | 2010-02-01T19:47:40Z | [
"python",
"django",
"google-app-engine"
] |
Basic google app engine (python) templating issue | 2,179,481 | <p>after going through some basic tutorials on the app engine and the webapp framework, I'm attempting to display documents that are related to a project construct I've created (e.g {% ifequal project.key doc.parentproject %} ) I have created several documents that do indeed have a doc.parentproject identical to keys f... | 0 | 2010-02-01T19:35:13Z | 2,183,866 | <p>If a "doc" is an entity, and "parentproject" is a ReferenceProperty on that entity, the problem here is that you're attempting to compare a Key with an entity (ReferenceProperties automatically resolve their references). You need to use this instead:</p>
<pre><code>{% ifequal project.key doc.parentproject.key %}
</... | 0 | 2010-02-02T12:16:02Z | [
"python",
"django",
"google-app-engine"
] |
Misleading(?) TypeError when passing keyword arguments to function defined with positional arguments | 2,179,703 | <p>In cPython 2.4:</p>
<pre><code>def f(a,b,c,d):
pass
>>> f(b=1,c=1,d=1)
TypeError: f() takes exactly 4 non-keyword arguments (0 given)
</code></pre>
<p>but:</p>
<pre><code>>>> f(a=1,b=1,c=1)
TypeError: f() takes exactly 4 non-keyword arguments (3 given)
</code></pre>
<p>Clearly, I don't <st... | 7 | 2010-02-01T20:10:31Z | 2,179,795 | <p>When you say</p>
<pre><code>def f(a,b,c,d):
</code></pre>
<p>you are telling python that <code>f</code> takes 4 <em>positional</em> arguments. Every time you call <code>f</code> it must be given exactly 4 arguments, and the first value will be assigned to <code>a</code>, the second to <code>b</code>, etc.</p>
<p>... | 13 | 2010-02-01T20:24:08Z | [
"python",
"arguments"
] |
Misleading(?) TypeError when passing keyword arguments to function defined with positional arguments | 2,179,703 | <p>In cPython 2.4:</p>
<pre><code>def f(a,b,c,d):
pass
>>> f(b=1,c=1,d=1)
TypeError: f() takes exactly 4 non-keyword arguments (0 given)
</code></pre>
<p>but:</p>
<pre><code>>>> f(a=1,b=1,c=1)
TypeError: f() takes exactly 4 non-keyword arguments (3 given)
</code></pre>
<p>Clearly, I don't <st... | 7 | 2010-02-01T20:10:31Z | 13,495,961 | <p>It is theoretically possible to wrap the resulting TypeError with something more clear and informative. However, there are many little details some of which I don't know how to solve.</p>
<p><strong>NOTE:</strong> the code below is a barely-working example, not a complete solution.</p>
<pre><code>try:
fn(**dat... | 0 | 2012-11-21T14:58:05Z | [
"python",
"arguments"
] |
python log view application | 2,179,918 | <p>I want to have GUI application or Web app where I can view the python log information. I can choose any formatter required. But it should work with standard logging module.</p>
<p>I have configured my logs to file. But I wanted to have log to be stored to mysql db (it is possible) but I badly need user interface t... | 3 | 2010-02-01T20:42:13Z | 2,179,969 | <p>You can write a database handler for logging as in <a href="http://stackoverflow.com/questions/935930/creating-a-logging-handler-to-connect-to-oracle/1014450#1014450">this example</a> using any Python DB-API 2.0 compliant database interface. Then, of course, you can view the logs using any framework which allows you... | 2 | 2010-02-01T20:49:23Z | [
"python",
"mysql",
"logging"
] |
python log view application | 2,179,918 | <p>I want to have GUI application or Web app where I can view the python log information. I can choose any formatter required. But it should work with standard logging module.</p>
<p>I have configured my logs to file. But I wanted to have log to be stored to mysql db (it is possible) but I badly need user interface t... | 3 | 2010-02-01T20:42:13Z | 4,847,201 | <p>vsConsole FileView lets you view server logs via a web application. Have a look at the demo and see if it suits your needs:</p>
<p><a href="http://demo.vamonossoftware.com/" rel="nofollow">http://demo.vamonossoftware.com/</a></p>
| 0 | 2011-01-31T02:44:01Z | [
"python",
"mysql",
"logging"
] |
How is the __format__ method suposed to be used for int? | 2,179,926 | <p>I saw there was a __format__ method but help(int.__format__) doesn't provide any help.</p>
<p>I also know you're not suppose to call a __method__ directly. When is this method called? Which is its argument?</p>
| 4 | 2010-02-01T20:43:31Z | 2,179,970 | <p>It's used when you pass an integer to the format() function. The details elude me, as I can't seem to get it to tell me what exactly the argument is. (Edit: see lost-theory's link)</p>
<p>Oh, and it only works when the integer is the only argument. If you pass a tuple to format, then the tuple.__format__ function i... | 1 | 2010-02-01T20:49:26Z | [
"python",
"int"
] |
How is the __format__ method suposed to be used for int? | 2,179,926 | <p>I saw there was a __format__ method but help(int.__format__) doesn't provide any help.</p>
<p>I also know you're not suppose to call a __method__ directly. When is this method called? Which is its argument?</p>
| 4 | 2010-02-01T20:43:31Z | 2,179,983 | <p>It's used for Py3k's new string formatting scheme.</p>
<p>You can find more info here:</p>
<p><a href="http://docs.python.org/whatsnew/2.6.html#pep-3101-advanced-string-formatting" rel="nofollow">http://docs.python.org/whatsnew/2.6.html#pep-3101-advanced-string-formatting</a></p>
<p>You are right that it isn't ca... | 3 | 2010-02-01T20:50:52Z | [
"python",
"int"
] |
Is it possible to submit batch processing requests with the Python Youtube API? | 2,180,016 | <p>I'm writing an application using Python that adds videos to a user's playlist on Youtube. Doing this one at a time causes Youtube to start throttling my requests.</p>
<p>There is a batch processing API that allows you to submit 50 requests at once, but I can't find out from the docs how to submit a batch processing... | 1 | 2010-02-01T20:54:16Z | 2,180,238 | <p>It looks like this is documented on the gdata-python-client wiki: <a href="http://code.google.com/p/gdata-python-client/wiki/UsingBatchOperations" rel="nofollow">http://code.google.com/p/gdata-python-client/wiki/UsingBatchOperations</a>. While the examples on that page are for Base and Spreadsheets, not YouTube, it ... | 3 | 2010-02-01T21:32:59Z | [
"python",
"youtube",
"gdata-api",
"batch-processing",
"playlist"
] |
Is it possible to submit batch processing requests with the Python Youtube API? | 2,180,016 | <p>I'm writing an application using Python that adds videos to a user's playlist on Youtube. Doing this one at a time causes Youtube to start throttling my requests.</p>
<p>There is a batch processing API that allows you to submit 50 requests at once, but I can't find out from the docs how to submit a batch processing... | 1 | 2010-02-01T20:54:16Z | 7,993,806 | <p>I've managed to get things done this way:</p>
<pre><code>query = "<feed xmlns=\"http://www.w3.org/2005/Atom\""
query += " xmlns:media=\"http://search.yahoo.com/mrss/\""
query += " xmlns:batch=\"http://schemas.google.com/gdata/batch\""
query += " xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
query += "&... | 3 | 2011-11-03T11:05:13Z | [
"python",
"youtube",
"gdata-api",
"batch-processing",
"playlist"
] |
How can I grap resident set size from Python on Solaris? | 2,180,156 | <p>Calling resource.getrusage() from Python returns a 0 value for resident set size on Solaris and Linux systems. On Linux you can pull the RSS From /proc//status instead. Does anybody have a good way to pull RSS on Solaris, either similar or not to the Linux workaround?</p>
| 1 | 2010-02-01T21:17:11Z | 2,180,523 | <p>Maybe use Solaris's <code>psinfo</code> under <code>/proc</code>? (<a href="http://docs.oracle.com/cd/E19455-01/806-0633/6j9vn6q6d/index.html" rel="nofollow">solaris proc(4) docs</a>)</p>
| 0 | 2010-02-01T22:24:27Z | [
"python",
"solaris",
"getrusage"
] |
How can I grap resident set size from Python on Solaris? | 2,180,156 | <p>Calling resource.getrusage() from Python returns a 0 value for resident set size on Solaris and Linux systems. On Linux you can pull the RSS From /proc//status instead. Does anybody have a good way to pull RSS on Solaris, either similar or not to the Linux workaround?</p>
| 1 | 2010-02-01T21:17:11Z | 2,193,909 | <p>Well...you can pull it from the pmap application by calling pmap -x. But I was looking more for a way to access the info directly in /proc from my app. The only way to do it is to access the /proc/<pid>/xmap file. Unfortunately, the data is stored as an array of prxmap structs...so either a Python C-module is... | 0 | 2010-02-03T17:26:18Z | [
"python",
"solaris",
"getrusage"
] |
Python: use mysqldb to import a MySQL table as a dictionary? | 2,180,226 | <p>Anyone know how I can use mysqldb to turn a MySQL table, with lots of rows, into a list of dictionary objects in Python?</p>
<p>I mean turning a set of MySQL rows, with columns 'a', 'b', and 'c', into a Python object that that looks like this: </p>
<pre><code>data = [ { 'a':'A', 'b':(2, 4), 'c':3.0 }, { 'a':'Q', '... | 20 | 2010-02-01T21:31:18Z | 2,180,257 | <p>MySQLdb has a separate cursor class for this, the DictCursor. You can pass the cursor class you want to use to MySQLdb.connect():</p>
<pre><code>import MySQLdb.cursors
MySQLdb.connect(host='...', cursorclass=MySQLdb.cursors.DictCursor)
</code></pre>
| 46 | 2010-02-01T21:37:06Z | [
"python",
"mysql"
] |
Python: use mysqldb to import a MySQL table as a dictionary? | 2,180,226 | <p>Anyone know how I can use mysqldb to turn a MySQL table, with lots of rows, into a list of dictionary objects in Python?</p>
<p>I mean turning a set of MySQL rows, with columns 'a', 'b', and 'c', into a Python object that that looks like this: </p>
<pre><code>data = [ { 'a':'A', 'b':(2, 4), 'c':3.0 }, { 'a':'Q', '... | 20 | 2010-02-01T21:31:18Z | 30,149,680 | <p>If you need to use more cursors and only one needs to be MySQLdb.cursors.DictCursor you can do:</p>
<pre><code>import MySQLdb
db = MySQLdb.connect(host='...', db='...', user='...t', passwd='...')
list_cursor = db.cursor()
dict_cursor = db.cursor(MySQLdb.cursors.DictCursor)
</code></pre>
| 4 | 2015-05-10T09:16:38Z | [
"python",
"mysql"
] |
Does the Jinja2 templating language have the concept of 'here' (current directory)? | 2,180,247 | <p>Does Jinja2 support template-relative paths e.g. <code>%(here)s/other/template.html</code>, to include other templates relative to the current template's place in the filesystem?</p>
| 14 | 2010-02-01T21:34:10Z | 2,180,584 | <p>I do not believe so. Typically you include or extend other templates by specifying their paths relative to the root of whatever template loader and environment you're using.</p>
<p>So let's say your templates are all in <code>/path/to/templates</code> and you've set up Jinja like so:</p>
<pre><code>import jinja2
... | 26 | 2010-02-01T22:38:46Z | [
"python",
"jinja2"
] |
Does the Jinja2 templating language have the concept of 'here' (current directory)? | 2,180,247 | <p>Does Jinja2 support template-relative paths e.g. <code>%(here)s/other/template.html</code>, to include other templates relative to the current template's place in the filesystem?</p>
| 14 | 2010-02-01T21:34:10Z | 3,655,911 | <p>According to the documentation for <a href="http://jinja.pocoo.org/2/documentation/api#jinja2.Environment.join_path">jinja2.Environment.join_path()</a>, support for relative template paths is possible by overriding join_path() to implement "template path joining". </p>
<pre><code>class RelEnvironment(jinja2.Environ... | 5 | 2010-09-07T05:02:09Z | [
"python",
"jinja2"
] |
Does the Jinja2 templating language have the concept of 'here' (current directory)? | 2,180,247 | <p>Does Jinja2 support template-relative paths e.g. <code>%(here)s/other/template.html</code>, to include other templates relative to the current template's place in the filesystem?</p>
| 14 | 2010-02-01T21:34:10Z | 9,763,688 | <p>Just to add to Will McCutchen's answer,</p>
<p>You can have multiple directories in your loader. It then searches in each of the directories (in order) until it finds the template.</p>
<p>for example, if you wanted to have "sidebar.html" instead of "/includes/sidebar.html" then have:</p>
<pre><code>loader=jinja2.... | 9 | 2012-03-19T00:42:56Z | [
"python",
"jinja2"
] |
Does the Jinja2 templating language have the concept of 'here' (current directory)? | 2,180,247 | <p>Does Jinja2 support template-relative paths e.g. <code>%(here)s/other/template.html</code>, to include other templates relative to the current template's place in the filesystem?</p>
| 14 | 2010-02-01T21:34:10Z | 24,600,205 | <p>The cleanest way to overcome this limitation, would be with a jinja2 extension that will allow to <a href="https://gist.github.com/wooyek/8d4c37d684a5ba38b8c1" rel="nofollow">import relative template names</a></p>
<p>Something in the likes of:</p>
<pre><code>from jinja2.ext import Extension
import re
class Relat... | 1 | 2014-07-06T20:48:40Z | [
"python",
"jinja2"
] |
Range of python's random.random() from the standard library | 2,180,299 | <p>Does python's random.random() ever return 1.0 or does it only return up until 0.9999..?</p>
| 13 | 2010-02-01T21:45:26Z | 2,180,314 | <p>Python's <a href="http://docs.python.org/library/random.html"><code>random.random</code></a> function returns numbers that are less than, but not equal to, <code>1</code>.</p>
<p>However, it can return <code>0</code>.</p>
| 10 | 2010-02-01T21:48:09Z | [
"python",
"random"
] |
Range of python's random.random() from the standard library | 2,180,299 | <p>Does python's random.random() ever return 1.0 or does it only return up until 0.9999..?</p>
| 13 | 2010-02-01T21:45:26Z | 2,180,324 | <p>Docs are here: <a href="http://docs.python.org/library/random.html" rel="nofollow">http://docs.python.org/library/random.html</a></p>
<blockquote>
<p>...random(), which
generates a random float uniformly in
the semi-open range [0.0, 1.0).</p>
</blockquote>
<p>So, the return value will be greater than or equa... | 18 | 2010-02-01T21:49:26Z | [
"python",
"random"
] |
Range of python's random.random() from the standard library | 2,180,299 | <p>Does python's random.random() ever return 1.0 or does it only return up until 0.9999..?</p>
| 13 | 2010-02-01T21:45:26Z | 2,180,332 | <pre><code>>>> help(random.random)
Help on built-in function random:
random(...)
random() -> x in the interval [0, 1).
</code></pre>
<p>That means 1 is excluded.</p>
| 31 | 2010-02-01T21:50:41Z | [
"python",
"random"
] |
Range of python's random.random() from the standard library | 2,180,299 | <p>Does python's random.random() ever return 1.0 or does it only return up until 0.9999..?</p>
| 13 | 2010-02-01T21:45:26Z | 18,429,518 | <p>The other answers already clarified that 1 is not included in the range, but out of curiosity, I decided to look at the source to see precisely how it is calculated.</p>
<p>The CPython source can be found <a href="http://hg.python.org/cpython/file/8eac75276e5b/Modules/_randommodule.c">here</a></p>
<pre><code>/* ra... | 11 | 2013-08-25T13:32:50Z | [
"python",
"random"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 2,180,431 | <p>You just need to configure the Django settings before you do any calls, including importing your models. Something like this:</p>
<pre><code>from django.conf import settings
settings.configure(
DATABASE_ENGINE = 'postgresql_psycopg2',
DATABASE_NAME = 'db_name',
DATABASE_USER = 'db_user',
DATABASE_PA... | 39 | 2010-02-01T22:08:14Z | [
"python",
"mysql",
"django"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 2,180,479 | <p>For using Django ORM from other applications you need:</p>
<p>1) <code>export DJANGO_SETTINGS_MODULE=dproj.settings</code></p>
<p>2) Add your Django app folder to the path (you can do it in the code of your non-django-app):</p>
<pre><code>sys.path = sys.path + ['/path/to/your/app/']
</code></pre>
<p>3) If using ... | 2 | 2010-02-01T22:18:32Z | [
"python",
"mysql",
"django"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 2,180,485 | <p><strong>Update</strong> setup_environ is to be removed in django 1.6</p>
<p>If you're able to import your settings.py file, then <a href="http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/" rel="nofollow">take a look</a> at handy setup_environ command.</p>
<pre><code>from django.core.management im... | 13 | 2010-02-01T22:19:03Z | [
"python",
"mysql",
"django"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 2,180,680 | <p>A final option no-one's mentioned: a <a href="http://docs.djangoproject.com/en/1.1/howto/custom-management-commands/">custom <code>./manage.py</code> subcommand</a>.</p>
| 5 | 2010-02-01T22:55:08Z | [
"python",
"mysql",
"django"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 18,103,558 | <p>For django 1.5 on (multiple databases are supported) the DATABASE settings also changed.
You need to adapt the previous answer to ...</p>
<pre><code>settings.configure(
DATABASES = { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db_name',
'USER': 'db_usr',
... | 3 | 2013-08-07T12:35:47Z | [
"python",
"mysql",
"django"
] |
Using Django database layer outside of Django? | 2,180,415 | <p>I've got a nice database I've created in Django, and I'd like to interface with through some python scripts <em>outside</em> of my website stuff, so I'm curious if it's possible to use the Django database API outside of a Django site, and if so does anyone have any info on how it can be done? Google hasn't yielded ... | 39 | 2010-02-01T22:05:31Z | 26,633,359 | <p>For django 1.7, I used the following to get up and running.</p>
<p><strong>settings.py:</strong></p>
<pre><code>from django.conf import settings
settings.configure(
DATABASES={
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'name',
'USER': '... | 9 | 2014-10-29T14:45:03Z | [
"python",
"mysql",
"django"
] |
SQLAlchemy ORM Inserting Related Objects without Selecting Them | 2,180,522 | <p>In the <a href="http://www.sqlalchemy.org/docs/ormtutorial.html#working-with-related-objects" rel="nofollow">SQLAlchemy ORM tutorial</a>, it describes the process of creating object relations roughly as follows. Let's pretend I have a table Articles, a table Keywords, and a table Articles_Keywords which creates a m... | 2 | 2010-02-01T22:24:10Z | 2,181,291 | <p>Unfortunately the ORM cannot keep the object state sane without querying the database. However you can easily go around the ORM and insert into the association table. Assuming that Articles_Keywords is a <code>Table</code> object:</p>
<pre><code> meta.Session.execute(Articles_Keywords.delete(Articles_Keywords.c.art... | 3 | 2010-02-02T01:12:16Z | [
"python",
"performance",
"orm",
"sqlalchemy"
] |
SQLAlchemy ORM Inserting Related Objects without Selecting Them | 2,180,522 | <p>In the <a href="http://www.sqlalchemy.org/docs/ormtutorial.html#working-with-related-objects" rel="nofollow">SQLAlchemy ORM tutorial</a>, it describes the process of creating object relations roughly as follows. Let's pretend I have a table Articles, a table Keywords, and a table Articles_Keywords which creates a m... | 2 | 2010-02-01T22:24:10Z | 2,209,975 | <p>Ants has the right answer, but also if you mapped article_keywords explicitly as an association object, you would just create new ArticleKeyword objects and add them straight in. </p>
| 1 | 2010-02-05T19:53:07Z | [
"python",
"performance",
"orm",
"sqlalchemy"
] |
Python Dynamic module loading based on input | 2,180,539 | <p>I wrote a program that takes in a partial rss feed and outputs a full one, but it is one a case by case basis. The recipe for one site is not the same as the recipe for the other. So what I do is look at the domain basename(for instance nyt or wsj) and choose a module based on that. Though I need to load each and... | 1 | 2010-02-01T22:27:27Z | 2,180,572 | <p>It sounds like you're looking for the <a href="http://docs.python.org/library/functions.html#__import__" rel="nofollow"><code>__import__</code></a> function. This function does the same thing as the <code>import</code> statement, but allows you to pass a name to import that might only be known at runtime.</p>
<p>So... | 3 | 2010-02-01T22:35:04Z | [
"python",
"web-scraping"
] |
Python Dynamic module loading based on input | 2,180,539 | <p>I wrote a program that takes in a partial rss feed and outputs a full one, but it is one a case by case basis. The recipe for one site is not the same as the recipe for the other. So what I do is look at the domain basename(for instance nyt or wsj) and choose a module based on that. Though I need to load each and... | 1 | 2010-02-01T22:27:27Z | 2,180,655 | <p>You can use the <a href="http://docs.python.org/library/imp.html" rel="nofollow">imp module</a>.</p>
| 1 | 2010-02-01T22:51:34Z | [
"python",
"web-scraping"
] |
Is it OK to raise a built-in exception, but with a different message, in Python? | 2,180,577 | <p>Is it OK to raise a <a href="http://docs.python.org/library/exceptions.html">built-in exception</a> with a custom text? or to raise a <a href="http://docs.python.org/library/warnings.html#warning-categories">built-in warning</a> also with custom text?</p>
<p>The documentation reads:</p>
<blockquote>
<p>exceptio... | 16 | 2010-02-01T22:36:15Z | 2,180,615 | <p>It's perfectly ok. </p>
<p>However you may want to create your own subclass to help distinguish from the builtin exceptions</p>
<p>For example if you have something that works like a <code>dict</code>, you can raise a KeyError for the usual reasons, but what if the KeyError is really coming from an underlying dic... | 2 | 2010-02-01T22:44:28Z | [
"python",
"exception",
"raise",
"built-in"
] |
Is it OK to raise a built-in exception, but with a different message, in Python? | 2,180,577 | <p>Is it OK to raise a <a href="http://docs.python.org/library/exceptions.html">built-in exception</a> with a custom text? or to raise a <a href="http://docs.python.org/library/warnings.html#warning-categories">built-in warning</a> also with custom text?</p>
<p>The documentation reads:</p>
<blockquote>
<p>exceptio... | 16 | 2010-02-01T22:36:15Z | 2,180,634 | <p>It's OK and I do it all the time. I find it less surprising to see TypeError than MySpecialTypeError in many situations.</p>
<p>On the <a href="http://docs.python.org/library/exceptions.html" rel="nofollow">page you linked</a>, I don't see the phrase "built-in":</p>
<pre><code>exception TypeError: Raised when an ... | 4 | 2010-02-01T22:48:45Z | [
"python",
"exception",
"raise",
"built-in"
] |
Is it OK to raise a built-in exception, but with a different message, in Python? | 2,180,577 | <p>Is it OK to raise a <a href="http://docs.python.org/library/exceptions.html">built-in exception</a> with a custom text? or to raise a <a href="http://docs.python.org/library/warnings.html#warning-categories">built-in warning</a> also with custom text?</p>
<p>The documentation reads:</p>
<blockquote>
<p>exceptio... | 16 | 2010-02-01T22:36:15Z | 2,180,803 | <p>There's nothing operationally wrong with doing something like:</p>
<pre><code>raise ValueError("invalid input encoding")
</code></pre>
<p>In fact, I do that quite often when I'm writing the first pass of some code. The main problem with doing it that way is that clients of your code have a hard time being precise ... | 17 | 2010-02-01T23:20:23Z | [
"python",
"exception",
"raise",
"built-in"
] |
Python: Why can't I iterate over a list? Is my exception class borked? | 2,180,578 | <p>I've already looked at this question: <a href="http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class">http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class</a></p>
<p>but this doesn'... | 1 | 2010-02-01T22:36:25Z | 2,180,588 | <p>The <a href="http://docs.python.org/reference/datamodel.html#object.__iter__"><code>__iter__</code></a> method should return an iterator object, but you are returning a list object. Use</p>
<pre><code>def __iter__(self):
return iter(self._values)
</code></pre>
<p>instead to fix this. From the documentation for... | 5 | 2010-02-01T22:39:50Z | [
"python",
"exception-handling",
"iterator",
"exception"
] |
Python: Why can't I iterate over a list? Is my exception class borked? | 2,180,578 | <p>I've already looked at this question: <a href="http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class">http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class</a></p>
<p>but this doesn'... | 1 | 2010-02-01T22:36:25Z | 2,180,596 | <p><code>__iter__</code> needs to return an iterator, not a list.</p>
<p>Try this:</p>
<pre><code> def __iter__(self):
return iter(self._values)
</code></pre>
<p>You could also do:</p>
<pre><code> def __iter__(self):
for val in self._values:
yield val
</code></pre>
<p>But I can't ... | 1 | 2010-02-01T22:40:47Z | [
"python",
"exception-handling",
"iterator",
"exception"
] |
Python: Why can't I iterate over a list? Is my exception class borked? | 2,180,578 | <p>I've already looked at this question: <a href="http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class">http://stackoverflow.com/questions/1152238/python-iterators-how-to-dynamically-assign-self-next-within-a-new-style-class</a></p>
<p>but this doesn'... | 1 | 2010-02-01T22:36:25Z | 2,180,601 | <pre><code>def __iter__(self):
return iter(self._values)
</code></pre>
<p>Or a more generic:</p>
<pre><code>def __iter__(self):
for x in self._values:
yield x
</code></pre>
| 4 | 2010-02-01T22:41:09Z | [
"python",
"exception-handling",
"iterator",
"exception"
] |
pygtk: find out focused element | 2,180,614 | <p>i'm creating a dialog that finds out what is focused element.
that's what i wrote:</p>
<pre><code>
import gtk
import gobject
class FocusedElementPath(gtk.Dialog):
def __init__(self, parent, title=None):
gtk.Dialog.__init__(self, title or 'Show path', parent)
self.catch_within = parent
... | 0 | 2010-02-01T22:44:26Z | 2,180,674 | <p><a href="http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--get-focus" rel="nofollow">gtk.Window.get_focus</a> (also available in <code>gtk.Dialog</code>) will return the currently focused child.</p>
<p>Anyway I don't quite understand what you want to achieve here...</p>
| 1 | 2010-02-01T22:54:32Z | [
"python",
"dialog",
"gtk",
"focus",
"pygtk"
] |
How do I use a Python regex to match the function syntax of MATLAB? | 2,180,784 | <p>I am trying to find all the inputs/outputs of all MATLAB functions in our internal library. I am new (first time) to regex and have been trying to use the multiline mode in Python's <code>re</code> library.</p>
<p>The MATLAB function syntax looks like:</p>
<pre><code>function output = func_name(input)
</code></pre... | 3 | 2010-02-01T23:16:10Z | 2,180,896 | <p>The peculiar (internal) error you're getting should come if you pass <code>re.T</code> instead of <code>re.M</code> as the second argument to <code>re.compile</code> (<code>re.template</code> -- a currently undocumented entry -- is the one intended to use it, and, in brief, template REs don't support repetition or b... | 5 | 2010-02-01T23:41:04Z | [
"python",
"regex",
"matlab"
] |
How do I use a Python regex to match the function syntax of MATLAB? | 2,180,784 | <p>I am trying to find all the inputs/outputs of all MATLAB functions in our internal library. I am new (first time) to regex and have been trying to use the multiline mode in Python's <code>re</code> library.</p>
<p>The MATLAB function syntax looks like:</p>
<pre><code>function output = func_name(input)
</code></pre... | 3 | 2010-02-01T23:16:10Z | 2,181,225 | <p>how about normal Python string operations? Just an example only</p>
<pre><code>for line in open("file"):
sline=line.strip()
if sline.startswith("function"):
lhs,rhs =sline.split("=")
out=lhs.replace("function ","")
if "[" in out and "]" in out:
out=out.replace("]","").replace(... | 0 | 2010-02-02T00:57:18Z | [
"python",
"regex",
"matlab"
] |
How do I use a Python regex to match the function syntax of MATLAB? | 2,180,784 | <p>I am trying to find all the inputs/outputs of all MATLAB functions in our internal library. I am new (first time) to regex and have been trying to use the multiline mode in Python's <code>re</code> library.</p>
<p>The MATLAB function syntax looks like:</p>
<pre><code>function output = func_name(input)
</code></pre... | 3 | 2010-02-01T23:16:10Z | 2,181,368 | <p>Here's a regular expression that should match any MATLAB function declaration at the start of an m-file:</p>
<pre><code>^\s*function\s+((\[[\w\s,.]*\]|[\w]*)\s*=)?[\s.]*\w+(\([^)]*\))?
</code></pre>
<p>And here's a more detailed explanation of the components:</p>
<pre><code>^\s* # Match 0 or more whit... | 2 | 2010-02-02T01:34:22Z | [
"python",
"regex",
"matlab"
] |
Python: Can I overload the raise statement with def __raise__(self):? | 2,180,810 | <p>Here's my exception class that is using <strong>raise</strong>:</p>
<pre><code>class SCE(Exception):
"""
An error while performing SCE functions.
"""
def __init__(self, value=None):
"""
Message: A string message or an iterable of strings.
"""
if value is None:
... | 2 | 2010-02-01T23:21:35Z | 2,180,854 | <p>There is no such special method <code>__raise__</code> (at least none that I have ever heard of or that I can find in <a href="http://docs.python.org/reference/datamodel.html" rel="nofollow">the Python documentation</a>).</p>
<p>Why do you want to do this? I can't think of any reason why you want custom code be be... | 1 | 2010-02-01T23:31:00Z | [
"python",
"raise"
] |
Python: Can I overload the raise statement with def __raise__(self):? | 2,180,810 | <p>Here's my exception class that is using <strong>raise</strong>:</p>
<pre><code>class SCE(Exception):
"""
An error while performing SCE functions.
"""
def __init__(self, value=None):
"""
Message: A string message or an iterable of strings.
"""
if value is None:
... | 2 | 2010-02-01T23:21:35Z | 2,180,933 | <p>As the other answer says, there is no <code>__raise__</code> special method. There was a thread in 2004 on comp.lang.python where someone suggested adding such a method, but I don't think there was any followup to that. The only way I can think of to hook exception raising is either by patching the interpreter, or s... | 2 | 2010-02-01T23:49:37Z | [
"python",
"raise"
] |
Sorting and grouping objects by Date with the Django ORM | 2,180,847 | <p>I have an Article model which has a date field. I want to query against all Article objects, and have a datatype returned with each distinct year, and then each distinct month within that.</p>
<p>for instance</p>
<p><code>
archives = {
2009: {12, [, , ...], 11: [...]},
2008: {12, [...], 11: [...]},
}
</code>... | 0 | 2010-02-01T23:29:33Z | 2,181,178 | <p>There is no quick solution, but you may check <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#dates-field-kind-order-asc" rel="nofollow">dates()</a> method.</p>
| 0 | 2010-02-02T00:46:06Z | [
"python",
"django",
"django-orm"
] |
Sorting and grouping objects by Date with the Django ORM | 2,180,847 | <p>I have an Article model which has a date field. I want to query against all Article objects, and have a datatype returned with each distinct year, and then each distinct month within that.</p>
<p>for instance</p>
<p><code>
archives = {
2009: {12, [, , ...], 11: [...]},
2008: {12, [...], 11: [...]},
}
</code>... | 0 | 2010-02-01T23:29:33Z | 2,181,424 | <p>This sort of question seems to come up fairly often. The easiest solution is to loop through the data and group the objects by year and month. You can do this by hand in the view or using <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup" rel="nofollow">regroup</a> in your template. It... | 4 | 2010-02-02T01:52:22Z | [
"python",
"django",
"django-orm"
] |
How do I use this Python package? (guess_language) | 2,180,864 | <p>I am trying to use this package: <a href="http://pypi.python.org/pypi/guess-language/0.1" rel="nofollow">http://pypi.python.org/pypi/guess-language/0.1</a>
I've read the documentation/wiki, but can't find the solution.</p>
<p>Basically, this package allows you to pass in a string, and it will return a "language".
I... | 0 | 2010-02-01T23:32:57Z | 2,180,885 | <p>By modifying the source code of the module, from the sounds of this quote (taken from the answer you linked to):</p>
<blockquote>
<p>Update after some experimentation, <em>including inserting a print statement to show what script blocks were detected with what percentages</em></p>
</blockquote>
<p>(Emphasis adde... | 1 | 2010-02-01T23:38:19Z | [
"python",
"documentation",
"wiki",
"packages"
] |
Why do I get the u"xyz" format when I print a list of unicode strings in Python? | 2,180,929 | <p>Please observe the following behavior:</p>
<pre><code>a = u"foo"
b = u"b\xe1r" # \xe1 is an 'a' with an accent
s = [a, b]
print a, b
print s
for x in s: print x,
</code></pre>
<p>The result is:</p>
<pre><code>foo bár
[u'foo', u'b\xe1r']
foo bár
</code></pre>
<p>When I just print the two values sitting in va... | 1 | 2010-02-01T23:48:20Z | 2,180,940 | <p>When you print a list, you get the <code>repr()</code> of each element, lists aren't really meant to be printed, so python tries to print something representative of it's structure.</p>
<p>If you want to format it in any particular way, either be explicit about how you want it formatted, or override it's <code>__re... | 7 | 2010-02-01T23:51:38Z | [
"python",
"unicode",
"list"
] |
Why do I get the u"xyz" format when I print a list of unicode strings in Python? | 2,180,929 | <p>Please observe the following behavior:</p>
<pre><code>a = u"foo"
b = u"b\xe1r" # \xe1 is an 'a' with an accent
s = [a, b]
print a, b
print s
for x in s: print x,
</code></pre>
<p>The result is:</p>
<pre><code>foo bár
[u'foo', u'b\xe1r']
foo bár
</code></pre>
<p>When I just print the two values sitting in va... | 1 | 2010-02-01T23:48:20Z | 2,180,949 | <p>You get this because lists can contain any number of elements, of mixed types. In the second case, instead of printing unicode strings, you're printing the <strong>list itself</strong> - which is very different than printing the list contents.</p>
<p>Since the list can contain anything, you get the <code>u'foo'</c... | 0 | 2010-02-01T23:52:51Z | [
"python",
"unicode",
"list"
] |
Why do I get the u"xyz" format when I print a list of unicode strings in Python? | 2,180,929 | <p>Please observe the following behavior:</p>
<pre><code>a = u"foo"
b = u"b\xe1r" # \xe1 is an 'a' with an accent
s = [a, b]
print a, b
print s
for x in s: print x,
</code></pre>
<p>The result is:</p>
<pre><code>foo bár
[u'foo', u'b\xe1r']
foo bár
</code></pre>
<p>When I just print the two values sitting in va... | 1 | 2010-02-01T23:48:20Z | 2,181,022 | <p>Objects in Python have two ways to be turned into strings: roughly speaking, str() produces human readable output, and repr() produces computer-readable output. When you print something, it uses str().</p>
<p>But the str() of a list uses the repr() of its elements.</p>
| 1 | 2010-02-02T00:14:33Z | [
"python",
"unicode",
"list"
] |
Really weird issue with shelve (python) | 2,180,946 | <p>I create a file called <code>foo_module.py</code> containing the following code:</p>
<pre><code>import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
</code></pre>
<p>Next to that file I c... | 5 | 2010-02-01T23:52:23Z | 2,181,067 | <p>It seems to be an exception in a shutdown function registered by the <code>shelve</code> module. The "ignored" part is from the shutdown system, and might get its wording improved sometime, per <a href="http://bugs.python.org/issue6294" rel="nofollow">Issue 6294</a>. I'm still hoping for an answer on how to elimin... | 1 | 2010-02-02T00:22:07Z | [
"python",
"shelve"
] |
Really weird issue with shelve (python) | 2,180,946 | <p>I create a file called <code>foo_module.py</code> containing the following code:</p>
<pre><code>import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
</code></pre>
<p>Next to that file I c... | 5 | 2010-02-01T23:52:23Z | 2,181,095 | <p>I think you've hit a minor bug in 2.6.4's code related to the cleanup at end of program. If you run <code>python -v</code> you can see exactly at what point of the cleanup the error comes:</p>
<pre><code># cleanup[1] foo_package.g
Exception TypeError: "'NoneType' object is not callable" in ignored
</code></pre>
<... | 10 | 2010-02-02T00:28:08Z | [
"python",
"shelve"
] |
Really weird issue with shelve (python) | 2,180,946 | <p>I create a file called <code>foo_module.py</code> containing the following code:</p>
<pre><code>import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
</code></pre>
<p>Next to that file I c... | 5 | 2010-02-01T23:52:23Z | 2,181,642 | <p>This is indeed a Python bug, and I've posted a patch to the tracker issue you opened (thanks for doing that). </p>
<p>The problem is that shelve's <strong>del</strong> method calls its close method, but if the shelve module has already been through cleanup, the close method fails with the message you see.</p>
<p>... | 2 | 2010-02-02T03:00:26Z | [
"python",
"shelve"
] |
Really weird issue with shelve (python) | 2,180,946 | <p>I create a file called <code>foo_module.py</code> containing the following code:</p>
<pre><code>import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
</code></pre>
<p>Next to that file I c... | 5 | 2010-02-01T23:52:23Z | 2,978,282 | <p>After days of hair loss, I finally had success using an atexit function:</p>
<pre><code> import atexit
...
cache = shelve.open(path)
atexit.register(cache.close)
</code></pre>
<p>It's most appropriate to register right after opening. This works with multiple concurrent shelves.</p>
<p>(python 2.6.5 on luci... | 8 | 2010-06-04T22:50:27Z | [
"python",
"shelve"
] |
Really weird issue with shelve (python) | 2,180,946 | <p>I create a file called <code>foo_module.py</code> containing the following code:</p>
<pre><code>import shelve, whichdb, os
from foo_package.g import g
g.shelf = shelve.open("foo_path")
g.shelf.close()
print whichdb.whichdb("foo_path") # => dbhash
os.remove("foo_path")
</code></pre>
<p>Next to that file I c... | 5 | 2010-02-01T23:52:23Z | 36,686,333 | <p>for me a simple <code>shelve.close()</code> on an unclosed one did the job.</p>
<p>shelve.open('somefile') returns a "persistent dictionary for reading and writing" object which i used throughout the app's runtime.
when I terminated the app I received the "TypeError" Exception as mentioned.
I plased a 'close()' c... | 0 | 2016-04-18T05:50:54Z | [
"python",
"shelve"
] |
Django generic views with multiple parameters | 2,181,002 | <p>Is it possible to use a generic view with additional parameters in the URL mapping - i.e. I got the following model:</p>
<pre><code>class Route(models.Model):
area = models.ForeignKey(Area)
slug = models.SlugField(null=True,blank=True)
@models.permalink
def get_absolute_url(self):
return ('... | 2 | 2010-02-02T00:07:06Z | 2,181,163 | <p>Sure, something like this:</p>
<pre><code>url(r'^(?P<area>[-\w]+)/(?P<slug>[-\w]+)/$',
'django.views.generic.list_detail.object_detail',
{'queryset': Route.objects.all()}
name='route_details')
</code></pre>
<p>Should just work.</p>
<p>Be sure to either set template_object_name to "route" o... | 0 | 2010-02-02T00:41:28Z | [
"python",
"django",
"django-generic-views"
] |
Deleting attributes when deleting instance | 2,181,016 | <p>class A:
def __get(self):
return self._x</p>
<pre><code> def __set(self, y):
self._x = y
def __delete_x(self):
print('DELETING')
del self._x
x = property(__get,__set,__delete_x)
b = A()
# Here, when b is deleted, i'd like b.x to be deleted, i.e __delete_x()
# called (and for immediate consequ... | 1 | 2010-02-02T00:12:53Z | 2,181,058 | <p>To control what happens when an instance of class <code>A</code> goes away (whether by being deleted or garbage collected), you can implement special method <code>__del__(self)</code> in <code>A</code>. If you want to have your code involved when a specific <em>attribute</em> of that instance goes away, you can eit... | 1 | 2010-02-02T00:20:03Z | [
"python",
"class",
"attributes",
"instance",
"del"
] |
Deleting attributes when deleting instance | 2,181,016 | <p>class A:
def __get(self):
return self._x</p>
<pre><code> def __set(self, y):
self._x = y
def __delete_x(self):
print('DELETING')
del self._x
x = property(__get,__set,__delete_x)
b = A()
# Here, when b is deleted, i'd like b.x to be deleted, i.e __delete_x()
# called (and for immediate consequ... | 1 | 2010-02-02T00:12:53Z | 2,181,078 | <p>The semantics of the <code>del</code> statement don't really lend themselves to what you want here. <code>del b</code> simple removes the reference to the <code>A</code> object you just instantiated from the local scope frame / dictionary; this does not directly cause any operation to be performed on the object itse... | 2 | 2010-02-02T00:24:47Z | [
"python",
"class",
"attributes",
"instance",
"del"
] |
Deleting attributes when deleting instance | 2,181,016 | <p>class A:
def __get(self):
return self._x</p>
<pre><code> def __set(self, y):
self._x = y
def __delete_x(self):
print('DELETING')
del self._x
x = property(__get,__set,__delete_x)
b = A()
# Here, when b is deleted, i'd like b.x to be deleted, i.e __delete_x()
# called (and for immediate consequ... | 1 | 2010-02-02T00:12:53Z | 2,181,298 | <p>An ugly way to do it would be :</p>
<pre><code>def __del__(self):
for x in dir(self.__class__):
if type(getattr(self.__class__, x)) == property:
getattr(self.__class__, x).fdel(self)
</code></pre>
| 0 | 2010-02-02T01:13:13Z | [
"python",
"class",
"attributes",
"instance",
"del"
] |
How do I extend the Django Group model? | 2,181,039 | <p>Is there a way to extend the built-in Django Group object to add additional attributes similar to the way you can extend a user object? With a user object, you can do the following: </p>
<pre><code>class UserProfile(models.Model):
user = models.OneToOneField(User)
</code></pre>
<p>and add the following to the ... | 18 | 2010-02-02T00:17:16Z | 2,182,418 | <p>You can create a model that subclasses Group, add your own fields, and use a Model Manager to return any custom querysets you need. Here's a truncated example showing I extended Group to represent Families associated with a school:</p>
<pre><code>from django.contrib.auth.models import Group, User
class FamilyManag... | 12 | 2010-02-02T07:16:54Z | [
"python",
"django",
"django-models"
] |
How do I extend the Django Group model? | 2,181,039 | <p>Is there a way to extend the built-in Django Group object to add additional attributes similar to the way you can extend a user object? With a user object, you can do the following: </p>
<pre><code>class UserProfile(models.Model):
user = models.OneToOneField(User)
</code></pre>
<p>and add the following to the ... | 18 | 2010-02-02T00:17:16Z | 7,669,063 | <p>If you simply subclass the Group object then by default it will create a new database table and the admin site won't pick up any new fields.</p>
<p>You need to inject new fields into the existing Group:</p>
<pre><code>if not hasattr(Group, 'parent'):
field = models.ForeignKey(Group, blank=True, null=True, rela... | 24 | 2011-10-05T23:52:00Z | [
"python",
"django",
"django-models"
] |
How to access url hash/fragment from a Django Request object | 2,181,186 | <p>As in the title: how can I access the url hash/fragment (the part following the dash <code>#</code>) from a Django view and so, I suppose, from a Django Request object?</p>
<p>I've not found enough information on the documentation here available: <a href="http://docs.djangoproject.com/en/dev/ref/request-response/">... | 18 | 2010-02-02T00:47:37Z | 2,181,192 | <p>This is not sent to the server, by definition. From <a href="http://www.w3.org/DesignIssues/Fragment.html">URI References: Fragment Identifiers on URIs </a>:</p>
<blockquote>
<p>"The HTTP engine cannot make any assumptions about it. The server is not even given it."</p>
</blockquote>
| 29 | 2010-02-02T00:50:46Z | [
"python",
"django",
"hash",
"django-urls",
"fragment-identifier"
] |
Multiprocessing and niceness value | 2,181,209 | <p>Does anyone know of an easy way to set the niceness value of a Process or Pool when it is created in multiprocessing?</p>
| 9 | 2010-02-02T00:54:25Z | 2,181,412 | <p>Try importing the ctypes module and looking for pthread_schedparam() or SetThreadPriority() (Linux / Windows).</p>
| 0 | 2010-02-02T01:47:43Z | [
"python",
"multiprocessing"
] |
Multiprocessing and niceness value | 2,181,209 | <p>Does anyone know of an easy way to set the niceness value of a Process or Pool when it is created in multiprocessing?</p>
| 9 | 2010-02-02T00:54:25Z | 2,181,704 | <pre><code>os.nice(increment)
Add increment to the processâs ânicenessâ. Return the new niceness. Availability: Unix.
</code></pre>
<p>From <a href="http://docs.python.org/library/os.html#os.nice" rel="nofollow">http://docs.python.org/library/os.html#os.nice</a>.</p>
<p>Is there a reason you can't call this in ... | 12 | 2010-02-02T03:26:10Z | [
"python",
"multiprocessing"
] |
Determining the frequency of Twitter tweets on a certain topic | 2,181,230 | <p>Is there a way for me to determine the total number of Twitter messages on a given trend topic (e.g. frequency of Twitter messages with subject matter on Haiti/#Haiti) at a given instance in time using the Twitter API? I'm writing a script in Python that will monitor Twitter traffic over a long spell of time and I w... | 1 | 2010-02-02T00:58:37Z | 2,181,240 | <p>Yes. Use the <a href="http://apiwiki.twitter.com/Streaming-API-Documentation" rel="nofollow">Twitter Streaming API</a> to get a representative sample.</p>
| 1 | 2010-02-02T01:00:17Z | [
"python",
"twitter"
] |
Determining the frequency of Twitter tweets on a certain topic | 2,181,230 | <p>Is there a way for me to determine the total number of Twitter messages on a given trend topic (e.g. frequency of Twitter messages with subject matter on Haiti/#Haiti) at a given instance in time using the Twitter API? I'm writing a script in Python that will monitor Twitter traffic over a long spell of time and I w... | 1 | 2010-02-02T00:58:37Z | 2,182,091 | <p>You might take a look at this site (see below) Drew has several sources of information and was to look at the data.
Network of People who Twitter about R
<a href="http://www.drewconway.com/zia/?p=1471" rel="nofollow">http://www.drewconway.com/zia/?p=1471</a></p>
| 1 | 2010-02-02T05:38:33Z | [
"python",
"twitter"
] |
Python: How do I access an decorated class's instance from inside a class decorator? | 2,181,275 | <p>Here's an example of what I mean:</p>
<pre><code>class MyDecorator(object):
def __call__(self, func):
# At which point would I be able to access the decorated method's parent class's instance?
# In the below example, I would want to access from here: myinstance
def wrapper(*args, **k... | 5 | 2010-02-02T01:07:56Z | 2,181,312 | <pre><code>class MyDecorator(object):
def __call__(self, func):
def wrapper(that, *args, **kwargs):
## you can access the "self" of func here through the "that" parameter
## and hence do whatever you want
return func(that, *args, **kwargs)
return wrapper
</code></pre>
| 5 | 2010-02-02T01:17:06Z | [
"python",
"decorator"
] |
Python: How do I access an decorated class's instance from inside a class decorator? | 2,181,275 | <p>Here's an example of what I mean:</p>
<pre><code>class MyDecorator(object):
def __call__(self, func):
# At which point would I be able to access the decorated method's parent class's instance?
# In the below example, I would want to access from here: myinstance
def wrapper(*args, **k... | 5 | 2010-02-02T01:07:56Z | 2,181,922 | <p>Please notice in this context that the use of "self" is just a convention, a method just uses the first argument as a reference to the instance object:</p>
<pre><code>class Example:
def __init__(foo, a):
foo.a = a
def method(bar, b):
print bar.a, b
e = Example('hello')
e.method('world')
</code></pre>
| 2 | 2010-02-02T04:36:53Z | [
"python",
"decorator"
] |
Python: How do I access an decorated class's instance from inside a class decorator? | 2,181,275 | <p>Here's an example of what I mean:</p>
<pre><code>class MyDecorator(object):
def __call__(self, func):
# At which point would I be able to access the decorated method's parent class's instance?
# In the below example, I would want to access from here: myinstance
def wrapper(*args, **k... | 5 | 2010-02-02T01:07:56Z | 2,182,726 | <p>The self argument is passed as the first argument. Also your <code>MyDecorator</code> is a class emulating a function. Easier to make it an actual function.</p>
<pre><code>def MyDecorator(method):
def wrapper(self, *args, **kwargs):
print 'Self is', self
return method(self, *args, **kwargs)
... | 1 | 2010-02-02T08:35:56Z | [
"python",
"decorator"
] |
Using the Image.point() method in PIL to manipulate pixel data | 2,181,292 | <p>I am using the <a href="http://www.pythonware.com/products/pil/">Python Imaging Library</a> to colorize a black and white image with a lookup table that defines the color relationships. The lookup table is simply a 256-element list of RGB tuples: </p>
<pre><code>>>> len(colors)
256
>>> colors[0]... | 17 | 2010-02-02T01:12:33Z | 2,181,365 | <blockquote>
<p>Is Image.point() the right tool for
this job?</p>
</blockquote>
<p>Yes indeed, <code>Image.point()</code> is perfect for this job</p>
<blockquote>
<p>What format/structure does
Image.point() expect the table?</p>
</blockquote>
<p>You should flatten the list so instead of <code>[(12, 140, 10),... | 14 | 2010-02-02T01:33:43Z | [
"python",
"image",
"image-processing",
"image-manipulation",
"python-imaging-library"
] |
Using the Image.point() method in PIL to manipulate pixel data | 2,181,292 | <p>I am using the <a href="http://www.pythonware.com/products/pil/">Python Imaging Library</a> to colorize a black and white image with a lookup table that defines the color relationships. The lookup table is simply a 256-element list of RGB tuples: </p>
<pre><code>>>> len(colors)
256
>>> colors[0]... | 17 | 2010-02-02T01:12:33Z | 2,181,473 | <p>I think it might be more typical to <code>point</code> on a band-by-band basis like so (lifted directly from the PIL <a href="http://effbot.org/imagingbook/introduction.htm" rel="nofollow">tutorial</a>):</p>
<pre><code># split the image into individual bands
source = im.split()
R, G, B = 0, 1, 2
# select regions... | 3 | 2010-02-02T02:07:50Z | [
"python",
"image",
"image-processing",
"image-manipulation",
"python-imaging-library"
] |
Finding the length of a cubic B-spline | 2,181,349 | <p>Using scipy's <code>interpolate.splprep</code> function get a parametric spline on parameter <code>u</code>, but the domain of <code>u</code> is not the line integral of the spline, it is a piecewise linear connection of the input coordinates. I've tried <code>integrate.splint</code>, but that just gives the indivi... | 6 | 2010-02-02T01:27:46Z | 2,182,756 | <p>Because both x & y are cubic parametric functions, there isn't a closed solution in terms of simple functions. Numerical integration is the way to go. Either integrating the arc length expression or simply adding line segment lengths - depends on the accuracy you are after and how much effort you want to exert.<... | 4 | 2010-02-02T08:42:57Z | [
"python",
"scipy",
"interpolation"
] |
Finding the length of a cubic B-spline | 2,181,349 | <p>Using scipy's <code>interpolate.splprep</code> function get a parametric spline on parameter <code>u</code>, but the domain of <code>u</code> is not the line integral of the spline, it is a piecewise linear connection of the input coordinates. I've tried <code>integrate.splint</code>, but that just gives the indivi... | 6 | 2010-02-02T01:27:46Z | 2,184,220 | <p>You can integrate the function <code>sqrt(x'(u)**2+y'(u)**2)</code> over <code>u</code>, where you calculate the derivatives <code>x'</code> and <code>y'</code> of your coordinates with <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.splev.html#scipy.interpolate.splev" rel="nofollow">s... | 2 | 2010-02-02T13:10:25Z | [
"python",
"scipy",
"interpolation"
] |
what is 'comments' mean in this code | 2,181,460 | <pre><code>{% load comments %}
</code></pre>
<p>where defined 'comments' ,a viewer? or a template??</p>
<p>thanks </p>
| 1 | 2010-02-02T02:03:41Z | 2,181,471 | <p>It is a template tag library. For example:</p>
<pre><code>{% load cache %}
</code></pre>
<p>loads the <a href="http://docs.djangoproject.com/en/1.1/topics/cache/#template-fragment-caching" rel="nofollow">caching tags</a>.</p>
<p>Custom tags can be defined and placed within your project structure as defined <a hr... | 2 | 2010-02-02T02:07:34Z | [
"python",
"django"
] |
what is 'comments' mean in this code | 2,181,460 | <pre><code>{% load comments %}
</code></pre>
<p>where defined 'comments' ,a viewer? or a template??</p>
<p>thanks </p>
| 1 | 2010-02-02T02:03:41Z | 2,181,512 | <p>It's a template tag that loads a specific set of other template tags (comments application specific tags in this case) making them available in the rest of the template file to use.</p>
<p>So, for example, you will be able to use other comments-app specific tags like:</p>
<pre><code>{% get_comment_count for entry ... | 1 | 2010-02-02T02:22:34Z | [
"python",
"django"
] |
what is 'comments' mean in this code | 2,181,460 | <pre><code>{% load comments %}
</code></pre>
<p>where defined 'comments' ,a viewer? or a template??</p>
<p>thanks </p>
| 1 | 2010-02-02T02:03:41Z | 2,182,049 | <p>As other answers have pointed out, <code>comments</code> is a templatetag.</p>
<p>To answer your question: </p>
<blockquote>
<p>where defined 'comments'</p>
</blockquote>
<p>in <code>django/contrib/comments/templatetags/comments.py</code></p>
<p>Here you go: <a href="http://github.com/django/django/blob/master... | 1 | 2010-02-02T05:24:58Z | [
"python",
"django"
] |
Scraping html with Python or | 2,181,708 | <p>One of the arguments I make to my (Microbiology and Genetics) students is that "data" is/are messy, and Python can help with that (of course other languages can too). So here is a practical kind of web-based data-gathering exercise.</p>
<p>I notice that there a few people who answer Python-related questions among ... | 3 | 2010-02-02T03:27:17Z | 2,181,726 | <p>There's a perfectly usable monthly "data dump" of Stack Overflow under Creative Commons license, see for example <a href="http://blog.stackoverflow.com/2009/09/creative-commons-data-dump-sep-09/" rel="nofollow">here</a> (just the first one "under my thumb" of the many links about this -- at least one per month). Fo... | 3 | 2010-02-02T03:34:18Z | [
"python",
"screen-scraping"
] |
How do you make QT threads in python for pyqt? | 2,181,724 | <p>I see discussion about qt threads vs python threads but how do you create and call qt threads in python? how do you give it access to your functions in another thread?</p>
<p>Thanks!</p>
| 2 | 2010-02-02T03:34:05Z | 2,181,734 | <p>There's a good, fully worked-out example <a href="http://diotavelli.net/PyQtWiki/Threading,_Signals_and_Slots" rel="nofollow">here</a>.</p>
| 1 | 2010-02-02T03:35:59Z | [
"python",
"multithreading",
"pyqt"
] |
Parsing Python Response using httplib | 2,181,817 | <p>After connecting to a socket and capturing the response using .read() how do I parse the input stream and read lines?</p>
<p>I see the data is returned without any CRLF</p>
<pre><code><html><head><title>Apache Tomcat/6.0.16 - Error report</title><style><!--H1 {font-family:Tahoma,Ar... | 1 | 2010-02-02T04:05:08Z | 2,181,853 | <p>Use an HTML parser. <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beautiful Soup</a> seems to be a popular one.</p>
| 0 | 2010-02-02T04:16:26Z | [
"python",
"urllib",
"httplib"
] |
Parsing Python Response using httplib | 2,181,817 | <p>After connecting to a socket and capturing the response using .read() how do I parse the input stream and read lines?</p>
<p>I see the data is returned without any CRLF</p>
<pre><code><html><head><title>Apache Tomcat/6.0.16 - Error report</title><style><!--H1 {font-family:Tahoma,Ar... | 1 | 2010-02-02T04:05:08Z | 2,181,982 | <p>You have to parse the HTML. Python has several ways of parsing HTML - one of them the built-in <a href="http://docs.python.org/library/htmlparser.html" rel="nofollow">HTMLParser</a> module. Another, and probably better way, is the 3rd party <a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">Beaut... | 3 | 2010-02-02T04:58:33Z | [
"python",
"urllib",
"httplib"
] |
QT4, GTK+, wxWidgets or IronPython for a native Windows app using Python | 2,181,948 | <p>I need to build a native windows app using Python (and py2exe, I guess).</p>
<p>Feature requirements are:</p>
<ol>
<li>Taskbar icon</li>
<li>Alert notifications (next to Taskbar Icon)</li>
<li>Chromeless window (ideally a pretty, rounded, coloured one).</li>
<li>Webkit to render some of the Chromeless window</li>
... | 5 | 2010-02-02T04:46:01Z | 2,181,978 | <p>I've been using wxPython for sometime for deploying commercial grade apps.</p>
<p>You may have issues with qt's licensing.</p>
<p>I like wx because it's still very portable, and less dated than GTK. Which imo leaves only wx, but it's still an opinion call. Good luck.</p>
<p>wx can do all the things you've listed ... | 1 | 2010-02-02T04:56:22Z | [
"python",
"ironpython",
"wxwidgets",
"pygtk",
"pyqt4"
] |
QT4, GTK+, wxWidgets or IronPython for a native Windows app using Python | 2,181,948 | <p>I need to build a native windows app using Python (and py2exe, I guess).</p>
<p>Feature requirements are:</p>
<ol>
<li>Taskbar icon</li>
<li>Alert notifications (next to Taskbar Icon)</li>
<li>Chromeless window (ideally a pretty, rounded, coloured one).</li>
<li>Webkit to render some of the Chromeless window</li>
... | 5 | 2010-02-02T04:46:01Z | 2,182,074 | <p>Qt has a clean and consistent API, complete widgets set, excellent documentation and tools and Webkit integration is built in.</p>
<p>In my opinion none of the other libraries you cite offer all of these, so my advice would be to use PyQt4 if you can live with its licensing scheme.</p>
| 4 | 2010-02-02T05:32:28Z | [
"python",
"ironpython",
"wxwidgets",
"pygtk",
"pyqt4"
] |
python sqlite check points? | 2,182,062 | <p>I working with python sqlite3 , I found we have commit and rollback option.
Does sqlite3 allows something like check point ?</p>
<p>For example: Initial state is empty.
...
insert something
...
commit
....
.....
insert something
commit.
update something
Found some problem.Now I want to roll back to initial state... | 0 | 2010-02-02T05:29:08Z | 2,182,188 | <p>No, I don't know of any SQL database engine supporting "multiple undo" -- if one exists at all, Sqlite is definitely not it! For <em>nested</em> transactions (a less general concept), consider (per <a href="http://www.sqlite.org/lang_transaction.html" rel="nofollow">Sqlite's docs</a>!) the <code>SAVEPOINT</code> fe... | 2 | 2010-02-02T06:08:00Z | [
"python",
"sqlite3",
"rollback"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,124 | <p>I would use this:</p>
<pre><code>processed = [process(line.strip())
for line in open(config_file, 'r')
if line.strip() and not line.strip().startswith('#')]
</code></pre>
<p>The only ugliness I see here is all the repeated stripping. Getting rid of it complicates the function a bit:</p>
... | 1 | 2010-02-02T05:50:09Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,126 | <pre><code>for line in open("file"):
sline=line.strip()
if sline and not sline[0]=="#" :
print line.strip()
</code></pre>
<p>output</p>
<pre><code>$ cat file
one
#
#
two
three
$ ./python.py
one
two
three
</code></pre>
| 2 | 2010-02-02T05:50:55Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,142 | <p>The file is small, so performance is not really an issue. I will go for clarity than conciseness:</p>
<pre><code>fp = open('file.txt')
for line in fp:
line = line.strip()
if line and not line.startswith('#'):
# process
fp.close()
</code></pre>
<p>If you want, you can wrap this in a function.</p>
| 0 | 2010-02-02T05:54:15Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,167 | <p>This matches the description, ie </p>
<blockquote>
<p>strip lines that are either empty,
contain only spaces, or have # as a
first character, and then process
remaining lines</p>
</blockquote>
<p>So lines that start or end in spaces are passed through unfettered.</p>
<pre><code>with open("config_file","r"... | 1 | 2010-02-02T06:02:20Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,172 | <p>Generators are perfect for tasks like this. They are readable, maintain perfect separation of concerns, and efficient in memory-use and time.</p>
<pre><code>def RemoveComments(lines):
for line in lines:
if not line.strip().startswith('#'):
yield line
def RemoveBlankLines(lines):
for lin... | 5 | 2010-02-02T06:03:18Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,173 | <pre><code>lines = [r for r in open(thefile) if not r.isspace() and r[0] != '#']
</code></pre>
<p>The <code>.isspace()</code> method of strings is by far the best way to test if a string is entirely whitespace -- no need for contortions such as <code>len(r.strip()) == 0</code> (ech;-).</p>
| 3 | 2010-02-02T06:03:32Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,181 | <p>Using slightly newer idioms (or with Python 2.5 <code>from __future__ import with</code>) you could do this, which has the advantage of cleaning up safely yet is quite concise.</p>
<pre><code>with file('file.txt') as fp:
for line in fp:
line = line.strip()
if not line or line[0] == '#':
... | 0 | 2010-02-02T06:05:25Z | [
"python",
"coding-style",
"idioms"
] |
python style question around reading small files | 2,182,082 | <p>What is the most pythonic way to read in a named file, strip lines that are either empty, contain only spaces, or have # as a first character, and then process remaining lines? Assume it all fits easily in memory.</p>
<p>Note: it's not tough to do this -- what I'm asking is for the most pythonic way. I've been wr... | 3 | 2010-02-02T05:36:39Z | 2,182,656 | <p>I like Paul Hankin's thinking, but I'd do it differently:</p>
<pre><code>from itertools import ifilter, ifilterfalse, imap
with open(r'c:\temp\testfile.txt', 'rb') as f:
s1 = ifilterfalse(str.isspace, f)
s2 = ifilter(lambda x: not x.startswith('#'), s1)
s3 = imap(str.rstrip, s2)
print "\n".join(s3)... | 1 | 2010-02-02T08:19:50Z | [
"python",
"coding-style",
"idioms"
] |
How do I reply to an email using the Python imaplib and include the original message? | 2,182,196 | <p>I'm currently using <a href="http://docs.python.org/library/imaplib.html"><code>imaplib</code></a> to fetch email messages from a server and process the contents and attachments.</p>
<p>I'd like to reply to the messages with a status/error message and links to the resulting generated content on my site if they can ... | 13 | 2010-02-02T06:10:02Z | 2,189,630 | <p>The original MIME tree structure of the incoming message is as follows (using <code>email.iterators._structure(msg)</code>):</p>
<pre><code>multipart/mixed
text/html (message)
application/octet-stream (attachment 1)
application/octet-stream (attachment 2)
</code></pre>
<p>Replying via GM... | 14 | 2010-02-03T04:09:59Z | [
"python",
"django",
"email",
"mime",
"imaplib"
] |
Django templates condition check | 2,182,512 | <p>All,</p>
<p>Can t we do the following in templates</p>
<p>{% if subject.id == selected_id %}</p>
<p>and also cannot we assign variable like {{selected="selected"}}</p>
<p>Thank........</p>
| 1 | 2010-02-02T07:42:12Z | 2,182,519 | <p>Not as shown. Use the <code>ifequal</code> and <code>with</code> template tags instead.</p>
| 0 | 2010-02-02T07:44:12Z | [
"python",
"django"
] |
Django templates condition check | 2,182,512 | <p>All,</p>
<p>Can t we do the following in templates</p>
<p>{% if subject.id == selected_id %}</p>
<p>and also cannot we assign variable like {{selected="selected"}}</p>
<p>Thank........</p>
| 1 | 2010-02-02T07:42:12Z | 2,182,524 | <p>This comparison will work in Django 1.2. For 1.1 you have to use <a href="http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#ifequal">ifequal</a>:</p>
<pre><code>{% ifequal subject.id selected_id %}
</code></pre>
<p>For variable assignment you can use <a href="http://docs.djangoproject.com/en/1.1/ref/te... | 5 | 2010-02-02T07:45:27Z | [
"python",
"django"
] |
python sqlite 3 : roll back to save point fails | 2,182,591 | <pre><code>def rollback_savepoint(self):
try:
self.db.execute("rollback to savepoint pt;")
except:
print "roll back to save point failed"
else:
print "Roll back to save point. Done"
</code></pre>
<p>In above code snippet , It says "roll back to save point failed".
What went wrong?</... | 1 | 2010-02-02T08:06:13Z | 2,182,763 | <p>Don't ever catch exceptions you aren't handling. Let it raise, so you can have useful error messages and tracebacks.</p>
<p>Example:</p>
<pre><code>>>> c.execute('rollback to savepoint pt;')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: no s... | 3 | 2010-02-02T08:44:39Z | [
"python",
"sqlite3"
] |
Drawing Hebrew text to and image using Image module (python) | 2,182,787 | <p>This is an issue I already asked about and several got answers but the problem remained.
when I try to write in hebrew to an image using Image module I get instead of the hebrew lettring some other (ascii??) lettering. if I convert to unicode or ascii I get an error that it doesn't support. I got here a reference to... | 2 | 2010-02-02T08:52:02Z | 2,182,812 | <p>Sounds like PIL was built without FreeType support. Install the FreeType dev files and rebuild PIL again.</p>
| 3 | 2010-02-02T08:56:44Z | [
"python",
"image",
"hebrew",
"bidirectional"
] |
Drawing Hebrew text to and image using Image module (python) | 2,182,787 | <p>This is an issue I already asked about and several got answers but the problem remained.
when I try to write in hebrew to an image using Image module I get instead of the hebrew lettring some other (ascii??) lettering. if I convert to unicode or ascii I get an error that it doesn't support. I got here a reference to... | 2 | 2010-02-02T08:52:02Z | 2,234,852 | <p>the problem was the PIL 1.1.7 doesn't work well with windows XP. the same code runs well under linux or with XP but with PIL 1.1.6
mystory is solved</p>
| 0 | 2010-02-10T06:24:11Z | [
"python",
"image",
"hebrew",
"bidirectional"
] |
How can I pack several decorators into one? | 2,182,858 | <p>I have several decorators on each function, is there a way to pack them in to one instead?</p>
<pre><code>@fun1
@fun2
@fun3
def do_stuf():
pass
</code></pre>
<p>change to: </p>
<pre><code>@all_funs #runs fun1 fun2 and fun3, how should all_funs look like?
def do_stuf():
pass
</code></pre>
| 10 | 2010-02-02T09:04:37Z | 2,182,868 | <pre><code>def all_funs(f):
return fun1(fun2(fun3(f)))
</code></pre>
| 1 | 2010-02-02T09:06:48Z | [
"python",
"decorator"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.