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 |
|---|---|---|---|---|---|---|---|---|---|
Transforming DTD's with Python | 1,975,316 | <p>I'm looking for a library to help me parse and transform DTDs using Python. The only thing I have found so far is <a href="http://www.garshol.priv.no/download/software/xmlproc/" rel="nofollow">xmlproc</a>, but that seems ancient and doesn't seem to support serialization of DTDs. There's <a href="http://www.rpbourret... | 1 | 2009-12-29T15:56:54Z | 1,978,050 | <p>I don't know of an end-to-end processor for DTDs, but then again I so rarely use DTDs at all so that's not surprising.</p>
<p><a href="http://wiki.xml3k.org/Amara" rel="nofollow">Amara</a> can parse DTDs, but I don't know what level of access you can have to them or if the results can be serialized. I assume they c... | 0 | 2009-12-30T02:08:28Z | [
"python",
"dtd",
"dtd-parsing"
] |
Transforming DTD's with Python | 1,975,316 | <p>I'm looking for a library to help me parse and transform DTDs using Python. The only thing I have found so far is <a href="http://www.garshol.priv.no/download/software/xmlproc/" rel="nofollow">xmlproc</a>, but that seems ancient and doesn't seem to support serialization of DTDs. There's <a href="http://www.rpbourret... | 1 | 2009-12-29T15:56:54Z | 1,978,710 | <p>You might want to consider converting your DTD to one of the XML-based formats. At that point, you can process it with ElementTree, or whatever XML toolkit you prefer.</p>
<p>I've had good experience with RelaxNG, which is fairly concise and straightforward. There's a list of conversion tools on its site: <a href="... | 0 | 2009-12-30T06:27:12Z | [
"python",
"dtd",
"dtd-parsing"
] |
Django: iterating over the options in a custom select field | 1,975,411 | <p>I'm using a custom MM/YY field and widget based on <a href="http://joshourisman.com/2008/11/19/custom-fields-and-widgets-django-forms/" rel="nofollow">this example</a>. I want to iterate over the individual month and year options defined in the widget class in order to apply "selected='selected'" to the MM/YY value... | 1 | 2009-12-29T16:14:13Z | 1,975,645 | <p>The magic of django forms is that you don't need to do all that. By calling the form's select field by name, it will render it and select the right option as based on initial/instance data passed into the form on instantation.</p>
<pre><code>{{form.working_month}}
</code></pre>
<p>If you're still having troubles, ... | 2 | 2009-12-29T16:55:33Z | [
"python",
"django",
"django-templates",
"django-forms"
] |
Django: iterating over the options in a custom select field | 1,975,411 | <p>I'm using a custom MM/YY field and widget based on <a href="http://joshourisman.com/2008/11/19/custom-fields-and-widgets-django-forms/" rel="nofollow">this example</a>. I want to iterate over the individual month and year options defined in the widget class in order to apply "selected='selected'" to the MM/YY value... | 1 | 2009-12-29T16:14:13Z | 2,067,569 | <p>A slight variation of your problem is solved here</p>
<p><a href="http://skyl.org/log/post/skyl/2010/01/subclass-django-forms-widgets-radiofieldrenderer-and-django-forms-widgets-radioselect-for-custom-rendering-of-individual-choices/" rel="nofollow">http://skyl.org/log/post/skyl/2010/01/subclass-django-forms-widget... | 0 | 2010-01-14T21:06:51Z | [
"python",
"django",
"django-templates",
"django-forms"
] |
epoch timestamp converter with millennia range, python | 1,975,524 | <p>is there an epoch time converter that can deal with millennia?</p>
<pre><code>time.gmtime(1000 * 365 * 24 * 60 * 60)
</code></pre>
<p>throws </p>
<pre><code>ValueError: timestamp out of range for platform time_t
</code></pre>
| 0 | 2009-12-29T16:33:25Z | 1,975,558 | <p>Yes, at least on Windows (using Windows 7 here). What platform are you using?</p>
<pre><code>Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
>>> time.gmtime(1000*365*24*60*60)
time.struct_time(tm_year=2969, tm_mon=5, tm_mday=3, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=2... | 0 | 2009-12-29T16:40:16Z | [
"python"
] |
Is there a platform agnostic implementation of time.gmtime? | 1,975,693 | <p>on google appengine (http://shell.appspot.com/):</p>
<pre><code>>>> time.gmtime(1000*365*24*60*60)
(2969, 5, 3, 0, 0, 0, 2, 123, 0)
</code></pre>
<p>on macosx:</p>
<pre><code>>>> time.gmtime(1000*365*24*60*60)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
V... | 2 | 2009-12-29T17:03:19Z | 1,975,965 | <p>The <a href="http://docs.python.org/library/time.html" rel="nofollow">time module</a> is defined to be platform-specific.</p>
<blockquote>
<p>The functions in this module do not handle dates and times before the epoch or far in the future. The cut-off point in the future is determined by the C library; for Unix, ... | 1 | 2009-12-29T18:03:15Z | [
"python"
] |
store a queryset in the session with django | 1,975,700 | <p>I have problem storing a big queryset in the session. This queryset is from a search and I need to store it for paginate inside every result. This is the code in my view:</p>
<pre><code>c = queryset.order_by('-order')
request.session['query_search'] = c
</code></pre>
<p>You can see an example in my site: <a href=... | 2 | 2009-12-29T17:04:14Z | 1,975,781 | <p>You could store only the list of PKs and then query through them when you need to.</p>
| 3 | 2009-12-29T17:22:48Z | [
"python",
"django",
"session",
"django-queryset",
"paginate"
] |
store a queryset in the session with django | 1,975,700 | <p>I have problem storing a big queryset in the session. This queryset is from a search and I need to store it for paginate inside every result. This is the code in my view:</p>
<pre><code>c = queryset.order_by('-order')
request.session['query_search'] = c
</code></pre>
<p>You can see an example in my site: <a href=... | 2 | 2009-12-29T17:04:14Z | 1,976,054 | <p>Or may you can store the sql generated by the query and then execute.</p>
<pre><code>request.session['query_search'] = c.query.as_sql()
</code></pre>
| 0 | 2009-12-29T18:19:30Z | [
"python",
"django",
"session",
"django-queryset",
"paginate"
] |
store a queryset in the session with django | 1,975,700 | <p>I have problem storing a big queryset in the session. This queryset is from a search and I need to store it for paginate inside every result. This is the code in my view:</p>
<pre><code>c = queryset.order_by('-order')
request.session['query_search'] = c
</code></pre>
<p>You can see an example in my site: <a href=... | 2 | 2009-12-29T17:04:14Z | 1,980,232 | <p>I'm currently developing a very similar site to yours also in Django.
I stored the queryset in cache, where cache key is an urlencoded string of search parameters- this way if someone performs identical search it doesn't have to repeat the expensive queries to get the same results.</p>
<p>In your case, you can gene... | 3 | 2009-12-30T13:33:37Z | [
"python",
"django",
"session",
"django-queryset",
"paginate"
] |
store a queryset in the session with django | 1,975,700 | <p>I have problem storing a big queryset in the session. This queryset is from a search and I need to store it for paginate inside every result. This is the code in my view:</p>
<pre><code>c = queryset.order_by('-order')
request.session['query_search'] = c
</code></pre>
<p>You can see an example in my site: <a href=... | 2 | 2009-12-29T17:04:14Z | 4,770,736 | <p>Big sessions eat ressources (I suppose Django makes no exception to this).<br>
Make it a JSON list, then use the user's browser local storage : <a href="http://jstorage.info" rel="nofollow">http://jstorage.info</a> , a jQuery plugin, cross-browser.<br>
You'll need a way to tell if the data is outdated (checksum? did... | 0 | 2011-01-22T21:29:43Z | [
"python",
"django",
"session",
"django-queryset",
"paginate"
] |
Python - pickling fails for numpy.void objects | 1,975,704 | <pre><code> >>> idmapfile = open("idmap", mode="w")
>>> pickle.dump(idMap, idmapfile)
>>> idmapfile.close()
>>> idmapfile = open("idmap")
>>> unpickled = pickle.load(idmapfile)
>>> unpickled == idMap
False
idMap[1]
{1537: (552, 1, 1537, 17.793... | 0 | 2009-12-29T17:04:43Z | 1,975,854 | <p>Something with your system (filesystem?) ; I would try pickling in binary mode; use <code>dump(idMap, idmapfile, protocol=2)</code></p>
| 0 | 2009-12-29T17:39:26Z | [
"python",
"serialization",
"numpy",
"marshalling",
"pickle"
] |
Python - pickling fails for numpy.void objects | 1,975,704 | <pre><code> >>> idmapfile = open("idmap", mode="w")
>>> pickle.dump(idMap, idmapfile)
>>> idmapfile.close()
>>> idmapfile = open("idmap")
>>> unpickled = pickle.load(idmapfile)
>>> unpickled == idMap
False
idMap[1]
{1537: (552, 1, 1537, 17.793... | 0 | 2009-12-29T17:04:43Z | 1,975,948 | <p>So, using python31 I made just a small change to your example and it worked fine. Note that I added the "b" for binary in the file open's I tried this with all protocols and it worked for each</p>
<pre><code>idmapfile = open("idmap", mode="wb")
pickle.dump(idMap, idmapfile)
idmapfile.close()
idmapfile = open("idmap... | 0 | 2009-12-29T17:58:22Z | [
"python",
"serialization",
"numpy",
"marshalling",
"pickle"
] |
Python - pickling fails for numpy.void objects | 1,975,704 | <pre><code> >>> idmapfile = open("idmap", mode="w")
>>> pickle.dump(idMap, idmapfile)
>>> idmapfile.close()
>>> idmapfile = open("idmap")
>>> unpickled = pickle.load(idmapfile)
>>> unpickled == idMap
False
idMap[1]
{1537: (552, 1, 1537, 17.793... | 0 | 2009-12-29T17:04:43Z | 2,691,209 | <blockquote>
<p>so, pickling will only work with top level module functions and classes, and will not pickle class data, so if some numpy class code/data are required to produce a representation of the numpy void type pickling isn't going to work as expected. It may be that the numpy package has implemented an intern... | 0 | 2010-04-22T13:30:54Z | [
"python",
"serialization",
"numpy",
"marshalling",
"pickle"
] |
Python - pickling fails for numpy.void objects | 1,975,704 | <pre><code> >>> idmapfile = open("idmap", mode="w")
>>> pickle.dump(idMap, idmapfile)
>>> idmapfile.close()
>>> idmapfile = open("idmap")
>>> unpickled = pickle.load(idmapfile)
>>> unpickled == idMap
False
idMap[1]
{1537: (552, 1, 1537, 17.793... | 0 | 2009-12-29T17:04:43Z | 16,448,954 | <p>I agree. I think there is a problem with serializing numpy.void</p>
<p>example that doesn't work (Python 2.7.3, numpy 1.6.1):</p>
<pre><code>import pickle, numpy as np
my_array = np.array([('hello', 45.5, 'world')], dtype=[('a', str, 10), ('b', float), ('c', str,10)])
my_void = my_array[0]
print my_void
print pick... | 1 | 2013-05-08T19:44:10Z | [
"python",
"serialization",
"numpy",
"marshalling",
"pickle"
] |
Piecing together Django views | 1,975,769 | <p>Is it good practice to treat individual app views as a blocks of HTML that can be pieced together to form a larger site? If not, what is the best way to reuse app views from project to project, assuming each one uses a different set of templates?</p>
| 1 | 2009-12-29T17:19:48Z | 1,976,134 | <p>A general good practice to define views with a <code>template_name</code> kwarg. This allows a the default template to be overridden. This is common in generic views.</p>
<pre><code>#my reusable view
def list_items(request, template_name="items.html"):
items=Item.objects.all()
return render_to_response(template... | 2 | 2009-12-29T18:32:03Z | [
"python",
"django"
] |
Piecing together Django views | 1,975,769 | <p>Is it good practice to treat individual app views as a blocks of HTML that can be pieced together to form a larger site? If not, what is the best way to reuse app views from project to project, assuming each one uses a different set of templates?</p>
| 1 | 2009-12-29T17:19:48Z | 1,976,174 | <p>Your question is little too generic.</p>
<p>The general way of doing it involves:</p>
<ul>
<li>Extend templates of the reusable apps</li>
<li>Pass the new template name to the view (Reusable apps should accepts that argument)</li>
<li>Also pass <code>extra_context</code> to the reusable-generic-view</li>
<li>Use y... | 0 | 2009-12-29T18:39:30Z | [
"python",
"django"
] |
Piecing together Django views | 1,975,769 | <p>Is it good practice to treat individual app views as a blocks of HTML that can be pieced together to form a larger site? If not, what is the best way to reuse app views from project to project, assuming each one uses a different set of templates?</p>
| 1 | 2009-12-29T17:19:48Z | 1,977,037 | <p>usually each application should provide views for the basic functionality - where the application takes full control over the user and the page.</p>
<p>functionality which can be displayed in the basic page layout (e.g. 'last 5 posts in my blog') would be a perfect use case for template tags - i usually use simple ... | 0 | 2009-12-29T21:23:45Z | [
"python",
"django"
] |
Modern client/server authentication techniques | 1,975,793 | <p>I'm building a non-browser client-server (XULRunner-CherryPy) application using HTTP for communication. The area I'm pondering now is user authentication. Since I don't have substantial knowledge in security I would much prefer using tried-and-tested approaches and ready-made libraries over trying to invent and/or b... | 3 | 2009-12-29T17:24:56Z | 1,994,409 | <p>This may not be a complete answer, but I would like to offer some reassuring news about rainbow tables and the web. I wouldn't worry too much about Rainbow Tables with regards to the web for the following reasons: </p>
<p>(1) Rainbow table cracks work by examining the hashed password. On the web, the hashed passwor... | 1 | 2010-01-03T09:14:55Z | [
"python",
"authentication",
"client-server",
"xulrunner"
] |
Modern client/server authentication techniques | 1,975,793 | <p>I'm building a non-browser client-server (XULRunner-CherryPy) application using HTTP for communication. The area I'm pondering now is user authentication. Since I don't have substantial knowledge in security I would much prefer using tried-and-tested approaches and ready-made libraries over trying to invent and/or b... | 3 | 2009-12-29T17:24:56Z | 2,017,063 | <p>Amazon Web Services, OpenID, and OAuth have examples of request signing. Amazon Web Services is an easy example to follow because there isn't a more complex protocol around the interactions. They basically involve having the client or server sign a request by hashing all of its fields with a previously set up key ... | 1 | 2010-01-06T23:11:34Z | [
"python",
"authentication",
"client-server",
"xulrunner"
] |
Modern client/server authentication techniques | 1,975,793 | <p>I'm building a non-browser client-server (XULRunner-CherryPy) application using HTTP for communication. The area I'm pondering now is user authentication. Since I don't have substantial knowledge in security I would much prefer using tried-and-tested approaches and ready-made libraries over trying to invent and/or b... | 3 | 2009-12-29T17:24:56Z | 2,357,494 | <p>After a lot of poking around and trying to write my own prototype based on Amazon S3 design which (I thought) was pretty secure, I found this excellent website which has answers to all my questions, an Enterprise Security API Toolkit, and much, much more: <a href="http://www.owasp.org/index.php/Main_Page" rel="nofol... | 1 | 2010-03-01T16:58:34Z | [
"python",
"authentication",
"client-server",
"xulrunner"
] |
Separate logger name for each application instance | 1,975,823 | <p>My python application consists of main program and several modules. Each module contains</p>
<pre><code>import logging
log = logging.getLogger('myapp.mymodule')
</code></pre>
<p>on global level. Handlers and other stuff initialized in main program, and typically all messages forwarded to syslog.</p>
<p>Now I want... | 1 | 2009-12-29T17:30:55Z | 1,976,011 | <p>Here is a solution I can think of:</p>
<p>In the main program, set the formatter of logger named <code>myapp</code></p>
<pre><code>import logging
logger = logging.getLogger("myapp")
formatter = logging.Formatter("%(asctime)s - instance_name - %(levelname)s - %(message)s")
ch = logging.SysLogHandler()
ch.setFormatt... | 2 | 2009-12-29T18:12:29Z | [
"python",
"logging"
] |
Separate logger name for each application instance | 1,975,823 | <p>My python application consists of main program and several modules. Each module contains</p>
<pre><code>import logging
log = logging.getLogger('myapp.mymodule')
</code></pre>
<p>on global level. Handlers and other stuff initialized in main program, and typically all messages forwarded to syslog.</p>
<p>Now I want... | 1 | 2009-12-29T17:30:55Z | 1,976,145 | <p>Well, describing the problem really helps in solving it :) Just had an idea of using environment variables to pass parameters across all modules:</p>
<p>main.py:</p>
<pre><code>import os
os.environ['instance'] = 'blah'
import a
</code></pre>
<p>a.py:</p>
<pre><code>import os
import b
print 'a:', os.environ['in... | 0 | 2009-12-29T18:35:23Z | [
"python",
"logging"
] |
Separate logger name for each application instance | 1,975,823 | <p>My python application consists of main program and several modules. Each module contains</p>
<pre><code>import logging
log = logging.getLogger('myapp.mymodule')
</code></pre>
<p>on global level. Handlers and other stuff initialized in main program, and typically all messages forwarded to syslog.</p>
<p>Now I want... | 1 | 2009-12-29T17:30:55Z | 1,977,616 | <p>Simply write your own logging wrapper which will give you the correct name (tweak as needed to get the <strong>instance</strong> name that you want):</p>
<pre><code>def get_logger(obj=None):
if isinstance(obj, str):
return logging.getLogger(obj)
elif obj is not None:
logger_name ="%s.%s" % ... | 0 | 2009-12-29T23:39:41Z | [
"python",
"logging"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,975,867 | <p>Performancewise, if you have 1M records you might want to switch to a database or a different data structure. With the given data structure this will be a linear time operation. You could create an ID to records dict once though if you plan to do this query often.</p>
| 3 | 2009-12-29T17:42:29Z | [
"python"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,975,871 | <p>The best way would probably be to setup a reverse dict() from ids to names.</p>
| 3 | 2009-12-29T17:43:28Z | [
"python"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,975,993 | <p>Can two or more dicts share the same ID? If so, I presume you will need to return a list of indexes.</p>
<p>If you want to do a one-off search then you can do it with a list comprehension:</p>
<pre><code>>>> x = [
... {'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
... {'name': 'Wilmer Lummus', '... | 0 | 2009-12-29T18:08:54Z | [
"python"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,976,077 | <p>If frequency of building the index is low:</p>
<p>Create a lookup array of index values into your main list, such that eg</p>
<pre><code>lookup = [-1,-1,-1...]
...
def addtolookup
...
mainlistindex =lookup[myvalue]
if mainlistindex!=-1:
name=mainlist[mainlistindex].name
</code></pre>
<p>If frwquency is high, c... | 0 | 2009-12-29T18:23:21Z | [
"python"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,976,189 | <p>Simplest way to get the <em>first</em> index satisfying the condition (in Python 2.6 or better:</p>
<pre><code>next((i for i, d in enumerate(hugelist) if 735 in d['ids']), None)
</code></pre>
<p>this gives <code>None</code> if no item satisfies the condition; more generally you could put as the second argument to ... | 6 | 2009-12-29T18:41:30Z | [
"python"
] |
Python: find index of item containing X in list | 1,975,856 | <p>I have a huge list of data, more than 1M records in a form similar (though this is a much simpler form) to this:</p>
<pre><code>[
{'name': 'Colby Karnopp', 'ids': [441, 231, 822]},
{'name': 'Wilmer Lummus', 'ids': [438, 548, 469]},
{'name': 'Hope Teschner', 'ids': [735, 747, 488]},
{'name': 'Adolfo Fenric... | 2 | 2009-12-29T17:40:01Z | 1,981,386 | <p>It seems that the data structure is ill-suited to its use. Changing the list is costly - both the change itself (if you do any insertions/delitions) and the resulting need to rebuild a dict, or do linear scans every time.</p>
<p>The question is: <em>how</em> is your list changing?</p>
<p>Perhaps instead of using ... | 0 | 2009-12-30T17:34:47Z | [
"python"
] |
Does Google Webapp framework for Google App Engine maintain a link to the database? | 1,976,254 | <p>1) When a script gets data from the database using the db.Model.get_element_by_id("id") method, what id does it refer to, and how can you get it from the database.<br>
2) If you get a result using this method, does that result maintain a link to the database so that any changes to the result are reflected on the dat... | -1 | 2009-12-29T18:55:32Z | 1,976,311 | <p>Every entity in the db can have either a numeric ID or a key name; the <code>get_by_id</code> class method can actually fetch by either, depending on whether you pass it a number (then it looks for that ID) or a string (then it looks for that key name). (You can also pass it a list which contains numbers, numbers an... | 1 | 2009-12-29T19:06:43Z | [
"python",
"database",
"google-app-engine",
"reference",
"web-applications"
] |
Does Google Webapp framework for Google App Engine maintain a link to the database? | 1,976,254 | <p>1) When a script gets data from the database using the db.Model.get_element_by_id("id") method, what id does it refer to, and how can you get it from the database.<br>
2) If you get a result using this method, does that result maintain a link to the database so that any changes to the result are reflected on the dat... | -1 | 2009-12-29T18:55:32Z | 1,976,357 | <p>As Jonathan Feinberg suggested, this is answered in the Google App Engine tutorial. The relevant piece of the tutorial is found here: <a href="http://code.google.com/appengine/docs/python/gettingstarted/usingdatastore.html" rel="nofollow">http://code.google.com/appengine/docs/python/gettingstarted/usingdatastore.ht... | 2 | 2009-12-29T19:15:24Z | [
"python",
"database",
"google-app-engine",
"reference",
"web-applications"
] |
Does Google Webapp framework for Google App Engine maintain a link to the database? | 1,976,254 | <p>1) When a script gets data from the database using the db.Model.get_element_by_id("id") method, what id does it refer to, and how can you get it from the database.<br>
2) If you get a result using this method, does that result maintain a link to the database so that any changes to the result are reflected on the dat... | -1 | 2009-12-29T18:55:32Z | 1,986,230 | <p><a href="http://stackoverflow.com/questions/1982707/what-are-the-best-practices-of-the-appengine-datastore/1982800#1982800">James Polley</a> give me this <a href="http://code.google.com/appengine/articles/datastore/overview.html" rel="nofollow">link</a> to very interesting articles about the datastore, maybe this ca... | 1 | 2009-12-31T17:13:52Z | [
"python",
"database",
"google-app-engine",
"reference",
"web-applications"
] |
TypeError: can't multiply sequence by non-int of type 'float' | 1,976,467 | <p>I am a noob to Python and have not had any luck figuring this out. I want to be able to keep the tax variable in the code so it would be easily updated should it change. I have experimented with different means but was only able to get it to skip the print tax line and print the same values for the total and subtota... | 1 | 2009-12-29T19:33:37Z | 1,976,523 | <p>You need to use</p>
<pre><code>'$%.2f' % (sum(items_count) * tax)
</code></pre>
<p>instead of</p>
<pre><code>'$%.2f' % sum(items_count) * tax
</code></pre>
<p>The one you used will be evaluated as <code>('$%.2f' % sum(items_count)) * tax</code>, which is an error (multiplying a string by a float).</p>
| 1 | 2009-12-29T19:43:02Z | [
"python"
] |
TypeError: can't multiply sequence by non-int of type 'float' | 1,976,467 | <p>I am a noob to Python and have not had any luck figuring this out. I want to be able to keep the tax variable in the code so it would be easily updated should it change. I have experimented with different means but was only able to get it to skip the print tax line and print the same values for the total and subtota... | 1 | 2009-12-29T19:33:37Z | 1,976,530 | <p>Just add parens:</p>
<pre><code>print 'The amount of sales tax is: ' '$%.2f' % (sum(items_count) * tax)
</code></pre>
| 0 | 2009-12-29T19:43:56Z | [
"python"
] |
TypeError: can't multiply sequence by non-int of type 'float' | 1,976,467 | <p>I am a noob to Python and have not had any luck figuring this out. I want to be able to keep the tax variable in the code so it would be easily updated should it change. I have experimented with different means but was only able to get it to skip the print tax line and print the same values for the total and subtota... | 1 | 2009-12-29T19:33:37Z | 1,976,544 | <p>You need parentheses around the <code>sum(items_count) * tax</code>.</p>
<p>I took the liberty of cleaning up your code a bit as well :)</p>
<pre><code>items_count = []
tax = float(.06)
count = int(raw_input('How many items do you have? '))
while count:
price = float(raw_input('Please enter the price of your... | 1 | 2009-12-29T19:45:58Z | [
"python"
] |
TypeError: can't multiply sequence by non-int of type 'float' | 1,976,467 | <p>I am a noob to Python and have not had any luck figuring this out. I want to be able to keep the tax variable in the code so it would be easily updated should it change. I have experimented with different means but was only able to get it to skip the print tax line and print the same values for the total and subtota... | 1 | 2009-12-29T19:33:37Z | 1,976,551 | <p>It would help if you provide the back-trace for the error. I ran your code, and got this back-trace:</p>
<pre><code>Traceback (most recent call last):
File "t.py", line 13, in <module>
print 'The amount of sales tax is: ' '$%.2f' % sum(items_count) * tax
TypeError: can't multiply sequence by non-int of... | 5 | 2009-12-29T19:46:52Z | [
"python"
] |
DBus-Cherrypy merge issue | 1,976,622 | <p>I'm using python-dbus and cherrypy to monitor USB devices and provide a REST service that will maintain status on the inserted USB devices. I have written and debugged these services independently, and they work as expected.</p>
<p>Now, I'm merging the services into a single application. My problem is:
I cannot see... | 0 | 2009-12-29T19:56:51Z | 1,977,992 | <p>Yes; don't use cherrypy.quickstart. Instead, unpack it:</p>
<pre><code>cherrypy.config.update(conf)
cherrypy.tree.mount(USBREST())
cherrypy.engine.start()
</code></pre>
<p>Quickstart does the above, but finishes by calling engine.block(). If your program has some main loop other than CherryPy's, omit the call to e... | 3 | 2009-12-30T01:45:13Z | [
"python",
"cherrypy",
"dbus"
] |
DBus-Cherrypy merge issue | 1,976,622 | <p>I'm using python-dbus and cherrypy to monitor USB devices and provide a REST service that will maintain status on the inserted USB devices. I have written and debugged these services independently, and they work as expected.</p>
<p>Now, I'm merging the services into a single application. My problem is:
I cannot see... | 0 | 2009-12-29T19:56:51Z | 1,983,211 | <p>I figured this out. Apparently, there are a bunch of thread contention problems in glib. If you make an app that has DBusGMainLoop in it, then you cannot create another thread in your app. The new thread blocks immediately when start() is called on it. No amount of massaging will get the new thread to run.</p>
<p>I... | 3 | 2009-12-31T00:03:59Z | [
"python",
"cherrypy",
"dbus"
] |
Multiple level template inheritance in Jinja2? | 1,976,651 | <p>I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you... | 10 | 2009-12-29T20:03:42Z | 1,977,901 | <p>The way the documentation worded it, it seemed like it didn't support inheritance (n) levels deep. </p>
<blockquote>
<p>Unlike Python Jinja does not support
multiple inheritance. So you can only
have one extends tag called per
rendering.</p>
</blockquote>
<p>I didn't know it was just a rule saying 1 extend... | 12 | 2009-12-30T01:05:53Z | [
"python",
"css",
"django",
"django-templates",
"jinja2"
] |
Multiple level template inheritance in Jinja2? | 1,976,651 | <p>I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you... | 10 | 2009-12-29T20:03:42Z | 16,685,489 | <p>One of the best way to achieve multiple level of templating using jinja2 is to use 'include'
let say you have '<strong>base_layout.html</strong>' as your base template</p>
<pre><code><!DOCTYPE html>
<title>Base Layout</title>
<div>
<h1>Base</h1>
.... // write your code here
... | 13 | 2013-05-22T07:05:33Z | [
"python",
"css",
"django",
"django-templates",
"jinja2"
] |
Multiple level template inheritance in Jinja2? | 1,976,651 | <p>I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you... | 10 | 2009-12-29T20:03:42Z | 23,998,795 | <p>See the documentation <a href="http://jinja.pocoo.org/docs/templates/#extend" rel="nofollow">extending</a>, <a href="http://jinja.pocoo.org/docs/templates/#include" rel="nofollow">including</a>, and <a href="http://jinja.pocoo.org/docs/templates/#import" rel="nofollow">importing</a>.</p>
<p>This provides the means ... | 3 | 2014-06-02T16:06:44Z | [
"python",
"css",
"django",
"django-templates",
"jinja2"
] |
Multiple level template inheritance in Jinja2? | 1,976,651 | <p>I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you... | 10 | 2009-12-29T20:03:42Z | 24,635,850 | <p>I recently faced the same issue. I wanted to inherit several child templates and it worked. To illustrate it I would like to show you a solution that worked for me:</p>
<p>I had a base.html file that has block content and extended by manage.html. and that manage.html has a block sub_manage which is extended by inte... | 3 | 2014-07-08T15:29:34Z | [
"python",
"css",
"django",
"django-templates",
"jinja2"
] |
Multiple level template inheritance in Jinja2? | 1,976,651 | <p>I do html/css by trade, and I have been working on and off django projects as a template designer. I'm currently working on a site that uses Jinja2, which I have been using for about 2 weeks. I just found out through reading the documentation that Jinja2 doesn't support multiple level template inheritance, as in you... | 10 | 2009-12-29T20:03:42Z | 33,575,278 | <p>Try this, this work for me thanks to @Ixm answer.</p>
<p><strong>base.html</strong></p>
<pre><code><html xmlns="http://www.w3.org/1999/xhtml">
<body>
{% block content %}{% endblock %}
</body>
</html>
</code></pre>
<p><strong>content.html</strong></p>
<pre><code>{% extends "b... | 1 | 2015-11-06T20:34:05Z | [
"python",
"css",
"django",
"django-templates",
"jinja2"
] |
Retrieving ORM properties with SQLAlchemy | 1,977,008 | <p>I have three tables (users, articles, and tags) defined in SQLAlchemy and mapped with orm.mapper(). As you can see below, I'm adding a property "author" to each article which ties that article to the user that created it.</p>
<pre><code>orm.mapper(User, t_users)
orm.mapper(Tag, t_tags)
orm.mapper(Article, t_articl... | 1 | 2009-12-29T21:18:18Z | 1,977,083 | <p>Considered <em>eagerloading</em>, as covered in <a href="http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html#working-with-related-objects" rel="nofollow">Working with Related Objects</a>?</p>
<p>Your join is also funky. You're mixing the ORM with the SQL-toolkit, so you're getting row-objects and not mapped obj... | 3 | 2009-12-29T21:32:06Z | [
"python",
"orm",
"sqlalchemy"
] |
security question: Changing system password via python | 1,977,022 | <p>I'm working on a project aimed at system administration for a linux installation.</p>
<p>I need to perform some tasks like change the user password...</p>
<p>I was planning to use the subprocess module for this.
I'm concerned about security so, what are the 'best practices' when doing this via python?</p>
<p>is s... | 0 | 2009-12-29T21:21:29Z | 1,977,103 | <p>I believe the pexpect module would be the easiest way to go about this.</p>
<p><a href="http://pexpect.sourceforge.net/pexpect.html" rel="nofollow">http://pexpect.sourceforge.net/pexpect.html</a></p>
<p>Something along these lines should work pretty well:</p>
<pre><code>import pexpect
import time
def ChangePassw... | 3 | 2009-12-29T21:36:29Z | [
"python",
"security",
"system"
] |
Python Module To Detect Linux Distro Version | 1,977,306 | <p>Is there an existing python module that can be used to detect which distro of Linux and which version of the distro is currently installed.</p>
<p>For example:</p>
<ul>
<li>RedHat Enterprise 5</li>
<li>Fedora 11</li>
<li>Suse Enterprise 11</li>
<li>etc....</li>
</ul>
<p>I can make my own module by parsing various... | 3 | 2009-12-29T22:22:44Z | 1,977,330 | <p>Look up the docs for the platform module: <a href="http://docs.python.org/library/platform.html">http://docs.python.org/library/platform.html</a></p>
<p>Example:</p>
<pre>
>>> platform.uname()
('Linux', 'localhost', '2.6.31.5-desktop-1mnb', '#1 SMP Fri Oct 23 00:05:22 EDT 2009', 'x86_64', 'AMD Athlon(tm) 64 X2 Dua... | 14 | 2009-12-29T22:28:32Z | [
"python",
"redhat",
"suse"
] |
Python Module To Detect Linux Distro Version | 1,977,306 | <p>Is there an existing python module that can be used to detect which distro of Linux and which version of the distro is currently installed.</p>
<p>For example:</p>
<ul>
<li>RedHat Enterprise 5</li>
<li>Fedora 11</li>
<li>Suse Enterprise 11</li>
<li>etc....</li>
</ul>
<p>I can make my own module by parsing various... | 3 | 2009-12-29T22:22:44Z | 17,752,701 | <p>The above answer doesn't work on RHEL 5.x. The quickest way is on a redhat-like system is to read and look at the /etc/redhat-release file. This file is updated every time you run an update and the system gets upgraded by a minor release number.</p>
<pre><code>$ python
>>> open('/etc/redhat-release','r').r... | 1 | 2013-07-19T18:05:04Z | [
"python",
"redhat",
"suse"
] |
How to create module-wide variables in Python? | 1,977,362 | <p>Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable <code>__DBNAME__</code> did not exist.</p>
<pre><code>...
__DBNAME__ = None
def initDB(name):
if not __DBNAME__:
__DBNAME__ = name
els... | 101 | 2009-12-29T22:34:16Z | 1,977,383 | <p>For this, you need to declare the variable as global. However, a global variable is also accessible from <em>outside</em> the module by using <code>module_name.var_name</code>. Add this as the first line of your module:</p>
<pre><code>global __DBNAME__
</code></pre>
| 4 | 2009-12-29T22:41:14Z | [
"python",
"variables",
"singleton",
"module",
"scope"
] |
How to create module-wide variables in Python? | 1,977,362 | <p>Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable <code>__DBNAME__</code> did not exist.</p>
<pre><code>...
__DBNAME__ = None
def initDB(name):
if not __DBNAME__:
__DBNAME__ = name
els... | 101 | 2009-12-29T22:34:16Z | 1,978,076 | <p>Here is what is going on.</p>
<p>First, the only global variables Python really has are module-scoped variables. You cannot make a variable that is truly global; all you can do is make a variable in a particular scope. (If you make a variable inside the Python interpreter, and then import other modules, your vari... | 117 | 2009-12-30T02:20:57Z | [
"python",
"variables",
"singleton",
"module",
"scope"
] |
How to create module-wide variables in Python? | 1,977,362 | <p>Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable <code>__DBNAME__</code> did not exist.</p>
<pre><code>...
__DBNAME__ = None
def initDB(name):
if not __DBNAME__:
__DBNAME__ = name
els... | 101 | 2009-12-29T22:34:16Z | 1,978,217 | <p>You are falling for a subtle quirk. You cannot re-assign module-level variables inside a python function. I think this is there to stop people re-assigning stuff inside a function by accident. </p>
<p>You can access the module namespace, you just shouldn't try to re-assign. If your function assigns something, it au... | -5 | 2009-12-30T03:11:04Z | [
"python",
"variables",
"singleton",
"module",
"scope"
] |
How to create module-wide variables in Python? | 1,977,362 | <p>Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable <code>__DBNAME__</code> did not exist.</p>
<pre><code>...
__DBNAME__ = None
def initDB(name):
if not __DBNAME__:
__DBNAME__ = name
els... | 101 | 2009-12-29T22:34:16Z | 34,168,541 | <p>Steveha's answer was helpful to me, but omits an important point (one that that I think wisty was getting at). The global keyword is not necessary if you don't assign the variable in the function, but only access it.</p>
<p>If you assign the variable without the global keyword then Python creates a new local var -... | 5 | 2015-12-09T00:12:06Z | [
"python",
"variables",
"singleton",
"module",
"scope"
] |
How to create module-wide variables in Python? | 1,977,362 | <p>Is there a way to set up a global variable inside of a module? When I tried to do it the most obvious way as appears below, the Python interpreter said the variable <code>__DBNAME__</code> did not exist.</p>
<pre><code>...
__DBNAME__ = None
def initDB(name):
if not __DBNAME__:
__DBNAME__ = name
els... | 101 | 2009-12-29T22:34:16Z | 35,904,211 | <h2>Explicit and simple access to module variables without global</h2>
<hr>
<p>A neat recipe for module level variables, that</p>
<ul>
<li>eliminates the need for scope manipulation with <strong>global</strong> and <strong>nonlocal</strong></li>
<li>avoids clumsy access through instances of custom helper classes or ... | 4 | 2016-03-09T22:46:10Z | [
"python",
"variables",
"singleton",
"module",
"scope"
] |
Is there a Scrum plugin for the Roundup Issue Tracker? | 1,977,458 | <p>Is there a Scrum plugin for the <a href="http://roundup.sourceforge.net/" rel="nofollow">Roundup Issue Tracker</a> similar to <a href="http://www.agile42.com/cms/pages/agilo/" rel="nofollow">Agilo</a> for <a href="http://trac.edgewall.org/" rel="nofollow">Trac</a>? I realize that <a href="http://roundup.sourceforge.... | 3 | 2009-12-29T22:58:30Z | 1,999,898 | <p>After researching this some more, it appears that there is not a Scrum plugin for the <a href="http://roundup.sourceforge.net/" rel="nofollow">Roundup Issue Tracker</a> similar to <a href="http://www.agile42.com/cms/pages/agilo/" rel="nofollow">Agilo</a> for <a href="http://trac.edgewall.org/" rel="nofollow">Trac</a... | 0 | 2010-01-04T14:36:02Z | [
"python",
"agile",
"scrum",
"trac",
"roundup"
] |
2 dimensional interpolation problem | 1,977,467 | <p>I have DATA on x and y axes and the output is on z</p>
<p>for example</p>
<pre><code>y = 10
x = [1,2,3,4,5,6]
z = [2.3,3.4,5.6,7.8,9.6,11.2]
y = 20
x = [1,2,3,4,5,6]
z = [4.3,5.4,7.6,9.8,11.6,13.2]
y = 30
x = [1,2,3,4,5,6]
z = [6.3,7.4,8.6,10.8,13.6,15.2]
</code></pre>
<p>how can i find the value of z when y... | 0 | 2009-12-29T23:00:24Z | 1,977,536 | <p>I would say just take the average of the values around it. So if you need X=3.5 and Y=15 (3.5,15), you average (3,10), (3,20), (4,10) and (4,20). Since I have no idea what the data is you are dealing with, I am not sure if the exact proximity would matter - in which case you can just stick w/the average - or if yo... | 0 | 2009-12-29T23:19:58Z | [
"python",
"scipy"
] |
2 dimensional interpolation problem | 1,977,467 | <p>I have DATA on x and y axes and the output is on z</p>
<p>for example</p>
<pre><code>y = 10
x = [1,2,3,4,5,6]
z = [2.3,3.4,5.6,7.8,9.6,11.2]
y = 20
x = [1,2,3,4,5,6]
z = [4.3,5.4,7.6,9.8,11.6,13.2]
y = 30
x = [1,2,3,4,5,6]
z = [6.3,7.4,8.6,10.8,13.6,15.2]
</code></pre>
<p>how can i find the value of z when y... | 0 | 2009-12-29T23:00:24Z | 1,977,581 | <p>Given (not as Python code, since the second assignment would obliterate the first in each case, of course;-):</p>
<pre><code>y = 10
x = [1,2,3,4,5,6]
z = [2.3,3.4,5.6,7.8,9.6,11.2]
y = 20
x = [1,2,3,4,5,6]
z = [4.3,5.4,7.6,9.8,11.6,13.2]
</code></pre>
<p>you ask: "how can i find the value of z when y = 15 x = 3.... | 1 | 2009-12-29T23:32:51Z | [
"python",
"scipy"
] |
2 dimensional interpolation problem | 1,977,467 | <p>I have DATA on x and y axes and the output is on z</p>
<p>for example</p>
<pre><code>y = 10
x = [1,2,3,4,5,6]
z = [2.3,3.4,5.6,7.8,9.6,11.2]
y = 20
x = [1,2,3,4,5,6]
z = [4.3,5.4,7.6,9.8,11.6,13.2]
y = 30
x = [1,2,3,4,5,6]
z = [6.3,7.4,8.6,10.8,13.6,15.2]
</code></pre>
<p>how can i find the value of z when y... | 0 | 2009-12-29T23:00:24Z | 1,977,716 | <p>scipy.interpolate.bisplrep</p>
<p>Reference:
<a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.bisplrep.html" rel="nofollow">http://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.bisplrep.html</a></p>
<pre><code>import scipy
import math
import numpy
from scipy import in... | 4 | 2009-12-30T00:08:35Z | [
"python",
"scipy"
] |
State of Python Packaging: Buildout, Distribute, Distutils, EasyInstall, etc | 1,977,485 | <p>The last time I had to worry about installing Python packages was two years ago working with <a href="http://www.enthought.com/">Enthought</a>, <a href="http://numpy.scipy.org/">NumPy</a> and <a href="http://code.enthought.com/projects/mayavi/#Mayavi2">MayaVi2</a>. That experience gave me lingering nightmares relat... | 24 | 2009-12-29T23:06:50Z | 1,977,526 | <p><a href="http://packages.python.org/distribute/" rel="nofollow">Distribute</a> is a new fork of <code>setuptools</code> (<code>easy_install</code>), which should also be considered. Even <a href="http://mail.python.org/pipermail/python-dev/2009-October/092678.html" rel="nofollow">Guido recommends it</a>.</p>
<p>Bui... | 9 | 2009-12-29T23:16:36Z | [
"python",
"distutils",
"easy-install",
"buildout",
"distribute"
] |
State of Python Packaging: Buildout, Distribute, Distutils, EasyInstall, etc | 1,977,485 | <p>The last time I had to worry about installing Python packages was two years ago working with <a href="http://www.enthought.com/">Enthought</a>, <a href="http://numpy.scipy.org/">NumPy</a> and <a href="http://code.enthought.com/projects/mayavi/#Mayavi2">MayaVi2</a>. That experience gave me lingering nightmares relat... | 24 | 2009-12-29T23:06:50Z | 1,977,552 | <p>First of all, regardless of installation tool you decide on, start using <code>virtualenv --no-site-packages</code>! That way, python packages are not installed globally and you can easily get back to where you were in old as well as new projects.</p>
<p>Now, your comparison is a little bit apples-to-pears as the t... | 10 | 2009-12-29T23:24:15Z | [
"python",
"distutils",
"easy-install",
"buildout",
"distribute"
] |
State of Python Packaging: Buildout, Distribute, Distutils, EasyInstall, etc | 1,977,485 | <p>The last time I had to worry about installing Python packages was two years ago working with <a href="http://www.enthought.com/">Enthought</a>, <a href="http://numpy.scipy.org/">NumPy</a> and <a href="http://code.enthought.com/projects/mayavi/#Mayavi2">MayaVi2</a>. That experience gave me lingering nightmares relat... | 24 | 2009-12-29T23:06:50Z | 1,978,998 | <p>I can't easily help you with finding the strength, but I can make it a bit harder, since it also depends on the platform you want to use.</p>
<p>For example if you need to install python packages on Gentoo (GNU/Liunx) based computers, you can easily use <a href="http://code.google.com/p/g-pypi/" rel="nofollow" titl... | 0 | 2009-12-30T08:01:26Z | [
"python",
"distutils",
"easy-install",
"buildout",
"distribute"
] |
State of Python Packaging: Buildout, Distribute, Distutils, EasyInstall, etc | 1,977,485 | <p>The last time I had to worry about installing Python packages was two years ago working with <a href="http://www.enthought.com/">Enthought</a>, <a href="http://numpy.scipy.org/">NumPy</a> and <a href="http://code.enthought.com/projects/mayavi/#Mayavi2">MayaVi2</a>. That experience gave me lingering nightmares relat... | 24 | 2009-12-29T23:06:50Z | 1,986,981 | <p>I've done quiet a bit of research on this topic(a couple of weeks worth) before settling down on using buildout for all of my projects.</p>
<blockquote>
<p>DistUtils and EasyInstall in addition to Buildout!</p>
</blockquote>
<p>The difficulty in creating one place to compare all of these tools is that they're al... | 9 | 2009-12-31T20:26:34Z | [
"python",
"distutils",
"easy-install",
"buildout",
"distribute"
] |
State of Python Packaging: Buildout, Distribute, Distutils, EasyInstall, etc | 1,977,485 | <p>The last time I had to worry about installing Python packages was two years ago working with <a href="http://www.enthought.com/">Enthought</a>, <a href="http://numpy.scipy.org/">NumPy</a> and <a href="http://code.enthought.com/projects/mayavi/#Mayavi2">MayaVi2</a>. That experience gave me lingering nightmares relat... | 24 | 2009-12-29T23:06:50Z | 4,941,875 | <p>Whenever I need to remind myself of the state of play, I look at these as a starting point:</p>
<ul>
<li><a href="http://www.clemesha.org/blog/modern-python-hacker-tools-virtualenv-fabric-pip" rel="nofollow">The State of Python Packaging</a>, a response to:</li>
<li><a href="http://www.b-list.org/weblog/2008/dec/14... | 3 | 2011-02-09T06:15:38Z | [
"python",
"distutils",
"easy-install",
"buildout",
"distribute"
] |
Play Subset of audio file using Pyglet | 1,977,521 | <p>How can I use the pyglet API for sound to play subsets of a sound file e.g. from 1 second in to 3.5seconds of a 6 second sound clip?</p>
<p>I can load a sound file and play it, and can seek to the start of the interval desired, but am wondering how to stop playback at the point indicated?</p>
| 1 | 2009-12-29T23:15:55Z | 1,980,577 | <p>It doesn't appear that pyglet has support for setting a stop time. Your options are:</p>
<ol>
<li>Poll the current time and stop playback when you've reached your desired endpoint. This may not be precise enough for you.</li>
<li>Or, use a sound file library to extract the portion you want into a temporary sound ... | 1 | 2009-12-30T14:56:15Z | [
"python",
"audio",
"pyglet"
] |
Play Subset of audio file using Pyglet | 1,977,521 | <p>How can I use the pyglet API for sound to play subsets of a sound file e.g. from 1 second in to 3.5seconds of a 6 second sound clip?</p>
<p>I can load a sound file and play it, and can seek to the start of the interval desired, but am wondering how to stop playback at the point indicated?</p>
| 1 | 2009-12-29T23:15:55Z | 1,982,330 | <p>This approach seems to work: rather than poll the current time manually to stop playback, use the pyglet clock scheduler to run a stop callback once after a given interval. This is precise enough for my use case ;-)</p>
<pre><code>player = None
def stop_callback(dt):
if player != None:
player.stop()
def pla... | 0 | 2009-12-30T20:32:38Z | [
"python",
"audio",
"pyglet"
] |
Does Paramiko support non-secure telnet and ftp instead of just SSH and SFTP? | 1,977,571 | <p>I'm looking at existing python code that heavily uses Paramiko to do SSH and FTP. I need to allow the same code to work with some hosts that do not support a secure connection and over which I have no control. </p>
<p>Is there a quick and easy way to do it via Paramiko, or do I need to step back, create some abstra... | 5 | 2009-12-29T23:30:18Z | 1,978,007 | <p>No, paramiko has no support for telnet or ftp -- you're indeed better off using a higher-level abstraction and implementing it twice, with paramiko and without it (with the ftplib and telnetlib modules of the Python standard library).</p>
| 6 | 2009-12-30T01:53:00Z | [
"python",
"paramiko"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 1,977,790 | <p>On windows, you will need some trickery with <a href="http://sourceforge.net/projects/pywin32/" rel="nofollow">pywin32</a>, and <a href="http://blogs.msdn.com/coding4fun/archive/2006/10/31/912569.aspx" rel="nofollow">the windows API</a>, on 'linux' the answer will depend on which desktop is running - KDE, Gnome, or ... | 2 | 2009-12-30T00:28:34Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 1,977,831 | <p>On Windows with python2.5 or higher, use ctypes to load user32.dll and call <a href="http://msdn.microsoft.com/en-us/library/ms724947%28VS.85%29.aspx"><code>SystemParametersInfo()</code></a> with SPI_SETDESKWALLPAPER action. </p>
<p>For example:</p>
<pre><code>import ctypes
SPI_SETDESKWALLPAPER = 20
ctypes.windll... | 24 | 2009-12-30T00:40:55Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 1,978,847 | <p>On a gnome desktop, you usually do this with gconf, either directly calling gconftool or using the gconf python module. The latter is in the link given by unutbu. The first method could be done like this.</p>
<pre><code>import commands
command = "gconftool-2 --set /desktop/gnome/background/picture_filename --type s... | 8 | 2009-12-30T07:11:42Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 3,048,284 | <p>In gnome, it is probably preferable to use the python binding of gconf directly:</p>
<pre><code>import gconf
conf = gconf.client_get_default()
conf.set_string('/desktop/gnome/background/picture_filename','/path/to/filename.jpg')
</code></pre>
| 4 | 2010-06-15T19:17:01Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 20,024,286 | <p>Firstly, import <code>ctypes</code>: it gives you access to windows components such as the screensaver, wallpapers, etc.</p>
<p>Then call <code>ctypes.windll.user32.SystemParametersInfoA(a,b,c,d)</code>:</p>
<p><code>a</code> = 20</p>
<p><code>b</code> = 0</p>
<p><code>c</code> = The COMPLETE path of the image. ... | 1 | 2013-11-16T21:45:02Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 21,213,504 | <p>I use the following method in one of my initial projects:</p>
<pre><code> def set_wallpaper(self,file_loc, first_run):
# Note: There are two common Linux desktop environments where
# I have not been able to set the desktop background from
# command line: KDE, Enlightenment
deskt... | 7 | 2014-01-19T05:19:36Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 37,497,543 | <h1>changing the background image of desktop</h1>
<pre><code> import ctypes
import os
SPI_SETDESKWALLPAPER = 20
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, 'your image path', 3)
#'C:\\Users\\Public\\Pictures\\abc.jpg'
</code></pre>
<p>it worked fine for me. windows10, pyth... | 1 | 2016-05-28T09:50:57Z | [
"python",
"background",
"desktop"
] |
change desktop background | 1,977,694 | <p>how can i change desktop background with python</p>
<p>i want to do it in both windows and linux</p>
<p>thanks</p>
| 15 | 2009-12-30T00:02:26Z | 37,669,111 | <p>There is a difference what <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx" rel="nofollow">SystemParametersInfo</a> method to be called based on what if you are running on 64 bit or 32 bit OS. For 64 bit you have to use SystemParametersInfoW (Unicode) and for 32 bit SystemPar... | 1 | 2016-06-07T01:22:33Z | [
"python",
"background",
"desktop"
] |
Why doesn't my Django site return a 404 when checked with this URL parser? | 1,977,938 | <p>Here's a simple python function that checks if a given url is valid:</p>
<pre><code>from httplib import HTTP
from urlparse import urlparse
def checkURL(url):
p = urlparse(url)
h = HTTP(p[1])
h.putrequest('HEAD', p[2])
h.endheaders()
if h.getreply()[0] == 200:
return 1
else: return 0... | 1 | 2009-12-30T01:22:08Z | 1,977,970 | <p>Your page isn't actually returning a 404 status code:</p>
<pre><code>alex@alex-laptop:~$ curl -I http://wefoundland.com/GooseBumper
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 30 Dec 2009 01:37:41 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
</code></pre>
| 0 | 2009-12-30T01:38:09Z | [
"python",
"django",
"web-applications"
] |
Why doesn't my Django site return a 404 when checked with this URL parser? | 1,977,938 | <p>Here's a simple python function that checks if a given url is valid:</p>
<pre><code>from httplib import HTTP
from urlparse import urlparse
def checkURL(url):
p = urlparse(url)
h = HTTP(p[1])
h.putrequest('HEAD', p[2])
h.endheaders()
if h.getreply()[0] == 200:
return 1
else: return 0... | 1 | 2009-12-30T01:22:08Z | 1,977,975 | <p>Although the content says 404, the site is returning 200 OK in the headers:</p>
<pre><code>HTTP/1.1 200 OK
Server: nginx
Date: Wed, 30 Dec 2009 01:38:24 GMT
Content-Type: text/html; charset=utf-8
Connection: close
</code></pre>
<p>Make sure your response is using <code>HttpResponseNotFound</code>. e.g.:</p>
<pre>... | 1 | 2009-12-30T01:40:39Z | [
"python",
"django",
"web-applications"
] |
Why doesn't my Django site return a 404 when checked with this URL parser? | 1,977,938 | <p>Here's a simple python function that checks if a given url is valid:</p>
<pre><code>from httplib import HTTP
from urlparse import urlparse
def checkURL(url):
p = urlparse(url)
h = HTTP(p[1])
h.putrequest('HEAD', p[2])
h.endheaders()
if h.getreply()[0] == 200:
return 1
else: return 0... | 1 | 2009-12-30T01:22:08Z | 1,978,032 | <p>To get a 404 to be returned by your Django view, use HttpResponseNotFound instead of HttpResponse, or pass in 'status=404' to the HttpResponse constructor.</p>
| 0 | 2009-12-30T02:02:10Z | [
"python",
"django",
"web-applications"
] |
Jython Optimizations | 1,978,139 | <p>Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?</p>
<p>Specifically are there any flags that can be passed to the compiler, or code hints in tight loops.</p>
| 2 | 2009-12-30T02:44:13Z | 1,978,207 | <p>No flags, no code hints. You can optimize by tweaking your code much as you would for any other Python implementation (hoisting, etc), but profiling helps by telling you where it's <em>worth your while</em> to expend such effort -- so, sure, you can optimize "without resorting to profiling" (and the code changes to ... | 6 | 2009-12-30T03:06:31Z | [
"java",
"python",
"optimization",
"jython"
] |
Jython Optimizations | 1,978,139 | <p>Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?</p>
<p>Specifically are there any flags that can be passed to the compiler, or code hints in tight loops.</p>
| 2 | 2009-12-30T02:44:13Z | 1,990,415 | <p>Jython compiler does not offer lots of optimization choices. However, since the Java virtual machine (java) and perhaps compiler (javac) are getting invoked in the back end or at runtime, you should take a look at them.</p>
<p>Java has different runtime switches to use depending on whether you are going to launch i... | 1 | 2010-01-02T02:37:19Z | [
"java",
"python",
"optimization",
"jython"
] |
Jython Optimizations | 1,978,139 | <p>Are their any ways to optimize Jython without resorting to profiling or significantly changing the code?</p>
<p>Specifically are there any flags that can be passed to the compiler, or code hints in tight loops.</p>
| 2 | 2009-12-30T02:44:13Z | 6,481,974 | <p>I know this is an old question, but I'm just putting this for completeness.</p>
<p>You can use:<code>-J-server</code> flag to launch Jython in the Java server mode, which can help speed up the hot loops. (JVM will look to aggressively optimize, but might slow up the start up time)</p>
| 0 | 2011-06-26T03:32:40Z | [
"java",
"python",
"optimization",
"jython"
] |
Web2Py Working Directory | 1,978,188 | <p>Well I want to use WEb2Py because it's pretty nice..
I just need to change the working directory to the directory where all my modules/libraries/apps are so i can use them. I want to be able to import my real program when I use the web2py interface/applications. I need to do this instead of putting all my apps and ... | 3 | 2009-12-30T03:01:33Z | 1,978,212 | <p><a href="http://docs.python.org/library/os.html?highlight=os.chdir#os.chdir" rel="nofollow">os.chdir</a> lets you change the OS's working directory, but for your purposes (enabling imports of a bunch of modules &c which are constrained to live in some strange place) it seems better to add the needed directories ... | 0 | 2009-12-30T03:09:36Z | [
"python",
"directory",
"web2py"
] |
Web2Py Working Directory | 1,978,188 | <p>Well I want to use WEb2Py because it's pretty nice..
I just need to change the working directory to the directory where all my modules/libraries/apps are so i can use them. I want to be able to import my real program when I use the web2py interface/applications. I need to do this instead of putting all my apps and ... | 3 | 2009-12-30T03:01:33Z | 1,987,564 | <p>In any multi-threaded Python program (and not only Python) you should not use os.chdir and you should not change sys.path when you have more than one thread running. It is not safe because it affects other threads. Moreover you should not sys.path.append() in a loop because it may explode.</p>
<p>All web frameworks... | 5 | 2010-01-01T00:23:12Z | [
"python",
"directory",
"web2py"
] |
Web2Py Working Directory | 1,978,188 | <p>Well I want to use WEb2Py because it's pretty nice..
I just need to change the working directory to the directory where all my modules/libraries/apps are so i can use them. I want to be able to import my real program when I use the web2py interface/applications. I need to do this instead of putting all my apps and ... | 3 | 2009-12-30T03:01:33Z | 2,137,218 | <p>I had to do this very thing. I have few modules that I wanted to use from my controllers. If you want to be able to use the code that resides in the modules directory in the controller, you can use:</p>
<pre><code># use this in your controller code
impname = local_import('module_in_modules', reload=True)
# reload t... | 0 | 2010-01-26T02:40:40Z | [
"python",
"directory",
"web2py"
] |
pip equivalent to "easy_install ." | 1,978,220 | <p>Simple Question ;)</p>
<p>Is there a way to simply install the package using <a href="http://pypi.python.org/pypi/pip" rel="nofollow">pip</a> once you build it. Using <a href="http://pypi.python.org/pypi/setuptools" rel="nofollow">easy_install</a> I would simply build my <a href="http://code.google.com/p/pybugz/" ... | 2 | 2009-12-30T03:12:09Z | 1,978,359 | <p><code>pip install -e .</code> will install from a local source like <code>easy_install .</code> would.</p>
<p>Most of pip's commands and functionality are designed around installing from source repositories or <a href="http://pypi.python.org/pypi" rel="nofollow">PyPI</a> package listings, or maintaining consistentl... | 2 | 2009-12-30T04:04:01Z | [
"python"
] |
what does '__getnewargs__' do in this code | 1,978,264 | <pre><code>class NavigableString(unicode, PageElement):
def __new__(cls, value):
if isinstance(value, unicode):
return unicode.__new__(cls, value)
return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)
def __getnewargs__(self):#this line
return (NavigableString.__str__... | 7 | 2009-12-30T03:29:07Z | 1,978,269 | <p>Try this:</p>
<pre><code>x = NavigableString('foop')
y = pickle.dumps(x)
z = pickle.loads(y)
print x, z
</code></pre>
<p>I.e.: <a href="https://docs.python.org/2/library/pickle.html#object.__getnewargs__" rel="nofollow"><code>__getnewargs__</code></a> tells <code>pickle.dumps</code> to pickle <code>x</code> in suc... | 8 | 2009-12-30T03:32:03Z | [
"python"
] |
Web2py Import Once per Session | 1,978,426 | <p>I'm using Web2Py and i want to import my program simply once per session... not everytime the page is loaded. is this possible ? such as "import Client" being used on the page but only import it once per session..</p>
| 4 | 2009-12-30T04:27:58Z | 1,980,510 | <p>In web2py your models and controllers are executed, not imported. They are executed every time a request arrives. If you press the button [compile] in admin, they will be bytecode compiled and some other optimizations are performs.</p>
<p>If your app (in models and controllers) does "import somemodule", then the im... | 6 | 2009-12-30T14:40:09Z | [
"python",
"web2py"
] |
How to specify psycopg2 parameter for an array for timestamps (datetimes) | 1,978,586 | <p>I'd like to run a PostgreSQL query in Python using psycopg2, which filters by a column of type <code>timestamp without timezone</code>. I have a long list of allowed values for the timestamp (rather than a range) and psycopg2 conveniently handles arrays, so I thought that this should work:</p>
<pre><code>SELECT som... | 9 | 2009-12-30T05:42:28Z | 1,979,010 | <p>Try it like this:</p>
<pre><code>SELECT somestuff
FROM mytable
WHERE thetimestamp = ANY (%(times)s::timestamp[])
</code></pre>
| 12 | 2009-12-30T08:04:40Z | [
"python",
"postgresql",
"timestamp",
"psycopg2",
"python-db-api"
] |
How to specify psycopg2 parameter for an array for timestamps (datetimes) | 1,978,586 | <p>I'd like to run a PostgreSQL query in Python using psycopg2, which filters by a column of type <code>timestamp without timezone</code>. I have a long list of allowed values for the timestamp (rather than a range) and psycopg2 conveniently handles arrays, so I thought that this should work:</p>
<pre><code>SELECT som... | 9 | 2009-12-30T05:42:28Z | 4,851,777 | <p>If you use psycopg2 version 2.2.0 or newer, your original code should work, if you wrap the values in <code>Timestamp()</code> constructors, as you suggested.</p>
<p>The reason that it didn't work before was a bug in the psycopg2 implementation. The suggested workaround was to insert explicit casts into the SQL, a... | 3 | 2011-01-31T14:06:07Z | [
"python",
"postgresql",
"timestamp",
"psycopg2",
"python-db-api"
] |
Python web server? | 1,978,791 | <p>I want to develop a tool for my project using python. The requirements are:</p>
<ol>
<li>Embed a web server to let the user get some static files, but the traffic is not very high.</li>
<li>User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?</li>
<... | 0 | 2009-12-30T06:56:19Z | 1,978,818 | <p>Why dont you use open source build tools (continuous integration tools) like Cruise. Most of them come with a web server/xml interface and sometimes with fancy reports as well. </p>
| 0 | 2009-12-30T07:03:47Z | [
"python",
"cherrypy"
] |
Python web server? | 1,978,791 | <p>I want to develop a tool for my project using python. The requirements are:</p>
<ol>
<li>Embed a web server to let the user get some static files, but the traffic is not very high.</li>
<li>User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?</li>
<... | 0 | 2009-12-30T06:56:19Z | 1,979,101 | <p>what about the internal python webserver ?
just type "python web server" in google, and host the 1st result...</p>
| 3 | 2009-12-30T08:40:10Z | [
"python",
"cherrypy"
] |
Python web server? | 1,978,791 | <p>I want to develop a tool for my project using python. The requirements are:</p>
<ol>
<li>Embed a web server to let the user get some static files, but the traffic is not very high.</li>
<li>User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?</li>
<... | 0 | 2009-12-30T06:56:19Z | 1,979,317 | <p>Well, I used web frameworks like TurboGears, my current projects are based on Pylons. The last ist fairly easy to learn and both come with CherryPy. </p>
<p>To do some background job you could implement that in pylons too.</p>
<p>Just go to your config/environment.py and see that example:
(I implemented a queue he... | 1 | 2009-12-30T09:44:05Z | [
"python",
"cherrypy"
] |
Python web server? | 1,978,791 | <p>I want to develop a tool for my project using python. The requirements are:</p>
<ol>
<li>Embed a web server to let the user get some static files, but the traffic is not very high.</li>
<li>User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?</li>
<... | 0 | 2009-12-30T06:56:19Z | 1,979,714 | <p>Use the WSGI Reference Implementation <code>wsgiref</code> already provided with Python</p>
<p>Use REST protocols with JSON (not XML-RPC). It's simpler and faster than XML.</p>
<p>Background jobs are started with <code>subprocess</code>.</p>
| 1 | 2009-12-30T11:32:44Z | [
"python",
"cherrypy"
] |
Python web server? | 1,978,791 | <p>I want to develop a tool for my project using python. The requirements are:</p>
<ol>
<li>Embed a web server to let the user get some static files, but the traffic is not very high.</li>
<li>User can configure the tool using http, I don't want a GUI page, I just need a RPC interface, like XML-RPC? or others?</li>
<... | 0 | 2009-12-30T06:56:19Z | 1,979,792 | <p>This sounds like a fun project. So, why don't write your own HTTP server? Its not so complicated after all, HTTP is a well-known and easy to implement protocol and you'll gain a lot of new knowledge!</p>
<p>Check documentation or manual pages (whatever you prefer) of <code>socket()</code>, <code>bind()</code>, <cod... | -3 | 2009-12-30T11:51:41Z | [
"python",
"cherrypy"
] |
What causes subprocess.call to output blank file when attempting db export with mysqldump? | 1,978,944 | <p>I am having some problems using subprocess.call to export a database using mysqldump. I'm using Python 3.1 installed on Windows 7.</p>
<pre><code>from time import gmtime, strftime
import subprocess
DumpDir = "c:/apps/sqlbackup/";
DumpFile = "mysqldump-" + strftime("%Y-%m-%d-%H-%M-%S", gmtime()) + ".sql";
params =... | 0 | 2009-12-30T07:41:20Z | 1,979,413 | <p>I'm uncertain of what exactly caused the problem but the above code now works after:</p>
<ol>
<li>I reset the PATH environment setting
in Windows to be sure the path to
mysqldump is added everytime the PC
boots.</li>
<li>I restarted the PC (to ensure
Python/MySQL were restarted and PATH
environment settings were de... | 0 | 2009-12-30T10:15:07Z | [
"python",
"subprocess",
"mysqldump"
] |
How to get Python code to work with C++ App? | 1,978,967 | <p>I have the following python 3 file:</p>
<pre><code>import base64
import xxx
str = xxx.GetString()
str2 = base64.b64encode(str.encode())
str3 = str2.decode()
print str3
</code></pre>
<p>xxx is a module exported by some C++ code. This script does not work because calling Py_InitModule on this script returns NULL. T... | -1 | 2009-12-30T07:49:47Z | 1,979,007 | <p>Er... You have to investigate why Py_InitModule returns NULL. Posting the Python code using that module won't help.</p>
| 0 | 2009-12-30T08:04:28Z | [
"c++",
"python",
"string"
] |
How to get Python code to work with C++ App? | 1,978,967 | <p>I have the following python 3 file:</p>
<pre><code>import base64
import xxx
str = xxx.GetString()
str2 = base64.b64encode(str.encode())
str3 = str2.decode()
print str3
</code></pre>
<p>xxx is a module exported by some C++ code. This script does not work because calling Py_InitModule on this script returns NULL. T... | -1 | 2009-12-30T07:49:47Z | 1,979,720 | <p>Py_InitModule() is for <em>initializing</em> extension modules written in C, which is not what you are looking for here. If you want to import a module from C, there is a wealth of functions available in the C API: <a href="http://docs.python.org/c-api/import.html" rel="nofollow">http://docs.python.org/c-api/import.... | 0 | 2009-12-30T11:34:43Z | [
"c++",
"python",
"string"
] |
How to get Python code to work with C++ App? | 1,978,967 | <p>I have the following python 3 file:</p>
<pre><code>import base64
import xxx
str = xxx.GetString()
str2 = base64.b64encode(str.encode())
str3 = str2.decode()
print str3
</code></pre>
<p>xxx is a module exported by some C++ code. This script does not work because calling Py_InitModule on this script returns NULL. T... | -1 | 2009-12-30T07:49:47Z | 1,982,665 | <p>I know everybody says this...but:
Boost has an awesome library for exposing classes to python and getting data to and fro. If you're having problems, and looking for alternatives is an option I'd highly recommend the boost python library of the C interface. I've used them both, boost wins hands down imo. </p>
| 1 | 2009-12-30T21:43:38Z | [
"c++",
"python",
"string"
] |
Hooking into a wave-out on different platforms | 1,978,990 | <p>I am going to apologize in advance for being extremely vague, but my knowledge in this area is somewhat limited so I don't know the neccessary "keywords" to make my point/question clear. <em>Sorry</em>.</p>
<p>What I want to do is to find a way to obtain access to raw audio data as it is being output, say, when som... | 2 | 2009-12-30T07:59:20Z | 1,979,092 | <p>Whether you can access the "wave out" or "loopback" depends on your sound card and drivers.</p>
<p>The native sound API on Linux is called ALSA. Search for the ALSA docs and sample code and you should be able to get some code to record from your sound card, then hopefully set up your mixer so that you're recording... | 4 | 2009-12-30T08:38:26Z | [
"python",
"windows",
"linux",
"language-agnostic",
"audio"
] |
Is this essential functional programming feature missing from python? | 1,979,003 | <p>I have a class in python that allows me to save a function (in a database) for later use. Now I need to have a method in the class that allows me to call this function on some arguments. Since I don't know how many arguments the function has ahead of time, I have to pass them in as list. This is where things fall ap... | 1 | 2009-12-30T08:02:47Z | 1,979,025 | <p>Python uses * for argument expansion. If you want keyword arguments, expand a dict using **. So the macro you showed would be:</p>
<pre><code>def call(function, args):
return function(*args)
</code></pre>
<p>But usually the Pythonic way is to just do the call inline. There actually is a function called apply()... | 12 | 2009-12-30T08:07:44Z | [
"python"
] |
Is this essential functional programming feature missing from python? | 1,979,003 | <p>I have a class in python that allows me to save a function (in a database) for later use. Now I need to have a method in the class that allows me to call this function on some arguments. Since I don't know how many arguments the function has ahead of time, I have to pass them in as list. This is where things fall ap... | 1 | 2009-12-30T08:02:47Z | 1,979,035 | <p>No, this is not missing from python. <a href="http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/" rel="nofollow">SaltyCrane</a> explains the use of *args and **kwargs much better than I could.</p>
| 4 | 2009-12-30T08:10:47Z | [
"python"
] |
What is the difference between isinstance('aaa', basestring) and isinstance('aaa', str)? | 1,979,004 | <pre><code>a='aaaa'
print isinstance(a, basestring)#true
print isinstance(a, str)#true
</code></pre>
| 91 | 2009-12-30T08:02:53Z | 1,979,017 | <p>All strings are basestrings, but unicode strings are not of type str. Try this instead:</p>
<pre><code>>>> a=u'aaaa'
>>> print isinstance(a, basestring)
True
>>> print isinstance(a, str)
False
</code></pre>
| 7 | 2009-12-30T08:05:41Z | [
"python",
"built-in-types"
] |
What is the difference between isinstance('aaa', basestring) and isinstance('aaa', str)? | 1,979,004 | <pre><code>a='aaaa'
print isinstance(a, basestring)#true
print isinstance(a, str)#true
</code></pre>
| 91 | 2009-12-30T08:02:53Z | 1,979,022 | <p>Basestring is the superclass of string. In your example, a is of type "str" thus, it is both a basestring, and a str</p>
| 1 | 2009-12-30T08:06:55Z | [
"python",
"built-in-types"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.