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
Why does Django admin try to encode strings into ASCII rather than Unicode? Or is this error something different than it looks like?
2,002,460
<p>I've got the following error:</p> <blockquote> <p>TemplateSyntaxError at /admin/results_cop/copsegmentresult/</p> <p>Caught an exception while rendering: ('ascii', 'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96', 98, 99, 'ord...
3
2010-01-04T21:45:58Z
2,002,574
<p>I'm guessing you're asking Django to render a byte string. No <code>u</code> at the start of this:</p> <pre><code>'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96' </code></pre> <p>So Django is probably trying to encode it to the page's encoding...
7
2010-01-04T22:00:23Z
[ "python", "django", "unicode", "encoding", "django-admin" ]
Why does Django admin try to encode strings into ASCII rather than Unicode? Or is this error something different than it looks like?
2,002,460
<p>I've got the following error:</p> <blockquote> <p>TemplateSyntaxError at /admin/results_cop/copsegmentresult/</p> <p>Caught an exception while rendering: ('ascii', 'ISU European Figure Skating Championships 2009: Senior Ladies Ladies: Short Program - 2. Susanna P\xc3\x96YKI\xc3\x96', 98, 99, 'ord...
3
2010-01-04T21:45:58Z
17,178,207
<p>If anyone is confused by bobince's answer, think of this:</p> <p>The fields from the model are already in unicode format.</p> <p>when you have a unicode function like this:</p> <pre><code>def __unicode__(self): return "{0}".format(self.field_one) </code></pre> <p>It is actually returning a ASCII string(which m...
3
2013-06-18T20:22:44Z
[ "python", "django", "unicode", "encoding", "django-admin" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
2,002,566
<p>Are you logging in to admin as a superuser? If not, it could be a permissions problem.</p>
3
2010-01-04T21:59:40Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
2,002,593
<p>Do you have your apps in the INSTALLED_APPS section in settings.py? Make sure it has your apps listed there. My section reads</p> <pre><code>INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.admin', 'django.contrib.sites', 'squick.items', 'cowsite.s...
7
2010-01-04T22:04:11Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
2,003,858
<p>Not sure which version of django you're using but the current docs suggest <strong>including</strong> the admin urls.</p> <pre><code> ('^admin/', include(admin.site.urls)) </code></pre>
0
2010-01-05T02:46:47Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
2,004,969
<p>You didn't answer Antony's question. Are you logging in as a superuser, or at least with a user with add/edit rights for the applications? If not, you won't see them.</p>
-1
2010-01-05T09:04:47Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
2,027,239
<p>By coincidence I had the same problem this morning. Briefly, this is what worked for me (see references for details):</p> <p>In the top level directory of MyApp (ie same directory as models.py, etc.) I added a python module admin.py, containing:</p> <pre><code>from models import ThisModel, ThatModel from django.c...
4
2010-01-08T11:33:01Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
16,751,235
<p>For other's coming across this, I had the same issue due to grappelli.dashboard being in the installed apps but not actually installed in the virtualenv, so do a pip freeze and ensure all your requirements are actually installed.</p>
0
2013-05-25T15:48:19Z
[ "python", "django", "django-admin", "pinax" ]
Apps won't show in Django admin
2,002,549
<p>I've read all the other threads but I still don't get why my apps are not showing up in Django admin. Everything else works fine.</p> <p>My apps are in settings.py</p> <p>I have admin.autodiscover in my root urls.py file</p> <pre><code>from django.conf.urls.defaults import * from django.conf import settings from...
4
2010-01-04T21:57:00Z
18,739,266
<p>I had the same problem, what worked for me was changing this line in urls.py:</p> <pre><code>url(r'^admin/', include(admin.site.urls)), </code></pre> <p>to</p> <pre><code>url('^admin/', include(admin.site.urls)), </code></pre> <p>(Removing the <strong>r</strong> in the first bit of code) For some reason I am not...
0
2013-09-11T10:56:31Z
[ "python", "django", "django-admin", "pinax" ]
GQL with two tables
2,002,856
<p>Hello i am doing a very small application in google appengine and i use python. My problem is that i have two tables using de db.model ("clients" and "requests"). The table "client" has got the email and name fields and the table "requests" has got the email and issue fields. I want to do a query that returns for ea...
0
2010-01-04T22:50:18Z
2,003,187
<p>The app engine datastore does not support joins, so you will not be able to solve this problem with GQL. You can use two gets, one for client and one for request, or you can use a ReferenceProperty to establish a relationship between the two entities.</p> <p>If you need to model a one-to-many relationship, you can...
3
2010-01-04T23:50:40Z
[ "python", "django", "google-app-engine", "gql" ]
GQL with two tables
2,002,856
<p>Hello i am doing a very small application in google appengine and i use python. My problem is that i have two tables using de db.model ("clients" and "requests"). The table "client" has got the email and name fields and the table "requests" has got the email and issue fields. I want to do a query that returns for ea...
0
2010-01-04T22:50:18Z
2,053,736
<p>using this models:</p> <pre><code>class Client(db.Model): email = db.StringProperty() name = db.StringProperty() class Request(db.Model): client = db.ReferenceProperty(Client, collection_name='requests') issue = db.StringProperty() </code></pre> <p>With this code can query the data</p> <pre><...
0
2010-01-13T01:13:41Z
[ "python", "django", "google-app-engine", "gql" ]
how can i use '__set__'
2,003,284
<pre><code>class A(object): def __get__(self, instance, owner):#why i can't find argument 'key',where is 'key' #print ower.instance print instance,owner def __set__(self,instance,value): instance=value class X(object): a = A() xx=X() xx.a='aaa' print xx.a#None </code></pre>
1
2010-01-05T00:13:12Z
2,003,345
<p>Do you mean to be using __getattribute__? It has a parameter that is commonly called key; although it can be any name at all. And the definition that you have for __set__ looks like it should be for __setattribute__</p>
2
2010-01-05T00:25:12Z
[ "python" ]
how can i use '__set__'
2,003,284
<pre><code>class A(object): def __get__(self, instance, owner):#why i can't find argument 'key',where is 'key' #print ower.instance print instance,owner def __set__(self,instance,value): instance=value class X(object): a = A() xx=X() xx.a='aaa' print xx.a#None </code></pre>
1
2010-01-05T00:13:12Z
2,003,350
<p>I think you could read about descriptors:</p> <p><a href="http://users.rcn.com/python/download/Descriptor.htm" rel="nofollow">http://users.rcn.com/python/download/Descriptor.htm</a></p> <p>Or maybe what you want is to customize attribute access:</p> <p><a href="http://docs.python.org/reference/datamodel.html#cust...
1
2010-01-05T00:25:48Z
[ "python" ]
how can i use '__set__'
2,003,284
<pre><code>class A(object): def __get__(self, instance, owner):#why i can't find argument 'key',where is 'key' #print ower.instance print instance,owner def __set__(self,instance,value): instance=value class X(object): a = A() xx=X() xx.a='aaa' print xx.a#None </code></pre>
1
2010-01-05T00:13:12Z
2,003,361
<p>Hettinger's <a href="http://users.rcn.com/python/download/Descriptor.htm" rel="nofollow">HowTo Guide for Descriptors</a> covers this well. Quoting from it:</p> <blockquote> <p>Descriptor Protocol</p> <p><code>descr.__get__(self, obj, type=None) --&gt; value</code></p> <p><code>descr.__set__(self, obj, v...
4
2010-01-05T00:29:01Z
[ "python" ]
How to force Python to ignore re.DOTALL in re.findall() statement?
2,003,461
<p>I have been banging my head against the keyboard in search of enlightenment through Google and all Python docs I could get my hands on, but could not find an answer to an issue I'm encountering.</p> <p>I have the following regex that I run against a website, but Python insists in setting re.DOTALL on it, even thoug...
1
2010-01-05T00:57:34Z
2,003,476
<p><code>.+&gt;</code> should change to <code>[^&gt;]+&gt;</code> and</p> <p><code>.*?&gt;</code> to <code>[^&gt;]*&gt;</code></p> <p>You can try replacing others dots into <code>[^\r\n]</code> too, but above 2 changes should be enough.</p>
2
2010-01-05T01:03:22Z
[ "python", "regex", "flags" ]
How to use Python tkSimpleDialog.askstring
2,003,504
<p>I want to use the response from an askstring prompt to set a variable. Unfortunately, I have the dilemma that I'm trapped in the loop asking the question or the window refuses to draw because the variable (urltoopen) has no value. The code as it stands:</p> <pre><code>urltoopen = tkSimpleDialog.askstring('Address'...
2
2010-01-05T01:11:57Z
2,003,651
<p><a href="http://www.pythonware.com/library/tkinter/introduction/x1164-data-entry.htm" rel="nofollow">tkSimpleDialog.askstring</a> returns <code>None</code> if the user clicks Cancel or closes the window (instead of clicking Ok or using the Enter key); you should check for that (what do you want to do if the user cho...
2
2010-01-05T01:48:14Z
[ "python", "user-input", "tkinter" ]
How to use Python tkSimpleDialog.askstring
2,003,504
<p>I want to use the response from an askstring prompt to set a variable. Unfortunately, I have the dilemma that I'm trapped in the loop asking the question or the window refuses to draw because the variable (urltoopen) has no value. The code as it stands:</p> <pre><code>urltoopen = tkSimpleDialog.askstring('Address'...
2
2010-01-05T01:11:57Z
2,034,236
<pre><code> root = Tk() try: urltoopen = tkSimpleDialog.askstring('Ask Address', 'Where do we get the pictures from?') usock = urllib2.urlopen(urltoopen) data = usock.read() ...
0
2010-01-09T17:34:52Z
[ "python", "user-input", "tkinter" ]
Why are django projects python packages?
2,003,527
<p>Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the <code>__init__.py</code> at all? The project is perfectly useful witho...
2
2010-01-05T01:17:17Z
2,003,550
<p>We have a single project that we "subclass" of sorts for other projects. So we have other projects that import stuff from the main project. I guess for us it provides the common namespace that contains all the other apps.</p> <p>We could move to a package with all our apps in it separate from the projects i guess. ...
2
2010-01-05T01:22:51Z
[ "python", "django" ]
Why are django projects python packages?
2,003,527
<p>Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the <code>__init__.py</code> at all? The project is perfectly useful witho...
2
2010-01-05T01:17:17Z
2,003,748
<p>There isn't a requirement that apps be inside the project's namespace, to my knowledge. Just that they be on the $PYTHONPATH. As such, they are usable by any other code on the system which shares the same PYTHONPATH. </p>
1
2010-01-05T02:15:11Z
[ "python", "django" ]
Why are django projects python packages?
2,003,527
<p>Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the <code>__init__.py</code> at all? The project is perfectly useful witho...
2
2010-01-05T01:17:17Z
2,003,806
<p>I think the idea is that you can reuse the applications but you don't need to move them from the project where they were initially created. If the project weren't a package you would need to copy/move the application you want to reuse to a python package. Because of that being the project itself a proper python pack...
0
2010-01-05T02:33:13Z
[ "python", "django" ]
Why are django projects python packages?
2,003,527
<p>Why aren't they simply directories? Any good advice says to keep as much as possible in the apps and not to couple them to the project. The very ability to import an app as project.application discourages this. Why does django-admin.py create the <code>__init__.py</code> at all? The project is perfectly useful witho...
2
2010-01-05T01:17:17Z
2,007,779
<p>The core of a project is a settings.py and a root urls.py. Both of those are Python modules, thus they need to be importable somehow. You <em>can</em> put the project directory directly on the Python path and thus make them importable as top-level modules, but that's arguably even worse practice. Better to have the ...
1
2010-01-05T17:17:39Z
[ "python", "django" ]
AppEngine/Python, query database and send multiple images to the client as a response to a single get request
2,003,630
<p>I am working on a social-network type of application on App Engine, and would like to send multiple images to the client based on a single get request. In particular, when a client loads a page, they should see all images that are associated with their account. </p> <p>I am using python on the server side, and woul...
0
2010-01-05T01:44:04Z
2,003,652
<p>Trying to send all of the images in one request means that you will be fighting very hard against some of the fundamental assumptions of the web and browser technology. If you don't have a really, really compelling reason to do this, you should consider delivering one image per request. That already works now, no sw...
0
2010-01-05T01:49:09Z
[ "python", "ajax", "image", "google-app-engine" ]
AppEngine/Python, query database and send multiple images to the client as a response to a single get request
2,003,630
<p>I am working on a social-network type of application on App Engine, and would like to send multiple images to the client based on a single get request. In particular, when a client loads a page, they should see all images that are associated with their account. </p> <p>I am using python on the server side, and woul...
0
2010-01-05T01:44:04Z
2,003,690
<p>Send the client URLs for all the images in one hit, and deal with it on the client. That fits with the design of the protocol, and still lets you only make one query. The client might, if you're lucky, be able to stream those back in its next request, but the neat thing is that it'll work (eventually) even if it c...
0
2010-01-05T01:56:30Z
[ "python", "ajax", "image", "google-app-engine" ]
AppEngine/Python, query database and send multiple images to the client as a response to a single get request
2,003,630
<p>I am working on a social-network type of application on App Engine, and would like to send multiple images to the client based on a single get request. In particular, when a client loads a page, they should see all images that are associated with their account. </p> <p>I am using python on the server side, and woul...
0
2010-01-05T01:44:04Z
2,003,692
<p>The App Engine part isn't much of a problem (as long as the number of images and total size doesn't exceed GAE's limits), but the user's browser is unlikely to know what to do in order to <em>receive</em> multiple payloads per <code>GET</code> request -- that's just not how the web works. I guess you could concaten...
2
2010-01-05T01:57:11Z
[ "python", "ajax", "image", "google-app-engine" ]
AppEngine/Python, query database and send multiple images to the client as a response to a single get request
2,003,630
<p>I am working on a social-network type of application on App Engine, and would like to send multiple images to the client based on a single get request. In particular, when a client loads a page, they should see all images that are associated with their account. </p> <p>I am using python on the server side, and woul...
0
2010-01-05T01:44:04Z
2,041,528
<p>As an improvement to Alex's answer, there's no need to use memcache: Simply do a keys-only query to get a list of keys of images you want to send to the client, then use db.get() to fetch the image corresponding to the required key for each image request. This requires roughly the same amount of effort as a single r...
1
2010-01-11T11:39:13Z
[ "python", "ajax", "image", "google-app-engine" ]
Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other)
2,003,693
<p>Looking for advice on the best technique for saving complex Python data structures across program sessions.</p> <p>Here's a list of techniques I've come up with so far:</p> <ul> <li>pickle/cpickle</li> <li>json</li> <li>jsonpickle</li> <li>xml</li> <li>database (like SQLite)</li> </ul> <p>Pickle is the easiest an...
10
2010-01-05T01:57:23Z
2,003,704
<p>You have a misconception about pickles: they are guaranteed to work across Python versions. You simply have to choose a protocol version that is supported by all the Python versions you care about.</p> <p>The technique you left out is marshal, which is not guaranteed to work across Python versions (and btw, is how...
15
2010-01-05T01:59:19Z
[ "python", "json", "sqlite", "pickle" ]
Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other)
2,003,693
<p>Looking for advice on the best technique for saving complex Python data structures across program sessions.</p> <p>Here's a list of techniques I've come up with so far:</p> <ul> <li>pickle/cpickle</li> <li>json</li> <li>jsonpickle</li> <li>xml</li> <li>database (like SQLite)</li> </ul> <p>Pickle is the easiest an...
10
2010-01-05T01:57:23Z
2,003,715
<p>You left out the <a href="http://docs.python.org/library/marshal.html#module-marshal" rel="nofollow">marshal</a> and <a href="http://docs.python.org/library/shelve.html#module-shelve" rel="nofollow">shelve</a> modules.</p> <p>Also this <a href="http://docs.python.org/library/persistence.html" rel="nofollow">python ...
3
2010-01-05T02:01:34Z
[ "python", "json", "sqlite", "pickle" ]
Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other)
2,003,693
<p>Looking for advice on the best technique for saving complex Python data structures across program sessions.</p> <p>Here's a list of techniques I've come up with so far:</p> <ul> <li>pickle/cpickle</li> <li>json</li> <li>jsonpickle</li> <li>xml</li> <li>database (like SQLite)</li> </ul> <p>Pickle is the easiest an...
10
2010-01-05T01:57:23Z
2,003,721
<p>Have you looked at <a href="http://pyyaml.org/wiki/PySyck" rel="nofollow">PySyck</a> or <a href="http://pyyaml.org/wiki/PyYAML" rel="nofollow">pyYAML</a>?</p>
2
2010-01-05T02:03:03Z
[ "python", "json", "sqlite", "pickle" ]
Best way to save complex Python data structures across program sessions (pickle, json, xml, database, other)
2,003,693
<p>Looking for advice on the best technique for saving complex Python data structures across program sessions.</p> <p>Here's a list of techniques I've come up with so far:</p> <ul> <li>pickle/cpickle</li> <li>json</li> <li>jsonpickle</li> <li>xml</li> <li>database (like SQLite)</li> </ul> <p>Pickle is the easiest an...
10
2010-01-05T01:57:23Z
2,176,880
<p>What are your criteria for "best" ?</p> <ul> <li><code>pickle</code> can do most Python structures, deeply nested ones too</li> <li>sqlite dbs can be easily queried (if you know sql :)</li> <li>speed / memory ? trust no benchmarks that you haven't faked yourself.</li> </ul> <p>(Fine print:<br> cPickle.dump(protoco...
2
2010-02-01T13:22:03Z
[ "python", "json", "sqlite", "pickle" ]
google app engine jsonpickle
2,003,817
<p>Has anyone got jsonpickle working on the google app engine? My logs say there is no module but there is a module as sure as you're born. i'm using jsonpickle 0.32.</p> <pre><code>&lt;type 'exceptions.ImportError'&gt;: No module named jsonpickle Traceback (most recent call last): File "/base/data/home/apps/xxxxx/x...
4
2010-01-05T02:34:55Z
2,003,849
<p>As <a href="http://www.mail-archive.com/google-appengine@googlegroups.com/msg18556.html" rel="nofollow">this post</a> explains, <code>jsonpickle</code> requires one of a few underlying JSON modules. I would fix the issue as follows -- put at the top of your module(s) that need jsonpickle the following few lines:</p>...
3
2010-01-05T02:45:15Z
[ "python", "json", "google-app-engine", "jsonpickle" ]
google app engine jsonpickle
2,003,817
<p>Has anyone got jsonpickle working on the google app engine? My logs say there is no module but there is a module as sure as you're born. i'm using jsonpickle 0.32.</p> <pre><code>&lt;type 'exceptions.ImportError'&gt;: No module named jsonpickle Traceback (most recent call last): File "/base/data/home/apps/xxxxx/x...
4
2010-01-05T02:34:55Z
2,006,882
<p>I have managed to make it work registering <strong>django.utils.simplejson</strong> as a json encoder/decoder. In this real file index.py class Pizza is encoded and decoded back:</p> <pre><code>from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app import jsonpickle clas...
4
2010-01-05T15:14:19Z
[ "python", "json", "google-app-engine", "jsonpickle" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
2,003,871
<p>You could use the datetime module. You can specify the format and everything. Here's the link: <a href="http://docs.python.org/library/datetime.html" rel="nofollow">http://docs.python.org/library/datetime.html</a></p> <p>Look into datetime.datetime( params ) and datetime.timedelta( params ). Hope it all goes well ;...
1
2010-01-05T02:49:58Z
[ "python", "datetime", "calendar" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
2,003,894
<p>Here's some code:</p> <pre><code>import datetime now = datetime.datetime.now() now_day_1 = now - datetime.timedelta(days=now.weekday()) dates = {} for n_week in range(3): dates[n_week] = [(now_day_1 + datetime.timedelta(days=d+n_week*7)).strftime("%m/%d/%Y") for d in range(7)] print dates </code></pre> <p...
0
2010-01-05T02:59:13Z
[ "python", "datetime", "calendar" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
2,003,896
<p>How do you identify weeks? Here I'm identifying by a day in that week, using a function which gets the Sunday in that week (what you used in your example), and then returns it plus the next 6 days.</p> <pre><code>import datetime one_day = datetime.timedelta(days=1) def get_week(date): """Return the full week (...
3
2010-01-05T02:59:49Z
[ "python", "datetime", "calendar" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
2,003,937
<p>If you're OK with the ISO standard:</p> <pre><code>&gt;&gt;&gt; import collections &gt;&gt;&gt; dd = collections.defaultdict(list) &gt;&gt;&gt; jan1 = datetime.date(2010, 1, 1) &gt;&gt;&gt; oneday = datetime.timedelta(days=1) &gt;&gt;&gt; allyear = [jan1 + k*oneday for k in range(365 + 6)] &gt;&gt;&gt; for d in all...
1
2010-01-05T03:09:30Z
[ "python", "datetime", "calendar" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
2,004,013
<p>Beware! If you want to define YOUR OWN week numbers, you could use the generator expression provided <a href="http://stackoverflow.com/questions/2003870/how-can-i-select-all-of-the-sundays-for-a-year-using-python">in your first question</a> which, by the way, got an awesome answer). If you want to follow the ISO con...
16
2010-01-05T03:32:44Z
[ "python", "datetime", "calendar" ]
How can I get the current week using Python?
2,003,841
<p>Using Python...</p> <p>How can I get a list of the days in a specific week?</p> <p>Something like...</p> <pre><code>{ '1' : ['01/03/2010','01/04/2010','01/05/2010','01/06/2010','01/07/2010','01/08/2010','01/09/2010'], '2' : ['01/10/2010','01/11/2010','01/12/2010','01/13/2010','01/14/2010','01/15/2010','01/16/20...
10
2010-01-05T02:42:57Z
27,975,134
<p>There is a 3 lines method I developed after read that question:</p> <pre><code>from datetime import timedelta def get_week_dates(base_date, start_day, end_day=None): """ Return entire week of dates based on given date limited by start_day and end_day. If end_day is None, return only start_day. &gt...
0
2015-01-15T23:50:49Z
[ "python", "datetime", "calendar" ]
where is the '__path__' comes from
2,003,859
<p>i can't find who defined the <code>'__path__'</code>,why <code>'__path__'</code> can be use.</p> <pre><code>import os import sys import warnings import ConfigParser # ConfigParser is not a virtualenv module, so we can use it to find the stdlib dirname = os.path.dirname distutils_path = os.path.join(os.path.dirn...
2
2010-01-05T02:47:09Z
2,003,922
<p>I found the following description of the __path__ variable:</p> <blockquote> <p>It is initialized to a list of one item, containing the directory name of the package (a subdirectory of a directory on sys.path). Changing __path__ changes the list of directories that are searched for submodules of the pac...
3
2010-01-05T03:05:57Z
[ "python" ]
where is the '__path__' comes from
2,003,859
<p>i can't find who defined the <code>'__path__'</code>,why <code>'__path__'</code> can be use.</p> <pre><code>import os import sys import warnings import ConfigParser # ConfigParser is not a virtualenv module, so we can use it to find the stdlib dirname = os.path.dirname distutils_path = os.path.join(os.path.dirn...
2
2010-01-05T02:47:09Z
2,003,940
<p>You really need to read some Python documentation and learn the basics of the language.</p> <p>I checked, and you seem to speak Chinese. Here are Python documentation resources in Chinese:</p> <p><a href="http://www6.uniovi.es/python/doc/NonEnglish.html#chinese">http://www6.uniovi.es/python/doc/NonEnglish.html#ch...
8
2010-01-05T03:10:59Z
[ "python" ]
Python ftplib: Overwriting a File doesn't work with STOR
2,003,863
<p>I want to overwrite an existing file "test.txt" on my ftp server with this code:</p> <pre><code>from ftplib import FTP HOST = 'host.com' FTP_NAME = 'username' FTP_PASS = 'password' ftp = FTP(HOST) ftp.login(FTP_NAME, FTP_PASS) file = open('test.txt', 'r') ftp.storlines('STOR test.txt', file) ftp.quit() file.close...
0
2010-01-05T02:47:41Z
2,003,926
<p>I think you need to open the file in write mode</p> <pre><code>file = open('test.txt', 'w') </code></pre>
-1
2010-01-05T03:06:53Z
[ "python", "ftp", "file-upload" ]
Python ftplib: Overwriting a File doesn't work with STOR
2,003,863
<p>I want to overwrite an existing file "test.txt" on my ftp server with this code:</p> <pre><code>from ftplib import FTP HOST = 'host.com' FTP_NAME = 'username' FTP_PASS = 'password' ftp = FTP(HOST) ftp.login(FTP_NAME, FTP_PASS) file = open('test.txt', 'r') ftp.storlines('STOR test.txt', file) ftp.quit() file.close...
0
2010-01-05T02:47:41Z
2,003,959
<p>nvm, it's my fault... I forgot to change the current working directory to /public_html thanks anyway!</p>
0
2010-01-05T03:20:20Z
[ "python", "ftp", "file-upload" ]
How can I select all of the Sundays for a year using Python?
2,003,870
<p>Using Python...</p> <p>How can I select all of the Sundays (or any day for that matter) in a year?</p> <pre><code>[ '01/03/2010','01/10/2010','01/17/2010','01/24/2010', ...] </code></pre> <p>These dates represent the Sundays for 2010. This could also apply to any day of the week I suppose.</p>
11
2010-01-05T02:48:54Z
2,003,906
<p>You can use <code>date</code> from the <a href="http://docs.python.org/library/datetime.html"><code>datetime</code></a> module to find the first Sunday in a year and then keep adding seven days, generating new Sundays:</p> <pre><code>from datetime import date, timedelta def allsundays(year): d = date(year, 1, 1...
26
2010-01-05T03:02:11Z
[ "python", "datetime", "calendar" ]
How can I select all of the Sundays for a year using Python?
2,003,870
<p>Using Python...</p> <p>How can I select all of the Sundays (or any day for that matter) in a year?</p> <pre><code>[ '01/03/2010','01/10/2010','01/17/2010','01/24/2010', ...] </code></pre> <p>These dates represent the Sundays for 2010. This could also apply to any day of the week I suppose.</p>
11
2010-01-05T02:48:54Z
2,003,981
<p>Using the <a href="http://labix.org/python-dateutil" rel="nofollow">dateutil module</a>, you could generate the list this way:</p> <pre><code>#!/usr/bin/env python import dateutil.relativedelta as relativedelta import dateutil.rrule as rrule import datetime year=2010 before=datetime.datetime(year,1,1) after=datetim...
3
2010-01-05T03:24:21Z
[ "python", "datetime", "calendar" ]
PyQt4 Signalling between classes
2,004,060
<p>I have a family of classes (based on the same parent class) that are data cells in a QTableWidget (so they are all derived from QItemDelegate).</p> <p>I'm trying to create a signal that these classes can pass up to the controller to communicate data changes. </p> <p>I can't find the right combination (despite muc...
1
2010-01-05T03:47:30Z
2,009,818
<p>criteria.py</p> <pre><code>def criteria_change(row, col, new_value): print "change at", row, col, "new_value:", new_value class Criteria: def __init__(self, row, col): self.row, self.col = row, col def on_change(self): criteria_change(self.row, self.col, self.value()) </code></pre> <p...
0
2010-01-05T23:03:00Z
[ "python", "pyqt", "pyqt4" ]
PyQt4 Signalling between classes
2,004,060
<p>I have a family of classes (based on the same parent class) that are data cells in a QTableWidget (so they are all derived from QItemDelegate).</p> <p>I'm trying to create a signal that these classes can pass up to the controller to communicate data changes. </p> <p>I can't find the right combination (despite muc...
1
2010-01-05T03:47:30Z
2,020,550
<p>I'm really embarrassed about this. Hopefully this will help somebody else. </p> <p>I didn't call the Qt initialization for the appropriate object:</p> <pre><code>class YesNo(Criteria): def __init__(self, name, ctype): Criteria.__init__(self) # &lt;&lt;&lt;&lt;----- This was missing befor...
1
2010-01-07T13:25:01Z
[ "python", "pyqt", "pyqt4" ]
UnicodeEncodeError on joining file name
2,004,137
<p>It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code:</p> <pre><code>filename = 'Spywaj.ttf' print repr(filename) &gt;&gt; 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) </code></pre> <p>But the file is v...
4
2010-01-05T04:20:05Z
2,004,179
<p>In both Latin-1 (ISO-8859-1) and Windows-1252, 0xc2 would a capital A with a circumflex accent... doesn't seem to be anywhere in the code you show! Can you please add a</p> <pre><code>print repr(filename) </code></pre> <p>before the <code>os.path.join</code> call (and also put the <code>'/dirname'</code> in a var...
7
2010-01-05T04:34:15Z
[ "python", "unicode", "filenames" ]
UnicodeEncodeError on joining file name
2,004,137
<p>It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code:</p> <pre><code>filename = 'Spywaj.ttf' print repr(filename) &gt;&gt; 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) </code></pre> <p>But the file is v...
4
2010-01-05T04:20:05Z
2,004,494
<pre><code>filename = filename.decode('utf-8').encode("latin-1") </code></pre> <p>works for me with the file from <a href="http://download.appfile.com/Splywaj.zip" rel="nofollow">Splywaj.zip</a></p> <pre><code>&gt;&gt;&gt; os.path.isfile(filename.decode("utf8").encode("latin-1")) True &gt;&gt;&gt; </code></pre>
2
2010-01-05T06:18:01Z
[ "python", "unicode", "filenames" ]
UnicodeEncodeError on joining file name
2,004,137
<p>It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code:</p> <pre><code>filename = 'Spywaj.ttf' print repr(filename) &gt;&gt; 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) </code></pre> <p>But the file is v...
4
2010-01-05T04:20:05Z
2,006,157
<h3>Evidence problem 1 ###</h3> <blockquote> <p>It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code:</p> </blockquote> <pre><code>filename = 'Spywaj.ttf' print repr(filename) &gt;&gt; 'Sp\xc2\x88ywaj.ttf' filepath = os.path....
0
2010-01-05T13:06:38Z
[ "python", "unicode", "filenames" ]
UnicodeEncodeError on joining file name
2,004,137
<p>It throws out "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2: ordinal not in range(128)" when executing following code:</p> <pre><code>filename = 'Spywaj.ttf' print repr(filename) &gt;&gt; 'Sp\xc2\x88ywaj.ttf' filepath = os.path.join('/dirname', filename) </code></pre> <p>But the file is v...
4
2010-01-05T04:20:05Z
26,251,176
<p>I have fixed the UnicodeDecodeError by adding these lines to <code>/etc/apache2/envvars</code> and restarting Apache.</p> <pre><code>export LANG='en_US.UTF-8' export LC_ALL='en_US.UTF-8' </code></pre> <p>as described here: <a href="https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#if-you-get-a-...
3
2014-10-08T07:17:31Z
[ "python", "unicode", "filenames" ]
Increment Numpy array with repeated indices
2,004,364
<p>I have a Numpy array and a list of indices whose values I would like to increment by one. This list may contain repeated indices, and I would like the increment to scale with the number of repeats of each index. Without repeats, the command is simple:</p> <pre><code>a=np.zeros(6).astype('int') b=[3,2,5] a[b]+=1 </c...
8
2010-01-05T05:37:23Z
2,004,413
<p>Why not?</p> <pre><code>for i in b: a[i] += 1 </code></pre>
-3
2010-01-05T05:52:24Z
[ "python", "indexing", "numpy" ]
Increment Numpy array with repeated indices
2,004,364
<p>I have a Numpy array and a list of indices whose values I would like to increment by one. This list may contain repeated indices, and I would like the increment to scale with the number of repeats of each index. Without repeats, the command is simple:</p> <pre><code>a=np.zeros(6).astype('int') b=[3,2,5] a[b]+=1 </c...
8
2010-01-05T05:37:23Z
2,004,468
<p>After you do</p> <pre><code>bbins=np.bincount(b) </code></pre> <p>why not do:</p> <pre><code>a[:len(bbins)] += bbins </code></pre> <p>(Edited for further simplification.)</p>
3
2010-01-05T06:08:01Z
[ "python", "indexing", "numpy" ]
Increment Numpy array with repeated indices
2,004,364
<p>I have a Numpy array and a list of indices whose values I would like to increment by one. This list may contain repeated indices, and I would like the increment to scale with the number of repeats of each index. Without repeats, the command is simple:</p> <pre><code>a=np.zeros(6).astype('int') b=[3,2,5] a[b]+=1 </c...
8
2010-01-05T05:37:23Z
2,034,290
<p>If <code>b</code> is a small subrange of <code>a</code>, one can refine Alok's answer like this:</p> <pre><code>import numpy as np a = np.zeros( 100000, int ) b = np.array( [99999, 99997, 99999] ) blo, bhi = b.min(), b.max() bbins = np.bincount( b - blo ) a[blo:bhi+1] += bbins print a[blo:bhi+1] # 1 0 2 </code><...
1
2010-01-09T17:52:41Z
[ "python", "indexing", "numpy" ]
Increment Numpy array with repeated indices
2,004,364
<p>I have a Numpy array and a list of indices whose values I would like to increment by one. This list may contain repeated indices, and I would like the increment to scale with the number of repeats of each index. Without repeats, the command is simple:</p> <pre><code>a=np.zeros(6).astype('int') b=[3,2,5] a[b]+=1 </c...
8
2010-01-05T05:37:23Z
28,894,452
<p>In numpy >= 1.8, you can also use the <code>at</code> method of the addition 'universal function' ('ufunc'). As the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ufunc.at.html" rel="nofollow">docs note</a>:</p> <blockquote> <p>For addition ufunc, this method is equivalent to a[indices] += b, ...
3
2015-03-06T08:01:36Z
[ "python", "indexing", "numpy" ]
Nested Scopes and Lambdas
2,004,398
<pre><code>def funct(): x = 4 action = (lambda n: x ** n) return action x = funct() print(x(2)) # prints 16 </code></pre> <p>... I don't quite understand why 2 is assigned to n automatically?</p>
3
2010-01-05T05:48:48Z
2,004,427
<p><code>n</code> is the argument of the anonymous function returned by <code>funct</code>. An exactly equivalent defintion of <code>funct</code> is </p> <pre><code>def funct(): x = 4 def action(n): return x ** n return action </code></pre> <p>Does this form make any more sense?</p>
5
2010-01-05T05:55:22Z
[ "python", "lambda", "nested" ]
Nested Scopes and Lambdas
2,004,398
<pre><code>def funct(): x = 4 action = (lambda n: x ** n) return action x = funct() print(x(2)) # prints 16 </code></pre> <p>... I don't quite understand why 2 is assigned to n automatically?</p>
3
2010-01-05T05:48:48Z
2,004,433
<p>It's not assigned "automatically": it's assigned very explicitly and <strong>non</strong>-automatically by your passing it as the actual argument corresponding to the <code>n</code> parameter. That complicated way to set <code>x</code> is almost identical (net of <code>x.__name__</code> and other minor introspectiv...
3
2010-01-05T05:58:03Z
[ "python", "lambda", "nested" ]
Python equivalent of PyErr_Print()
2,004,400
<p>What is the Python API equivalent of <code>PyErr_Print()</code>, from the C interface?</p> <p>I'm assuming a call in either the <code>sys</code>, or <code>traceback</code> modules, but can't find any functions therein that make calls to <code>PyErr_Print()</code>.</p> <h2>Addendum</h2> <p>I'm after the Python cal...
1
2010-01-05T05:49:07Z
2,004,429
<p>There's no Python function that's exactly equivalent to <code>PyErr_PrintEx</code> (the real name of <code>PyErr_Print</code>;-), including for example setting <code>sys.last_traceback</code> and friends (which are only supposed to be set to help a post-mortem debugging from the interactive interpreter for exception...
2
2010-01-05T05:55:43Z
[ "python", "c", "cpython", "sys", "traceback" ]
Get original filename google app engine
2,004,476
<p>When receiving a file upload on google app engine, <a href="http://code.google.com/appengine/docs/python/images/usingimages.html" rel="nofollow">the example</a> assumes you're receiving a .png. However you only konw what the type of the image is by the extension on the filename.</p> <p>How do you get the original ...
4
2010-01-05T06:11:39Z
2,004,604
<p>It seems that the newly introduced BlobStore has direct support for original filename in the blob's properties. <a href="http://code.google.com/appengine/docs/python/blobstore/blobinfoclass.html#BlobInfo_filename" rel="nofollow">http://code.google.com/appengine/docs/python/blobstore/blobinfoclass.html#BlobInfo_filen...
3
2010-01-05T07:36:33Z
[ "python", "google-app-engine", "upload" ]
Get original filename google app engine
2,004,476
<p>When receiving a file upload on google app engine, <a href="http://code.google.com/appengine/docs/python/images/usingimages.html" rel="nofollow">the example</a> assumes you're receiving a .png. However you only konw what the type of the image is by the extension on the filename.</p> <p>How do you get the original ...
4
2010-01-05T06:11:39Z
2,006,424
<p>The filename of the file that is being uploaded can be determined by looking at the <em>filename</em> property of the variable that holds the file. For example, let's say that your form has a field named <em>content</em>:</p> <pre><code>&lt;input type="file" name="content" /&gt; </code></pre> <p>Inside your Handle...
8
2010-01-05T13:57:18Z
[ "python", "google-app-engine", "upload" ]
Force CherryPy Child Threads
2,004,514
<p>Well, I want cherrypy to kill all child threads on auto-reload instead of "Waiting for child threads to terminate" because my program has threads of its own and I don't know how to get past this. CherryPy keeps hanging on that one line and I don't know what to do to get the 'child threads' to terminate...</p> <p>`...
9
2010-01-05T06:24:29Z
2,007,568
<p>You need to write code that stops your threads, and register it as a listener for the 'stop' event:</p> <pre><code>from cherrypy.process import plugins class MyFeature(plugins.SimplePlugin): """A feature that does something.""" def start(self): self.bus.log("Starting my feature") self.thre...
11
2010-01-05T16:48:50Z
[ "python", "multithreading", "cherrypy" ]
Force CherryPy Child Threads
2,004,514
<p>Well, I want cherrypy to kill all child threads on auto-reload instead of "Waiting for child threads to terminate" because my program has threads of its own and I don't know how to get past this. CherryPy keeps hanging on that one line and I don't know what to do to get the 'child threads' to terminate...</p> <p>`...
9
2010-01-05T06:24:29Z
18,142,937
<p>This works with quickstart</p> <pre><code>def stopit(): print 'stop handler invoked' #... stopit.priority = 10 cherrypy.engine.subscribe('stop', stopit) </code></pre>
-1
2013-08-09T08:36:01Z
[ "python", "multithreading", "cherrypy" ]
If I have this string in Python, how do I decode it?
2,004,574
<p>s = 'Tara%2520Stiles%2520Living'</p> <p>How do I turn it into:</p> <pre><code>Tara Stiles Living </code></pre>
5
2010-01-05T06:41:04Z
2,004,580
<p>Use:</p> <pre><code>urllib.unquote(string) </code></pre> <p><a href="http://docs.python.org/library/urllib.html">http://docs.python.org/library/urllib.html</a></p>
5
2010-01-05T06:45:03Z
[ "python", "encoding" ]
If I have this string in Python, how do I decode it?
2,004,574
<p>s = 'Tara%2520Stiles%2520Living'</p> <p>How do I turn it into:</p> <pre><code>Tara Stiles Living </code></pre>
5
2010-01-05T06:41:04Z
2,004,587
<p>You need to use <a href="http://docs.python.org/library/urllib.html#urllib.unquote" rel="nofollow"><code>urllib.unquote</code></a>, but it appears you need to use it <em>twice</em>:</p> <pre><code>&gt;&gt;&gt; import urllib &gt;&gt;&gt; s = 'Tara%2520Stiles%2520Living' &gt;&gt;&gt; urllib.unquote(urllib.unquote(s))...
14
2010-01-05T06:47:17Z
[ "python", "encoding" ]
If I have this string in Python, how do I decode it?
2,004,574
<p>s = 'Tara%2520Stiles%2520Living'</p> <p>How do I turn it into:</p> <pre><code>Tara Stiles Living </code></pre>
5
2010-01-05T06:41:04Z
2,004,596
<pre><code>&gt;&gt;&gt; import urllib &gt;&gt;&gt; s = 'Tara%2520Stiles%2520Living' &gt;&gt;&gt; t=urllib.unquote_plus(s) &gt;&gt;&gt; print t Tara%20Stiles%20Living &gt;&gt;&gt; urllib.unquote_plus(t) 'Tara Stiles Living' &gt;&gt;&gt; </code></pre>
4
2010-01-05T06:51:08Z
[ "python", "encoding" ]
If I have this string in Python, how do I decode it?
2,004,574
<p>s = 'Tara%2520Stiles%2520Living'</p> <p>How do I turn it into:</p> <pre><code>Tara Stiles Living </code></pre>
5
2010-01-05T06:41:04Z
23,163,937
<pre class="lang-python prettyprint-override"><code>import urllib s = 'Tara%2520Stiles%2520Living' t='' while s&lt;&gt;t: s,t=t,urllib.unquote(s) </code></pre>
0
2014-04-18T23:30:21Z
[ "python", "encoding" ]
Regex match of hexdigest in google app engine webapp WSGIApplication
2,004,691
<pre><code>application = webapp.WSGIApplication( [(r'/main/profile/([a-f0-9]{40})', ProfileHandler)], debug=True) </code></pre> <p>The regex in the above parameter will not recognize a 40 hex long hexdigest in Google App Engine.</p> <p>I'm getting 404s instead of ProfileHandler being passed the matching 40 he...
1
2010-01-05T08:05:40Z
2,004,753
<p>I have no experience with the Google App Engine, but:</p> <ul> <li>what happens if you change <code>([a-f0-9]{40})</code> in to <code>([a-fA-F0-9]{40})</code></li> <li>are you sure group <code>$1</code> is used and not the entire match (including <code>/main/profile/</code>)?</li> </ul>
0
2010-01-05T08:18:15Z
[ "python", "regex", "google-app-engine", "web-applications" ]
Regex match of hexdigest in google app engine webapp WSGIApplication
2,004,691
<pre><code>application = webapp.WSGIApplication( [(r'/main/profile/([a-f0-9]{40})', ProfileHandler)], debug=True) </code></pre> <p>The regex in the above parameter will not recognize a 40 hex long hexdigest in Google App Engine.</p> <p>I'm getting 404s instead of ProfileHandler being passed the matching 40 he...
1
2010-01-05T08:05:40Z
2,004,976
<p>I can not reproduce your problem. Here is an exact code I have:</p> <h2>index.py</h2> <pre><code>from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app class ProfileHandler(webapp.RequestHandler): def get(self, *ar, **kw): self.response.out.write("PROFILE IS...
2
2010-01-05T09:05:18Z
[ "python", "regex", "google-app-engine", "web-applications" ]
Qt Python Calendar: selected day direct access
2,004,916
<p>I have calendar that is working fine.</p> <p>Here is the function that display the full date:</p> <pre><code>def selectDate(self,date): self.fullDate = str(date.day()) + " / " + str(date.month()) + " / " + str(date.year()) print "full date: %s" % self.fullDate </code></pre> <p>And here the code with the c...
0
2010-01-05T08:55:49Z
2,005,059
<p>I guess that the slot called by the selectdate signal shouldn't have any argument. You can access the selectedDate by the corresponding calendar method.</p> <p>See the c++ docs: <a href="http://doc.trolltech.com/4.3/widgets-calendarwidget.html" rel="nofollow">http://doc.trolltech.com/4.3/widgets-calendarwidget.html...
2
2010-01-05T09:25:31Z
[ "python", "qt", "date", "calendar", "typeerror" ]
Why is Django's Meta an old-style class?
2,005,150
<p>I noticed that in Django models, there is a <code>class Meta</code> which makes some additional definitions about the model.</p> <p>My question is, why is this done as an old-style class? (i.e. not subclassing <code>object</code>?) Is there a reason for this or is this just a custom? Could I do it as a new-style cl...
17
2010-01-05T09:45:17Z
2,007,514
<p>I believe that there is no real reason (including history, since new-style classes exist since Python 2.2) and that not only can you choose to use a new-style class instead, but that it would probably be a good idea for you to do so (for all the usual reasons).</p>
14
2010-01-05T16:40:36Z
[ "python", "django", "class" ]
Why is Django's Meta an old-style class?
2,005,150
<p>I noticed that in Django models, there is a <code>class Meta</code> which makes some additional definitions about the model.</p> <p>My question is, why is this done as an old-style class? (i.e. not subclassing <code>object</code>?) Is there a reason for this or is this just a custom? Could I do it as a new-style cl...
17
2010-01-05T09:45:17Z
2,007,686
<p>Since class Meta is never anything but a simple namespace container, there is zero advantage to subclassing object; just eight extra characters to type. Won't hurt anything to do so if you feel like it, though.</p>
7
2010-01-05T17:04:42Z
[ "python", "django", "class" ]
Asynchronous data through Bloomberg's new data API (COM v3) with Python?
2,005,234
<p>Does anyone know how to get asynchronous data through Bloomberg's new data API (COM v3) with Python? I found this code below on wilmott.com and it works just fine, but it's for the old API version.</p> <p>Does anyone know the corresponding code for the new version?</p> <pre><code>from win32com.client import Dispat...
8
2010-01-05T10:03:25Z
2,054,175
<p>For it to work you need to install Bloomberg Desktop v3 API SDK, I did that, restarted my machine, seems to work. Without the restart it just crashed.</p> <p>If you use Com explorer, you will see the bloomberg elements are now present</p>
0
2010-01-13T03:27:41Z
[ "python", "asynchronous", "win32com", "bloomberg" ]
Asynchronous data through Bloomberg's new data API (COM v3) with Python?
2,005,234
<p>Does anyone know how to get asynchronous data through Bloomberg's new data API (COM v3) with Python? I found this code below on wilmott.com and it works just fine, but it's for the old API version.</p> <p>Does anyone know the corresponding code for the new version?</p> <pre><code>from win32com.client import Dispat...
8
2010-01-05T10:03:25Z
2,054,374
<p>I finally figured it out. I did a fair bit of combrowse.py detective work, and I compared with the JAVA, C, C++, and .NET examples in the BBG API download. Interestingly enough the Bloomberg Helpdesk people knew pretty much null when it came to these things, or perhaps I was just talking to the wrong person.</p> <p...
19
2010-01-13T04:20:22Z
[ "python", "asynchronous", "win32com", "bloomberg" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,359
<p>Try:</p> <pre><code>msg = MIMEText("""The nightly build status was a SUCCESS Build File: http://www.python.org Build Results File: http://10.51.54.57/sandboxes/""", project, "\n") </code></pre> <p>If the additional space at the beginning of each line is a problem, remove them with a regexp (<code>r'^\s+'</code>...
5
2010-01-05T10:28:24Z
[ "python" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,364
<p>you can use triple quotes</p> <pre><code>&gt;&gt;&gt; s="""The nightly build status was a SUCCESS Build File: http://www.python.org Build Results File: http://10.51.54.57/sandboxes/""" &gt;&gt;&gt; msg=MimeType(s,project,"\n") </code></pre>
0
2010-01-05T10:29:31Z
[ "python" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,365
<p>How about</p> <pre><code>msg = MIMEText( "The nightly build status was a SUCCESS\n\n" "Build File: http://www.python.org\n\n" "Build Results File: http://10.51.54.57/sandboxes/" , project , "\n" ) </code></pre> <p>Or</p> <pre><code>msg = MIMEText("""The nightly build status was a SUCCESS Build File: http://www.p...
5
2010-01-05T10:29:35Z
[ "python" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,371
<p>Python supports multi-line strings using triple quotes:</p> <pre><code>text = """The nightly build status was a SUCCESS\n\nBuild File: http://www.python.org\n\n Build Results File: http://10.51.54.57/sandboxes/""" msg = MIMEText(text, project, "\n") </code></pre>
1
2010-01-05T10:31:20Z
[ "python" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,373
<p>Why not</p> <pre><code>msg= MIMEText("The nightly build status was a SUCCESS\n\nBuild File: "+ \ "http://www.python.org\n\n Bu..... ") </code></pre> <p>etc.</p> <p>(I.e., use the line continuation backslash).</p> <p>Also note that the following each give you <em>abcdef</em></p> <pre><code>s ="abc" "def" s=...
3
2010-01-05T10:31:37Z
[ "python" ]
String manipulation in Python
2,005,345
<p>I am trying to write a command but I do not want one long line that looks untidy. I am looking to add the strings together to be executed as on command. I have some code below which is part of an email function:</p> <pre><code>msg = MIMEText("The nightly build status was a SUCCESS\n\nBuild File: http://www.python.o...
0
2010-01-05T10:24:27Z
2,005,526
<p>Hmm, what exactly is the module are you using? I am guessing, that it is deprecated, because the modern interface is <a href="http://docs.python.org/library/email.html" rel="nofollow">email</a> (if I've guessed your intentions correctly). More specifically, to create a <code>MIMEText</code> object you use <a href="h...
-1
2010-01-05T11:00:26Z
[ "python" ]
Slow pyinotify.ThreadedNotifier.stop()
2,005,443
<p><br> I have a wxPython application that uses pyinotify (via ThreadedNotifier) to check when a certain file gets modified. When this happens, the application stops watching the file and does some stuff. Everything works fine, except that often the call to ThreadedNotifier.stop() takes a noticeable time, about 4 secon...
0
2010-01-05T10:46:54Z
2,005,571
<p>Could it be that it is a polling mechanism with a timeout of about 4 seconds? And that the thread is only really stopped when it is entering the run() stage?</p> <p>That might have something to do with the threading library. </p> <p>You could test that by using a notifier with a different timeout.</p>
1
2010-01-05T11:09:33Z
[ "python", "inotify", "pyinotify" ]
Developing a chat application in Python
2,005,540
<p>I want to develop a chat application similar to <a href="http://omegle.com" rel="nofollow">omegle.com</a>.</p> <p><strong>FUNCTIONALITY</strong> This website picks up two random people who are logged into the website and then pairs them for a chat session. Now if one of the party A disconnects then the other party ...
-1
2010-01-05T11:03:10Z
2,005,624
<p>You can set up some form of P2P connections between your users or you can do it through Servers. It all depends on what your interface is going to be. If its going to be in a browser then I would recommend routing it through a server and just having the some AJAX app that poles for changes.</p> <p>if you worried ab...
2
2010-01-05T11:19:51Z
[ "python", "design", "chat" ]
Developing a chat application in Python
2,005,540
<p>I want to develop a chat application similar to <a href="http://omegle.com" rel="nofollow">omegle.com</a>.</p> <p><strong>FUNCTIONALITY</strong> This website picks up two random people who are logged into the website and then pairs them for a chat session. Now if one of the party A disconnects then the other party ...
-1
2010-01-05T11:03:10Z
2,005,629
<ol> <li>Well, you can't send the message between the two parties specifically, unless you use an appropriately-authorised clientside system (Signed Java Applet, etc), so the answer here is obvious.</li> </ol> <p>-- Edit:</p> <p>By the way, a trick, for perhaps someone 'new' to programming; if you want to develop an ...
2
2010-01-05T11:20:44Z
[ "python", "design", "chat" ]
Developing a chat application in Python
2,005,540
<p>I want to develop a chat application similar to <a href="http://omegle.com" rel="nofollow">omegle.com</a>.</p> <p><strong>FUNCTIONALITY</strong> This website picks up two random people who are logged into the website and then pairs them for a chat session. Now if one of the party A disconnects then the other party ...
-1
2010-01-05T11:03:10Z
2,005,776
<ol> <li><p>Every request to server cause another load. The best is to pair clients without server. Alternative is to use dedicated light server for handling asynchronous request to avoid overload main website.</p></li> <li><p>About Twisted, everything depends on... For example - my company heavily used twisted for mul...
0
2010-01-05T11:47:15Z
[ "python", "design", "chat" ]
Handle Arbitrary Exception, Print Default Exception Message
2,005,680
<p>I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do...
16
2010-01-05T11:29:03Z
2,005,712
<pre><code>try: #stuff except Exception as e: print e </code></pre> <p>The <code>traceback</code> module provides various functions for extracting more information from the exception object (<code>e</code>, above).</p> <p>Source <a href="https://docs.python.org/2/tutorial/errors.html">Errors and Exceptions</a...
15
2010-01-05T11:33:47Z
[ "python", "exception-handling" ]
Handle Arbitrary Exception, Print Default Exception Message
2,005,680
<p>I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do...
16
2010-01-05T11:29:03Z
2,005,717
<pre><code>while True: try: # Do your stuff except Exception, e: print "Something happened: %s" % e </code></pre>
4
2010-01-05T11:34:07Z
[ "python", "exception-handling" ]
Handle Arbitrary Exception, Print Default Exception Message
2,005,680
<p>I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do...
16
2010-01-05T11:29:03Z
2,005,909
<p>Consider using the Python logging module, this is will give you a lot of the functionality to log problems for later inspection. Below is a simple example of using the logging module to to log exceptions:</p> <pre><code>import logging LOG_FILE = '/tmp/exceptions.log' logging.basicConfig(filename=LOG_FILE,level=logg...
12
2010-01-05T12:18:36Z
[ "python", "exception-handling" ]
Handle Arbitrary Exception, Print Default Exception Message
2,005,680
<p>I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do...
16
2010-01-05T11:29:03Z
3,002,292
<p>I find this to be much more useful for debugging:</p> <pre><code>from traceback import print_exc try: raise Exception("doh!") except: print_exc() </code></pre>
4
2010-06-09T00:15:36Z
[ "python", "exception-handling" ]
Handle Arbitrary Exception, Print Default Exception Message
2,005,680
<p>I have a program, a part of which executes a loop. During the execution of this loop, there are exceptions. Obviously, I would like my program to run without errors, but for the sake of progress, I would like the program to execute over the entire input and not stop when an exception is thrown. The easiest way to do...
16
2010-01-05T11:29:03Z
14,488,606
<p>While James's answer is almost always what you actually want, it's not quite what the OP asked for:</p> <blockquote> <p>Is there a way to except any arbitrary exception and be able to print out the exception message in the except block?</p> </blockquote> <p><a href="http://docs.python.org/2/library/exceptions.ht...
6
2013-01-23T20:18:10Z
[ "python", "exception-handling" ]
Visual module in python assign objects
2,005,759
<p>I am a newb in Visual module in python, not really understand how does it assign a value to an objects. say</p> <pre><code>from visual import * stars=[] galaxies=[] for i in range(10): stars+=[sphere('pos,radius,color.....')] for j in range(20): galaxies+=[sphere('pos,radius,color......')] for k in range(...
0
2010-01-05T11:43:13Z
2,006,439
<p>First things first. Your code uses list concatenation to add stuff to the list. It is better to use the <code>.append()</code> method of lists. Also, the last loop could iterate directly on the objects instead of using an index. It is more elegant and easy to understand this way.</p> <p>The pseudo-code below is equ...
1
2010-01-05T14:00:35Z
[ "python", "python-visual" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,005,892
<p>I think it isn't that there aren't other ways to do it, but some things are just nicer with metaclasses.</p>
-1
2010-01-05T12:15:19Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,005,894
<p>Add extra flexibility to your programming: </p> <p>But according to this <a href="http://www.ibm.com/developerworks/linux/library/l-pymeta.html">Metaclass programming in Python</a> you might not need them ( yet ) </p> <blockquote> <p><em>Metaclasses are deeper magic than 99% of users should ever worry about. If ...
10
2010-01-05T12:15:51Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,005,908
<p>They are rarely needed, but come in useful in places where you want to add behavior to the basic behavior of an object -- compare Aspect Oriented Programming, or the instrumentation done in persistence frameworks like Hibernate. </p> <p>For example, you may want a class which persists or logs each new object.</p>
1
2010-01-05T12:18:29Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,005,912
<p>If you are looking for examples of using the metaclass mechanism, you can read the source code of <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/forms.py" rel="nofollow">django.forms</a>.</p> <p>The declarative style of form definition is implemented through metaclass.</p>
4
2010-01-05T12:19:01Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,005,938
<p>Probably there is nothing that can be done exclusively with metaclasses, but to some people (mine included) it's a interesting tool you can use. Just be careful not to abuse, as it can be tricky.</p> <p>For example, I've used metaprogramming in a recent project. It was a OpenOffice calc sheet, which, using some pyU...
1
2010-01-05T12:26:01Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,006,243
<p>Take a look at Django sources - for example metaclasses are used there to generate models.</p> <p><a href="http://code.djangoproject.com/wiki/DynamicModels" rel="nofollow">http://code.djangoproject.com/wiki/DynamicModels</a></p> <blockquote> <p>Internally, Django uses metaclasses to create models based on a cl...
1
2010-01-05T13:21:58Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,006,875
<p>I use metaclasses with some frequency, and they're an extremely powerful tool to have in the toolbox. Sometimes your solution to a problem can be more elegant, less code, with them than without.</p> <p>The thing I find myself using metaclasses for most often, is post-processing the class attributes during class cr...
7
2010-01-05T15:13:05Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
2,007,641
<p>Metaclasses are indispensable if you want to have class objects (as opposed to <strong>instances</strong> of class objects) equipped with "special customized behavior", since an object's behavior depends on special methods on the <strong>type</strong> of the object, and a class object's type is, exactly a synonym fo...
17
2010-01-05T16:58:28Z
[ "python", "class", "decorator", "metaclass" ]
What are Python metaclasses useful for?
2,005,878
<p>What can be done with metaclasses that can't be in any other way?</p> <p>Alex Martelli told that there are tasks that can't be achieved without metaclasses here <a href="http://stackoverflow.com/questions/1779372/python-metaclasses-vs-class-decorators">http://stackoverflow.com/questions/1779372/python-metaclasses-v...
27
2010-01-05T12:12:19Z
23,853,229
<p>The first commentator states that the use of metaclasses <a href="http://www.jesshamrick.com/2013/04/17/rewriting-python-docstrings-with-a-metaclass/" rel="nofollow">here</a> was 'a gemstone' that helped him track down unexpected errors that had been occurring for (many) 'days'. </p>
0
2014-05-25T07:59:16Z
[ "python", "class", "decorator", "metaclass" ]
Limiting the features of an embedded python instance
2,005,898
<p>Is there a way to limit the abilities of python scripts running under an embedded interpretor? Specifically I wish to prevent the scripts from doing things like the following:</p> <ul> <li>Importing python extension modules (ie .pyd modules), except those specifically allowed by the application.</li> <li>Manipulati...
1
2010-01-05T12:16:51Z
2,006,074
<p>No. There's no easy way to prevent those things on CPython. Your options are:</p> <ol> <li>Edit CPython source code and remove things you don't want - provide mocking methods for all those things. Very error-prone and hard to do. This is the approach of Google's App Engine.</li> <li>Use <a href="http://pypi.python....
2
2010-01-05T12:49:10Z
[ "python", "c", "cpython", "python-embedding" ]
Limiting the features of an embedded python instance
2,005,898
<p>Is there a way to limit the abilities of python scripts running under an embedded interpretor? Specifically I wish to prevent the scripts from doing things like the following:</p> <ul> <li>Importing python extension modules (ie .pyd modules), except those specifically allowed by the application.</li> <li>Manipulati...
1
2010-01-05T12:16:51Z
2,006,116
<p>Maybe <a href="http://ssscripting.wordpress.com/2009/07/14/hacking-python-at-runtime/" rel="nofollow">this</a> can be helpful. You have an example provided on how to work with the ast.</p>
0
2010-01-05T12:57:29Z
[ "python", "c", "cpython", "python-embedding" ]
Limiting the features of an embedded python instance
2,005,898
<p>Is there a way to limit the abilities of python scripts running under an embedded interpretor? Specifically I wish to prevent the scripts from doing things like the following:</p> <ul> <li>Importing python extension modules (ie .pyd modules), except those specifically allowed by the application.</li> <li>Manipulati...
1
2010-01-05T12:16:51Z
23,365,213
<p>What you want it Google's <a href="http://en.wikipedia.org/wiki/Unladen_Swallow" rel="nofollow">Unladen Swallow</a> project that Python version of <a href="http://en.wikipedia.org/wiki/Appengine" rel="nofollow">App Engine</a> runs on.</p> <p>Modules are severely restricted, <code>ctypes</code> are not allowed, sock...
0
2014-04-29T12:52:54Z
[ "python", "c", "cpython", "python-embedding" ]
How do nested functions work in Python?
2,005,956
<pre><code>def maker(n): def action(x): return x ** n return action f = maker(2) print(f) print(f(3)) print(f(4)) g = maker(3) print(g(3)) print(f(3)) # still remembers 2 </code></pre> <p>Why does the nested function remember the first value <code>2</code> even though <code>maker()</code> has return...
34
2010-01-05T12:29:20Z
2,005,992
<p>You are basically creating a <a href="http://en.wikipedia.org/wiki/Closure%5F%28computer%5Fscience%29">closure</a>.</p> <blockquote> <p>In computer science, a closure is a first-class function with free variables that are bound in the lexical environment. Such a function is said to be "closed over" its free varia...
33
2010-01-05T12:37:17Z
[ "python", "function", "nested", "closures", "nested-function" ]