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 |
|---|---|---|---|---|---|---|---|---|---|
Django ModelForm, having a foreign key as a hidden field | 1,817,286 | <p>I'm basically building a very trivial form. Let's stick to the books/publisher examples given in the django tutorials and build upon that.</p>
<p>I have a user login to the web app, at which point the first thing they can do is click on a publisher. This publisher then gets saved for their session. Upon that I take... | 2 | 2009-11-30T00:25:40Z | 1,817,430 | <p>Retrieving the instance of the publisher does protect against client-side changes that might reference a completely invalid publisher.</p>
<p>To your second question, yes you can include that field as a hidden field by <a href="http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-fie... | 1 | 2009-11-30T01:18:01Z | [
"python",
"django"
] |
Django ModelForm, having a foreign key as a hidden field | 1,817,286 | <p>I'm basically building a very trivial form. Let's stick to the books/publisher examples given in the django tutorials and build upon that.</p>
<p>I have a user login to the web app, at which point the first thing they can do is click on a publisher. This publisher then gets saved for their session. Upon that I take... | 2 | 2009-11-30T00:25:40Z | 8,601,657 | <p>There is no better way to do this.</p>
<p>I would use the <a href="https://docs.djangoproject.com/en/1.3/topics/http/shortcuts/#get-object-or-404" rel="nofollow">get_object_or_404</a> function for this.</p>
<p>And yes, you can prevent this to be modified by the user by setting the model field to <a href="https://d... | 0 | 2011-12-22T09:16:31Z | [
"python",
"django"
] |
Python: How to get StringIO.writelines to accept unicode string? | 1,817,695 | <p>I'm getting a </p>
<pre><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128)
</code></pre>
<p>on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's ... | 21 | 2009-11-30T03:23:28Z | 1,817,732 | <p><a href="http://docs.python.org/library/stringio.html">StringIO documentation</a>:</p>
<blockquote>
<p>Unlike the memory files implemented by the StringIO module, those provided by [cStringIO] are not able to accept Unicode strings that cannot be encoded as plain ASCII strings.</p>
</blockquote>
<p>If possible, ... | 20 | 2009-11-30T03:39:32Z | [
"python",
"string",
"unicode",
"ascii",
"stringio"
] |
Python: How to get StringIO.writelines to accept unicode string? | 1,817,695 | <p>I'm getting a </p>
<pre><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128)
</code></pre>
<p>on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's ... | 21 | 2009-11-30T03:23:28Z | 1,819,009 | <p>You can wrap the StringIO object in a <code>codecs.StreamReaderWriter</code> object to automatically encode and decode unicode.</p>
<p>Like this:</p>
<pre><code>import cStringIO, codecs
buffer = cStringIO.StringIO()
codecinfo = codecs.lookup("utf8")
wrapper = codecs.StreamReaderWriter(buffer,
codecinfo.st... | 33 | 2009-11-30T10:30:28Z | [
"python",
"string",
"unicode",
"ascii",
"stringio"
] |
Python: How to get StringIO.writelines to accept unicode string? | 1,817,695 | <p>I'm getting a </p>
<pre><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128)
</code></pre>
<p>on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's ... | 21 | 2009-11-30T03:23:28Z | 10,547,179 | <p>You can also encode your string as utf-8 manually before adding it to the StringIO</p>
<pre><code>for val in rows:
if isinstance(val, unicode):
val = val.encode('utf-8')
result.writelines(rows)
</code></pre>
| 1 | 2012-05-11T07:24:08Z | [
"python",
"string",
"unicode",
"ascii",
"stringio"
] |
Python: How to get StringIO.writelines to accept unicode string? | 1,817,695 | <p>I'm getting a </p>
<pre><code>UnicodeEncodeError: 'ascii' codec can't encode character u'\xa3' in position 34: ordinal not in range(128)
</code></pre>
<p>on a string stored in 'a.desc' below as it contains the '£' character. It's stored in the underlying Google App Engine datastore as a unicode string so that's ... | 21 | 2009-11-30T03:23:28Z | 25,780,543 | <p>Python 2.6 introduced the <code>io</code> module and you should consider using <a href="https://docs.python.org/2.6/library/io.html#io.StringIO" rel="nofollow"><code>io.StringIO()</code></a>, "An in-memory stream for unicode text."</p>
<p>In older python versions this is not optimized (pure Python), in later versio... | 0 | 2014-09-11T06:28:49Z | [
"python",
"string",
"unicode",
"ascii",
"stringio"
] |
Sound Monitoring in C++/Python | 1,817,733 | <p>I'm looking for an API (or some information as to where to look/start) that will ultimately allow me to monitor sound being played by the computer. </p>
<p>My end goal (well, certain to eventually be a stepping-stone) is an oscilloscope.</p>
<p>Where should I begin to look (aside from Google, which has yielded uns... | 1 | 2009-11-30T03:40:02Z | 1,817,739 | <p>I have in the past used a combination of <a href="http://cycling74.com/products/soundflower/" rel="nofollow">Soundflower</a> and <a href="http://people.csail.mit.edu/hubert/pyaudio/" rel="nofollow">PyAudio</a> for a similar purpose.</p>
<p>Soundflower allows you to route all audio output into an input that can then... | 1 | 2009-11-30T03:42:27Z | [
"c++",
"python",
"c",
"osx",
"audio"
] |
Sound Monitoring in C++/Python | 1,817,733 | <p>I'm looking for an API (or some information as to where to look/start) that will ultimately allow me to monitor sound being played by the computer. </p>
<p>My end goal (well, certain to eventually be a stepping-stone) is an oscilloscope.</p>
<p>Where should I begin to look (aside from Google, which has yielded uns... | 1 | 2009-11-30T03:40:02Z | 1,818,543 | <p>As @cobbal noted, on Mac OS X you would need to use PortAudio in some way to get the audio as it plays. The only other way to do it would be to use an audio player that has a plugin API, then write your code as a plugin for that one player. But a CoreAudio solution should make it possible for you to monitor all so... | 2 | 2009-11-30T08:37:41Z | [
"c++",
"python",
"c",
"osx",
"audio"
] |
PyKDE4 documentation | 1,817,751 | <p>I'm trying to get started using Python for KDE development. What is the canonical source for PyKDE4 reference documentation? The <a href="http://techbase.kde.org/Development/Languages/Python" rel="nofollow">Python</a> page of KDE TechBase is surprisingly sparse on details, and googling hasn't helped.</p>
| 1 | 2009-11-30T03:47:32Z | 1,817,762 | <p><a href="http://api.kde.org/pykde-4.3-api/allclasses.html" rel="nofollow">Here</a>.</p>
| 1 | 2009-11-30T03:52:21Z | [
"python",
"pykde"
] |
what functional tools remain in Python 3k? | 1,817,771 | <p>I have have read several entries regarding dropping several functional functions from future python, including map and reduce. </p>
<p>What is the official policy regarding functional extensions?<br>
is lambda function going to stay?</p>
| 4 | 2009-11-30T03:55:59Z | 1,817,785 | <p>Well, Python 3.0 and 3.1 are already released, so you can check this out for yourself. The end result was that map and filter were kept as built-ins, and lambda was also kept. The only change was that reduce was moved to the functools module; you just need to do</p>
<pre><code>from functools import reduce
</code></... | 10 | 2009-11-30T03:59:56Z | [
"python",
"functional-programming",
"python-3.x"
] |
what functional tools remain in Python 3k? | 1,817,771 | <p>I have have read several entries regarding dropping several functional functions from future python, including map and reduce. </p>
<p>What is the official policy regarding functional extensions?<br>
is lambda function going to stay?</p>
| 4 | 2009-11-30T03:55:59Z | 1,818,432 | <p>In Python 3.x, Python continues to have a rich set of functional-ish tools built in: list comprehensions, generator expressions, iterators and generators, and functions like <code>any()</code> and <code>all()</code> that have short-circuit evaluation wherever possible.</p>
<p>Python's "Benevolent Dictator For Life"... | 3 | 2009-11-30T08:06:18Z | [
"python",
"functional-programming",
"python-3.x"
] |
Python OLE2 date format conversion | 1,817,780 | <p>I have created a python script which pulls data out of OLE streams in Word documents, but am having trouble converting the OLE2-formatted timestamp to something more human-readable :(</p>
<p>The timestamp which is pulled out is 12760233021 but I cannot for the life of me convert this to a date like 12 Mar 2007 or s... | 0 | 2009-11-30T03:57:52Z | 1,818,038 | <p>(0) Please clarify "like 12 Mar 2007 or similar": do you mean that you expect the 11-digit int to convert to 12 Mar 2007, or is "12 Mar 2007" merely intended to convey the format in which you want to display the date? If the latter, can't you provide expected results by inspecting some files with MS Word or OpenOffi... | 2 | 2009-11-30T05:52:12Z | [
"python",
"ole"
] |
Python OLE2 date format conversion | 1,817,780 | <p>I have created a python script which pulls data out of OLE streams in Word documents, but am having trouble converting the OLE2-formatted timestamp to something more human-readable :(</p>
<p>The timestamp which is pulled out is 12760233021 but I cannot for the life of me convert this to a date like 12 Mar 2007 or s... | 0 | 2009-11-30T03:57:52Z | 21,605,833 | <p>this question is quite old but still useful. I recently improved OleFileIO_PL to fix the issue by converting dates automatically to Python datetime.</p>
<p>See the documentation on this page, especially the parts about get_metadata and get_properties:
<a href="https://bitbucket.org/decalage/olefileio_pl" rel="nofol... | 2 | 2014-02-06T14:37:49Z | [
"python",
"ole"
] |
What are these errors and how do I handle them? | 1,817,815 | <p>I am using this simple code</p>
<pre><code>for l in bios:
OpenThisLink = url + l
response = urllib2.urlopen(OpenThisLink)
</code></pre>
<p>to open about 200 urls and search them with regex (and BeautifulSoup), but after a dozen or so I get these errors and IDLE quits. What do they mean? How can I handle th... | 0 | 2009-11-30T04:16:14Z | 1,817,830 | <p>I don't know anything about the particular libraries you're using. However, this looks to me like one big stack trace that leads to this original error at the very end:</p>
<blockquote>
<p>HTTPError: HTTP Error 404: Not Found</p>
</blockquote>
<p>I think one of the links was bad and that triggered an exception w... | 2 | 2009-11-30T04:20:42Z | [
"python",
"beautifulsoup"
] |
What are these errors and how do I handle them? | 1,817,815 | <p>I am using this simple code</p>
<pre><code>for l in bios:
OpenThisLink = url + l
response = urllib2.urlopen(OpenThisLink)
</code></pre>
<p>to open about 200 urls and search them with regex (and BeautifulSoup), but after a dozen or so I get these errors and IDLE quits. What do they mean? How can I handle th... | 0 | 2009-11-30T04:16:14Z | 1,817,852 | <p>The error being raised is <code>HTTPError</code> - specifically, a 404 is being thrown for one of your URLs. You could either ignore it:</p>
<pre><code>for l in bios:
OpenThisLink = url + l
try:
response = urllib2.urlopen(OpenThisLink)
except urllib2.HTTPError:
pass
</code></pre>
<p>Or,... | 3 | 2009-11-30T04:28:54Z | [
"python",
"beautifulsoup"
] |
Format Python List to SQL script? | 1,817,886 | <p>I have a list need to be format it to SQL scripte </p>
<pre><code>list =
[['11', ' 0', " 'MMB'", " '2 MB INTERNATIONAL'", ' NULL', ' NULL', ' 0\n'],
['12', ' 0', " '3D STRUCTURES'", " '3D STRUCTURES'", ' NULL', ' NULL', ' 0\n'],
['13', ' 0', " '2 STRUCTURES'", " '2D STRUCTURES'", ' NULL', ' NULL', '... | 1 | 2009-11-30T04:44:54Z | 1,817,910 | <pre><code>Iterate over each element in the list
Unpack the element (which is also a list) into its fields
Generate a SQL line from these fields
</code></pre>
<p>The simplest and ugliest way that just gets the job done is:</p>
<pre><code>list = [
['11', ' 0', " 'MMB'", " '2 MB INTERNATIONAL'", ' NULL', ' NULL... | 1 | 2009-11-30T04:52:40Z | [
"python"
] |
Format Python List to SQL script? | 1,817,886 | <p>I have a list need to be format it to SQL scripte </p>
<pre><code>list =
[['11', ' 0', " 'MMB'", " '2 MB INTERNATIONAL'", ' NULL', ' NULL', ' 0\n'],
['12', ' 0', " '3D STRUCTURES'", " '3D STRUCTURES'", ' NULL', ' NULL', ' 0\n'],
['13', ' 0', " '2 STRUCTURES'", " '2D STRUCTURES'", ' NULL', ' NULL', '... | 1 | 2009-11-30T04:44:54Z | 1,817,923 | <p>Basically, this should work</p>
<pre><code>print "\n".join(["INSERT INTO `Tbl_ABC` VALUES ("+",".join(x).strip()+")" for x in list1])
</code></pre>
<p>result</p>
<pre><code>INSERT INTO `Tbl_ABC` VALUES (11, 0, 'MMB', '2 MB INTERNATIONAL', NULL, NULL, 0)
INSERT INTO `Tbl_ABC` VALUES (12, 0, '3D STRUCTURES', '3D ST... | 1 | 2009-11-30T04:59:28Z | [
"python"
] |
Format Python List to SQL script? | 1,817,886 | <p>I have a list need to be format it to SQL scripte </p>
<pre><code>list =
[['11', ' 0', " 'MMB'", " '2 MB INTERNATIONAL'", ' NULL', ' NULL', ' 0\n'],
['12', ' 0', " '3D STRUCTURES'", " '3D STRUCTURES'", ' NULL', ' NULL', ' 0\n'],
['13', ' 0', " '2 STRUCTURES'", " '2D STRUCTURES'", ' NULL', ' NULL', '... | 1 | 2009-11-30T04:44:54Z | 1,817,980 | <p>Technically it's fairly easy to take a list and convert it into sql by hand, but .... you might consider checking out SQLAlchemy <a href="http://www.sqlalchemy.org" rel="nofollow">http://www.sqlalchemy.org</a>. It is I feel really superb. It will do all your conversions for you from Python objects into database ta... | 0 | 2009-11-30T05:29:13Z | [
"python"
] |
SQLAlchemy not returning selected data | 1,818,054 | <p>I'm using SQLAlchemy as the ORM within an application i've been building for some time.</p>
<p>So far, it's been quite a painless ORM to implement and use, however, a recent feature I'm working on requires a persistent & distributed queue (list & worker) style implementation, which I've built in MySQL and P... | 1 | 2009-11-30T05:59:28Z | 1,818,483 | <p>You have executed 3 queries and MySQLdb creates a result set for each. You have to fetch first result, then call <code>cursor.nextset()</code>, fetch second and so on. </p>
<p>This answers your question, but won't be useful for you, because it won't solve locking issue. You have to understand how FOR UPDATE works f... | 3 | 2009-11-30T08:18:16Z | [
"python",
"mysql",
"sqlalchemy"
] |
Django-Use of unicode | 1,818,224 | <p>Why is a unicode function is required in models.py?</p>
<p>i.e,</p>
<pre><code>def __unicode__(self)
return sumid;
</code></pre>
| 8 | 2009-11-30T06:52:42Z | 1,818,240 | <p>It's not. If you define a <code>__unicode__()</code> method, Django will call it when it needs to render an object in a context where a string representation is needed (e.g. in the model's admin pages).</p>
<p>The <a href="http://docs.djangoproject.com/en/dev/ref/models/instances/#unicode">documentation</a> says:</... | 12 | 2009-11-30T07:01:15Z | [
"python",
"django"
] |
Django-Use of unicode | 1,818,224 | <p>Why is a unicode function is required in models.py?</p>
<p>i.e,</p>
<pre><code>def __unicode__(self)
return sumid;
</code></pre>
| 8 | 2009-11-30T06:52:42Z | 1,818,241 | <p>I'm a bit new to Django, but I think I can help you.</p>
<p>First, it isn't exactly required, but it's a really good idea. The field is used to create representations of your objects in the Django admin (otherwise they all have the same name :-P) and when you print out an object to your terminal window to see what'... | 6 | 2009-11-30T07:01:37Z | [
"python",
"django"
] |
Django-Use of unicode | 1,818,224 | <p>Why is a unicode function is required in models.py?</p>
<p>i.e,</p>
<pre><code>def __unicode__(self)
return sumid;
</code></pre>
| 8 | 2009-11-30T06:52:42Z | 22,022,890 | <p>I think the others have given some detailed explanations that should be more than enough for you. But here's a straightforward answer: <code>__unicode__()</code> is equivalent to <code>toString()</code> in Java (and many other languages)</p>
| 1 | 2014-02-25T18:23:59Z | [
"python",
"django"
] |
python logging in django | 1,818,236 | <p>I am using the basic python logger in django and it seems to be workng well. I have the logging setup in my setting.py as; </p>
<pre><code>logging.baseConfig(level = logging.NOTSET,
format='a format',
datemt=' a datefmt',
filename='path to log'... | 0 | 2009-11-30T06:58:53Z | 1,818,379 | <p>There's a recipe: <a href="http://code.activestate.com/recipes/466332/" rel="nofollow">http://code.activestate.com/recipes/466332/</a></p>
<blockquote>
<p>In any somewhat complex application, you likely want to log and handle most exceptions. The recipe shows a way to separate logging from handling, so that it is... | 0 | 2009-11-30T07:49:38Z | [
"python",
"django",
"logging",
"exception-handling"
] |
python logging in django | 1,818,236 | <p>I am using the basic python logger in django and it seems to be workng well. I have the logging setup in my setting.py as; </p>
<pre><code>logging.baseConfig(level = logging.NOTSET,
format='a format',
datemt=' a datefmt',
filename='path to log'... | 0 | 2009-11-30T06:58:53Z | 1,819,109 | <p>There's no need to catch the exception <em>just</em> so you can log it. You can log it and handle it, or else let it bubble up to some higher level which will log it and handle it. If you want to log exceptions which occur in some view, which you don't want to handle, then you can install some <a href="http://docs.d... | 1 | 2009-11-30T10:54:32Z | [
"python",
"django",
"logging",
"exception-handling"
] |
Python unicode: how to test against unicode string | 1,818,263 | <p>I have a script like this:</p>
<pre><code>#!/Python26/
# -*- coding: utf-8 -*-
import sys
import xlrd
import xlwt
argset = set(sys.argv[1:])
#----------- import ----------------
wb = xlrd.open_workbook("excelfile.xls")
#----------- script ----------------
#Get the first sheet either by name
sh = wb.sheet_by_nam... | 2 | 2009-11-30T07:07:54Z | 1,818,326 | <p>Python has a sequence type called <em>unicode</em> which will be useful here. These links contain more information to help you regarding this:</p>
<ul>
<li><a href="http://www.amk.ca/python/howto/unicode" rel="nofollow">Python Unicode HOWTO</a></li>
<li><a href="http://docs.python.org/library/stdtypes.html" rel="no... | 4 | 2009-11-30T07:32:28Z | [
"python",
"unicode"
] |
Python unicode: how to test against unicode string | 1,818,263 | <p>I have a script like this:</p>
<pre><code>#!/Python26/
# -*- coding: utf-8 -*-
import sys
import xlrd
import xlwt
argset = set(sys.argv[1:])
#----------- import ----------------
wb = xlrd.open_workbook("excelfile.xls")
#----------- script ----------------
#Get the first sheet either by name
sh = wb.sheet_by_nam... | 2 | 2009-11-30T07:07:54Z | 3,994,025 | <p>Try encoding the Excel unicode to string using cp1252 (windows default unicode) and then testing. I know a lot of people don't recommend this, but this is what sometimes solve my problems.</p>
<p>Pseudo=> <code>if sh.cell(i, 1).value.encode('cp1252') in argset:
...</code></p>
<p>Br.</p>
| 1 | 2010-10-22T05:03:08Z | [
"python",
"unicode"
] |
python 2.3 regex problem | 1,818,622 | <p>how do i set the regular expressions flags like multiline and ignorecase in python 2.3?</p>
<p>in python 2.6 its like this</p>
<p><code>re.findall(pattern,string, re.multiline | re.ignorecase)</code></p>
<p>but this doesn't seem to wok for python 2.3, any ideas?</p>
<p>pointers appreciated</p>
<p>edit: sorry, i... | 0 | 2009-11-30T08:59:53Z | 1,818,639 | <p>Compile the regexp in advance with <a href="http://docs.python.org/library/re.html#re.compile" rel="nofollow"><code>re.compile(pattern[, flags])</code></a>. Then you can pass the options as the second parameter.</p>
| 1 | 2009-11-30T09:03:08Z | [
"python",
"regex"
] |
python 2.3 regex problem | 1,818,622 | <p>how do i set the regular expressions flags like multiline and ignorecase in python 2.3?</p>
<p>in python 2.6 its like this</p>
<p><code>re.findall(pattern,string, re.multiline | re.ignorecase)</code></p>
<p>but this doesn't seem to wok for python 2.3, any ideas?</p>
<p>pointers appreciated</p>
<p>edit: sorry, i... | 0 | 2009-11-30T08:59:53Z | 1,818,645 | <p>the flags are uppercase in 2.4, e.g.:</p>
<pre><code>re.findall(pattern,string, re.MULTILINE | re.IGNORECASE)
</code></pre>
<p>works for me;</p>
<pre><code>Python 2.4.3 (#1, Sep 3 2009, 15:37:37)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more informat... | 1 | 2009-11-30T09:03:48Z | [
"python",
"regex"
] |
setuptools test hides import errors. How to have better info? | 1,818,684 | <p>In python setuptools, python setup.py test runs the testsuite. However if I have an import error in my testsuite, the only error message I obtain is an AttributeError complaining that my test class is missing. Is there a way to obtain a more detailed error message, so I can fix the testsuite ?</p>
<p>I will explain... | 6 | 2009-11-30T09:11:51Z | 1,819,862 | <p>The problem is that the first argument of <code>__import__()</code> must be module. When you need to reach some object with dotted name you never know what part is module and what isn't. The one way to get <code>module.subname</code> object is to try import it as submodule first and when it fails use <code>getattr(m... | 1 | 2009-11-30T13:34:58Z | [
"python",
"setuptools"
] |
setuptools test hides import errors. How to have better info? | 1,818,684 | <p>In python setuptools, python setup.py test runs the testsuite. However if I have an import error in my testsuite, the only error message I obtain is an AttributeError complaining that my test class is missing. Is there a way to obtain a more detailed error message, so I can fix the testsuite ?</p>
<p>I will explain... | 6 | 2009-11-30T09:11:51Z | 1,819,891 | <p>You may also want to try your code with <a href="http://pypi.python.org/pypi/distribute" rel="nofollow">Distribute</a> (a fork of setuptools since setuptools isn't being very actively maintained). I don't know if it will do anything different, but it's worth a shot.</p>
| 0 | 2009-11-30T13:41:41Z | [
"python",
"setuptools"
] |
setuptools test hides import errors. How to have better info? | 1,818,684 | <p>In python setuptools, python setup.py test runs the testsuite. However if I have an import error in my testsuite, the only error message I obtain is an AttributeError complaining that my test class is missing. Is there a way to obtain a more detailed error message, so I can fix the testsuite ?</p>
<p>I will explain... | 6 | 2009-11-30T09:11:51Z | 2,164,085 | <p>The issue here is that a Python ImportError doesn't tell you what module the error actually occurred in, unless you carefully inspect the traceback -- which the unittest module doesn't do. You'll have the same problem with the unittest module, regardless of what tool you use to run it.</p>
<p>You may want to try t... | 0 | 2010-01-29T18:10:34Z | [
"python",
"setuptools"
] |
setuptools test hides import errors. How to have better info? | 1,818,684 | <p>In python setuptools, python setup.py test runs the testsuite. However if I have an import error in my testsuite, the only error message I obtain is an AttributeError complaining that my test class is missing. Is there a way to obtain a more detailed error message, so I can fix the testsuite ?</p>
<p>I will explain... | 6 | 2009-11-30T09:11:51Z | 9,513,815 | <p>Use <a href="http://readthedocs.org/docs/nose/en/latest/" rel="nofollow">nose</a>. No modification to your code should be necessary. Just do:</p>
<pre><code>$ pip install nose
$ nosetests
</code></pre>
<p>If there is an ImportError, you will see it:</p>
<pre><code>ERROR: Failure: ImportError (cannot import name M... | 2 | 2012-03-01T09:42:23Z | [
"python",
"setuptools"
] |
cat filename.* > Datei | 1,818,758 | <p>I'm looking to translate the unix-command</p>
<pre><code>$ cat filename.* > Datei
</code></pre>
<p>into a Python program. Can somebody help ?</p>
| 1 | 2009-11-30T09:29:23Z | 1,818,775 | <p>Something like this should get you started:</p>
<pre><code>import glob
outfile = file("Datei", "wb")
for f in glob.glob("filename.*"):
infile = open(f, "rb")
outfile.write(infile.read())
infile.close()
outfile.close()
</code></pre>
<p><strong>UPDATE</strong>: Of course, input files need to be opened, too.</... | 2 | 2009-11-30T09:33:19Z | [
"python",
"cat"
] |
cat filename.* > Datei | 1,818,758 | <p>I'm looking to translate the unix-command</p>
<pre><code>$ cat filename.* > Datei
</code></pre>
<p>into a Python program. Can somebody help ?</p>
| 1 | 2009-11-30T09:29:23Z | 1,818,783 | <pre><code>import glob
output = open('Datei', 'wb')
chunk_size = 8192
for filename in glob.glob('filename.*'):
input = open(filename, 'rb')
buffer = input.read(chunk_size)
while buffer: # False if buffer == ""
output.write(buffer)
buffer = input.read(chunk_size)
input.close()
output.clo... | 1 | 2009-11-30T09:37:23Z | [
"python",
"cat"
] |
cat filename.* > Datei | 1,818,758 | <p>I'm looking to translate the unix-command</p>
<pre><code>$ cat filename.* > Datei
</code></pre>
<p>into a Python program. Can somebody help ?</p>
| 1 | 2009-11-30T09:29:23Z | 1,818,953 | <p>alternatively</p>
<pre><code>import os
f=open("outfile.txt","a")
for file in os.listdir("."):
if file.startswith("filename."):
for line in open(file):
f.write(line)
f.close()
</code></pre>
| 0 | 2009-11-30T10:16:05Z | [
"python",
"cat"
] |
cat filename.* > Datei | 1,818,758 | <p>I'm looking to translate the unix-command</p>
<pre><code>$ cat filename.* > Datei
</code></pre>
<p>into a Python program. Can somebody help ?</p>
| 1 | 2009-11-30T09:29:23Z | 1,858,912 | <p>Thank you for your help.
My script now:</p>
<pre><code>LOGFILEDIR="/olatfile/logs"
VORMONAT=time.strftime("%Y-%m", time.localtime(time.time()-3600*24*30))
LOGDATEIEN=LOGFILEDIR+"/olat.log."+VORMONAT +"-*"
print LOGDATEIEN
OUTPUT=LOGFILEDIR+"/olat.log."+VORMONAT
LOGFILE=OUTPUT
output = open(OUTPUT, 'wb')... | 0 | 2009-12-07T09:42:08Z | [
"python",
"cat"
] |
Creating new list with values from two prior lists | 1,818,763 | <p>Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consis... | 0 | 2009-11-30T09:30:40Z | 1,818,776 | <p>May I suggest making your job much simpler by using the list <code>.append()</code> method instead?</p>
<pre><code>>>> mylist = []
>>> mylist.append(1)
>>> mylist
[1]
>>> mylist.append(7)
>>> mylist
[1, 7]
</code></pre>
<p>Also another small suggestion, instead of itera... | 0 | 2009-11-30T09:33:27Z | [
"python",
"list"
] |
Creating new list with values from two prior lists | 1,818,763 | <p>Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consis... | 0 | 2009-11-30T09:30:40Z | 1,818,798 | <pre><code>l1 = [1,2,3]
l2 = [4,5,6]
newl = []
for item1, item2 in zip(reversed(l1), reversed(l2)):
newl.append(item1)
newl.append(item2)
print newl
</code></pre>
| 5 | 2009-11-30T09:43:22Z | [
"python",
"list"
] |
Creating new list with values from two prior lists | 1,818,763 | <p>Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consis... | 0 | 2009-11-30T09:30:40Z | 1,818,814 | <p>One-liner:</p>
<pre><code>reduce(lambda x,y: list(x+y), reversed(zip(list1,list2)))
</code></pre>
<p><code>list</code> is necessary as the prior operations return a tuple.</p>
| 0 | 2009-11-30T09:47:40Z | [
"python",
"list"
] |
Creating new list with values from two prior lists | 1,818,763 | <p>Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consis... | 0 | 2009-11-30T09:30:40Z | 1,819,156 | <pre><code>list(sum(zip(list1,list2)[::-1],()))
</code></pre>
| 2 | 2009-11-30T11:04:53Z | [
"python",
"list"
] |
Creating new list with values from two prior lists | 1,818,763 | <p>Given the lists list1 and list2 that are of the same length, create a new list consisting of the last element of list1 followed by the last element of list2 , followed by the second to last element of list1 , followed by the second to last element of list2 , and so on (in other words the new list should consis... | 0 | 2009-11-30T09:30:40Z | 1,819,177 | <p>Yet another way,</p>
<pre><code>from itertools import izip
l1 = [1, 2, 3, 4]
l2 = [5, 6, 7, 8]
l = []
for _ in izip(reversed(l1), reversed(l2)): l.extend(_)
</code></pre>
| 1 | 2009-11-30T11:09:48Z | [
"python",
"list"
] |
Executing a subprocess fails | 1,818,774 | <p>I tried to call a process via Python with several arguments. Executing the batch file itself works fine for me but translating it into Python makes me scream. Here the contents of the batch file:</p>
<pre><code>"C:\Program Files\bin\cspybat" "C:\Program Files\bin\armproc.dll" "C:\Program Files\bin\armjlink.dll" "C:... | 12 | 2009-11-30T09:33:00Z | 1,818,902 | <p>To execute a batch file in Windows:</p>
<pre><code>from subprocess import Popen
p = Popen("batchfile.bat", cwd=r"c:\directory\containing\batchfile")
stdout, stderr = p.communicate()
</code></pre>
<p>If you don't want to execute the batch file, but rather execute the command in your question directly from Python, y... | 20 | 2009-11-30T10:04:17Z | [
"python",
"subprocess"
] |
Executing a subprocess fails | 1,818,774 | <p>I tried to call a process via Python with several arguments. Executing the batch file itself works fine for me but translating it into Python makes me scream. Here the contents of the batch file:</p>
<pre><code>"C:\Program Files\bin\cspybat" "C:\Program Files\bin\armproc.dll" "C:\Program Files\bin\armjlink.dll" "C:... | 12 | 2009-11-30T09:33:00Z | 1,819,301 | <p>First, you don't <em>need</em> all those quotes. So remove them. You only need quotes around parameters that have a filename when that filename has a space (stupidly, Windows does this often).</p>
<p>Your parameters are simply a list of strings, some of which need quotes. Because Windows uses non-standard <code... | 0 | 2009-11-30T11:36:58Z | [
"python",
"subprocess"
] |
Close and open a new browser in Selenium | 1,818,969 | <p>I'm writting a script which needs the browser that selinium is operating to close and re-open, without loosing his cookies.</p>
<p>any idea of how to go about it?</p>
<p>Basically it's a check to see that if the user opens and closes his browser, his cookies stay intact.</p>
| 1 | 2009-11-30T10:20:03Z | 1,819,042 | <p>This is a feature of the browser and not your concern: If there is a bug in the browser, then there is little you can do. If you need to know whether a certain version of the browser works correctly, then define a manual test (write a document that explains the steps), do it once and record the result somewhere (lik... | 0 | 2009-11-30T10:38:04Z | [
"python",
"selenium"
] |
Close and open a new browser in Selenium | 1,818,969 | <p>I'm writting a script which needs the browser that selinium is operating to close and re-open, without loosing his cookies.</p>
<p>any idea of how to go about it?</p>
<p>Basically it's a check to see that if the user opens and closes his browser, his cookies stay intact.</p>
| 1 | 2009-11-30T10:20:03Z | 1,819,059 | <p>You should be able to use the <code>stop</code> and <code>start</code> commands. You will need to ensure that you are not clearing cookies between sessions, and depending on the browser you're launching you may also need to use the <code>-browserSessionReuse</code> command line option.</p>
| 3 | 2009-11-30T10:42:19Z | [
"python",
"selenium"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,819,195 | <p>If your problem is about shifted pixels, maybe you should compare against a frequency transform.</p>
<p>The FFT should be OK (<a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.fft.fft2.html#numpy.fft.fft2" rel="nofollow">numpy has an implementation for 2D matrices</a>), but I'm always hearing that ... | 6 | 2009-11-30T11:14:10Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,819,242 | <p>I guess you could do something like this:</p>
<ul>
<li><p>estimate vertical / horizontal displacement of reference image vs the comparison image. a
simple SAD (sum of absolute difference) with motion vectors would do to. </p></li>
<li><p>shift the comparison image accordingly </p></li>
<li>compute the pearson corr... | 0 | 2009-11-30T11:21:26Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,819,262 | <p>I have one done this with an image histogram comparison. My basic algorithm was this:</p>
<ol>
<li>Split image into red, green and blue</li>
<li>Create normalized histograms for red, green and blue channel and concatenate them into a vector <code>(r0...rn, g0...gn, b0...bn)</code> where n is the number of "buckets"... | 13 | 2009-11-30T11:27:37Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,819,528 | <p>First off, correlation is a very CPU intensive rather inaccurate measure for similarity. Why not just go for the sum of the squares if differences between individual pixels?</p>
<p>A simple solution, if the maximum shift is limited: generate all possible shifted images and find the one that is the best match. Make ... | 1 | 2009-11-30T12:27:13Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,820,393 | <p>I have done some image processing course long ago, and remember that when matching I normally started with making the image grayscale, and then sharpening the edges of the image so you only see edges. You (the software) can then shift and subtract the images until the difference is minimal. </p>
<p>If that differen... | 2 | 2009-11-30T15:12:42Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,821,664 | <p>A <a href="http://stackoverflow.com/questions/189943/how-can-i-quantify-difference-between-two-images">similar question</a> was asked a year ago and has numerous responses, including one regarding pixelizing the images, which I was going to suggest as at least a pre-qualification step (as it would exclude very non-s... | 31 | 2009-11-30T18:51:30Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Image comparison algorithm | 1,819,124 | <p>I'm trying to compare images to each other to find out whether they are different. First I tried to make a Pearson correleation of the RGB values, which works also quite good unless the pictures are a litte bit shifted. So if a have a 100% identical images but one is a little bit moved, I get a bad correlation value... | 31 | 2009-11-30T10:57:54Z | 1,849,015 | <p>You really need to specify the question better, but, looking at those 5 images, the organisms all seem to be oriented the same way. If this is always the case, you can try doing a <a href="http://www.mathworks.com/products/demos/image/cross%5Fcorrelation/imreg.html">normalized cross-correlation</a> between the two ... | 6 | 2009-12-04T19:05:27Z | [
"python",
"image",
"image-processing",
"compare",
"computer-vision"
] |
Sharing utilities modules across python projects | 1,819,326 | <p>What would be the best directory structure strategy to share a utilities module across my python projects? As the common modules would be updated with new functions I would not want to put them in the python install directory.</p>
<pre><code>project1/
project2/
sharedUtils/
</code></pre>
<p>From project1 I can not... | 9 | 2009-11-30T11:44:01Z | 1,819,334 | <p>Make a separate standalone package? And put it in the /site-packages of your python install?</p>
<p>There is also my personal favorite when it comes to development mode: use of symlinks and/or <code>*.pth</code> files.</p>
| 6 | 2009-11-30T11:46:54Z | [
"python",
"directory-structure"
] |
Sharing utilities modules across python projects | 1,819,326 | <p>What would be the best directory structure strategy to share a utilities module across my python projects? As the common modules would be updated with new functions I would not want to put them in the python install directory.</p>
<pre><code>project1/
project2/
sharedUtils/
</code></pre>
<p>From project1 I can not... | 9 | 2009-11-30T11:44:01Z | 1,819,723 | <p>Suppose you have <code>sharedUtils/utils_foo</code> and <code>sharedUtils/utils_bar</code>.
You could edit your PYTHONPATH to include <code>sharedUtils</code>, then import them in <code>project1</code> and <code>project2</code> using</p>
<pre><code>import utils_foo
import utils_bar
etc.
</code></pre>
<p>In linux y... | 5 | 2009-11-30T13:05:39Z | [
"python",
"directory-structure"
] |
Sharing utilities modules across python projects | 1,819,326 | <p>What would be the best directory structure strategy to share a utilities module across my python projects? As the common modules would be updated with new functions I would not want to put them in the python install directory.</p>
<pre><code>project1/
project2/
sharedUtils/
</code></pre>
<p>From project1 I can not... | 9 | 2009-11-30T11:44:01Z | 13,694,622 | <p>Directory structure:</p>
<pre><code>project1/foo.py
sharedUtils/bar.py
</code></pre>
<p>With the directories as you've shown them, from <code>foo.py</code> inside the <code>project1</code> directory you can add the relative path to <code>sharedUtils</code> as follows:</p>
<pre><code>import sys
sys.path.append("..... | 2 | 2012-12-04T01:16:18Z | [
"python",
"directory-structure"
] |
Are there functions in Python? | 1,819,372 | <p>Or is everything a method?</p>
<p>Since everything is an object, a </p>
<pre><code>def whatever:
</code></pre>
<p>is just a method of that file.py, right?</p>
| 8 | 2009-11-30T11:55:51Z | 1,819,393 | <p>Hmm... You can work with "whatever" as an ordinary function in file namespace.</p>
| 0 | 2009-11-30T12:00:45Z | [
"python",
"computer-science"
] |
Are there functions in Python? | 1,819,372 | <p>Or is everything a method?</p>
<p>Since everything is an object, a </p>
<pre><code>def whatever:
</code></pre>
<p>is just a method of that file.py, right?</p>
| 8 | 2009-11-30T11:55:51Z | 1,819,395 | <p>Python has functions. As everything is an object <a href="http://www.diveintopython.org/getting%5Fto%5Fknow%5Fpython/everything%5Fis%5Fan%5Fobject.html" rel="nofollow">functions are objects too</a>.</p>
<p>So, to use your example:</p>
<pre><code>>>> def whatever():
... pass
...
>>> whatever
... | 31 | 2009-11-30T12:00:52Z | [
"python",
"computer-science"
] |
Are there functions in Python? | 1,819,372 | <p>Or is everything a method?</p>
<p>Since everything is an object, a </p>
<pre><code>def whatever:
</code></pre>
<p>is just a method of that file.py, right?</p>
| 8 | 2009-11-30T11:55:51Z | 1,819,473 | <p>Unlike in Java in Python a file named <code>file.py</code> does not necessarily contain a class called <code>file</code> as you might expect if this was a java file named <code>file.java</code>.</p>
<p>In Python a file is a module which is really just a namespace (more comparable to a Java package than a Java class... | 2 | 2009-11-30T12:17:45Z | [
"python",
"computer-science"
] |
Cannot make cProfile work in IPython | 1,819,448 | <p>I'm missing something very basic. </p>
<pre><code>class C:
def __init__(self):
self.N = 100
pass
def f(self, param):
print 'C.f -- param'
for k in xrange(param):
for i in xrange(self.N):
for j in xrange(self.N):
a = float(i)/(1... | 12 | 2009-11-30T12:12:25Z | 1,821,029 | <p>Although IPython is very handy, there is a lot of rare cases when it breaks working code or masks errors. So it's useful to try code in standard interpreter when you get such mystical errors.</p>
| 3 | 2009-11-30T16:56:32Z | [
"python",
"profiling",
"profiler",
"ipython"
] |
Cannot make cProfile work in IPython | 1,819,448 | <p>I'm missing something very basic. </p>
<pre><code>class C:
def __init__(self):
self.N = 100
pass
def f(self, param):
print 'C.f -- param'
for k in xrange(param):
for i in xrange(self.N):
for j in xrange(self.N):
a = float(i)/(1... | 12 | 2009-11-30T12:12:25Z | 1,821,123 | <p>While inside IPython, you can use the <a href="http://ipython.org/ipython-doc/stable/interactive/magics.html?highlight=prun#magic-prun">%prun magic function</a>:</p>
<pre><code>In [9]: %prun c.f(3)
C.f -- param
3 function calls in 0.066 CPU seconds
Ordered by: internal time
ncalls tottime percall... | 23 | 2009-11-30T17:13:48Z | [
"python",
"profiling",
"profiler",
"ipython"
] |
Cannot make cProfile work in IPython | 1,819,448 | <p>I'm missing something very basic. </p>
<pre><code>class C:
def __init__(self):
self.N = 100
pass
def f(self, param):
print 'C.f -- param'
for k in xrange(param):
for i in xrange(self.N):
for j in xrange(self.N):
a = float(i)/(1... | 12 | 2009-11-30T12:12:25Z | 3,305,654 | <p>Not the original poster's problem, but you can also get this same error if you are invoking cProfile.run() in something other than the __main__ namespace (from within a function or an import). In that case you need to use the following instead of the run() method:</p>
<pre><code>cProfile.runctx("your code", globals... | 14 | 2010-07-22T03:46:58Z | [
"python",
"profiling",
"profiler",
"ipython"
] |
Database query across django ManyToManyField | 1,819,613 | <p>I'd like to find how to select all objects whose ManyToMany field contains another object. I have the following models (stripped down)</p>
<pre><code>class Category(models.Model):
pass
class Picture(models.Model):
categories = models.ManyToManyField(Category)
visible = models.BooleanField()
</code></pr... | 1 | 2009-11-30T12:42:45Z | 1,819,675 | <p>Why write a custom function and not use something like this? (untested)</p>
<pre><code>pics = Picture.objects.filter(categories__in = [1,2,3]).filter(visible=True)
</code></pre>
| 3 | 2009-11-30T12:55:52Z | [
"python",
"django",
"django-database"
] |
Generate ODT/DOC(X) and convert to PDF, without OO.o/MS | 1,819,700 | <p>I have a WSGI application that generates invoices and stores them as PDF.</p>
<p>So far I have solved similar problems with FPDF (or equivalents), generating the PDF from scratch like a GUI. Sadly this means the entire formatting logic (positioning headers, footers and content, styling) is in the application, where... | 6 | 2009-11-30T13:01:30Z | 1,819,781 | <p>I don't know how to go about automatic ODT -> PDF conversion, but a simpler route might be to generate your invoices as HTML and convert them to PDF using <a href="http://www.xhtml2pdf.com/" rel="nofollow">http://www.xhtml2pdf.com/</a>. I haven't tried the library myself, but it definitely seems promising.</p>
| 2 | 2009-11-30T13:20:04Z | [
"python",
"pdf",
"ms-office",
"openoffice.org",
"odf"
] |
Generate ODT/DOC(X) and convert to PDF, without OO.o/MS | 1,819,700 | <p>I have a WSGI application that generates invoices and stores them as PDF.</p>
<p>So far I have solved similar problems with FPDF (or equivalents), generating the PDF from scratch like a GUI. Sadly this means the entire formatting logic (positioning headers, footers and content, styling) is in the application, where... | 6 | 2009-11-30T13:01:30Z | 12,729,994 | <p>You can use QTextDocument, QTextCursor and QTextDocumentWriter in PyQt4. A simple example to show how to write to an odt file:</p>
<pre><code>>>>from pyqt4 import QtGui
# Create a document object
>>>doc = QtGui.QTextDocument()
# Create a cursor pointing to the beginning of the document
>>>... | 1 | 2012-10-04T14:50:25Z | [
"python",
"pdf",
"ms-office",
"openoffice.org",
"odf"
] |
Javascript communication with Selenium (RC) | 1,819,903 | <p>My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any <code>NaN</code>s creeping in.</p>
<p>We are planning... | 3 | 2009-11-30T13:42:54Z | 1,820,000 | <p>There is GetEval() call that returns the result of a JavaScript call to the page. If you have the JavaScript on the page then you can do something like </p>
<pre><code>self.assertEqual(selenium.GetEval("this.browserbot.getUserWindow().functionUnderTest().isNaN();"),"false","There was a NaN detected")
</code></pre>
... | 4 | 2009-11-30T14:00:06Z | [
"javascript",
"python",
"testing",
"selenium",
"selenium-rc"
] |
Javascript communication with Selenium (RC) | 1,819,903 | <p>My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any <code>NaN</code>s creeping in.</p>
<p>We are planning... | 3 | 2009-11-30T13:42:54Z | 1,902,514 | <p>If you are purely testing that the JavaScript functions are performing the correct calculations with the given inputs, I would suggest separating your JavaScript from your page and use a JavaScript testing framework to test the functionality. Testing low level code using Selenium is a lot of unnecessary overhead. ... | 1 | 2009-12-14T18:10:33Z | [
"javascript",
"python",
"testing",
"selenium",
"selenium-rc"
] |
Python - Exists a function that is called when an object does not implement a function? | 1,820,160 | <p>In Smalltalk there is a message <code>DoesNotUnderstand</code> that is called when an object does not understand a message (this is, when the object does not have the message sent implemented). </p>
<p>So, I like to know if in python there is a function that does the same thing.</p>
<p>In this example:</p>
<pre><... | 7 | 2009-11-30T14:31:48Z | 1,820,167 | <p>You are looking for the <code>__getattr__</code> method. Have a look <a href="http://pyref.infogami.com/%5F%5Fgetattr%5F%5F" rel="nofollow">here</a>.</p>
<p>If you want "total control" of a class, look at the <code>__getattribute__</code> special method then (<a href="http://pyref.infogami.com/%5F%5Fgetattribute%5F... | 3 | 2009-11-30T14:33:55Z | [
"python",
"oop",
"function"
] |
Python - Exists a function that is called when an object does not implement a function? | 1,820,160 | <p>In Smalltalk there is a message <code>DoesNotUnderstand</code> that is called when an object does not understand a message (this is, when the object does not have the message sent implemented). </p>
<p>So, I like to know if in python there is a function that does the same thing.</p>
<p>In this example:</p>
<pre><... | 7 | 2009-11-30T14:31:48Z | 1,820,170 | <p>Have you looked at object.<code>__getattr__(self, name)</code>, or object.<code>__getattribute__(self, name)</code> for new-style classes? (see <a href="http://docs.python.org/reference/datamodel.html#special-method-names" rel="nofollow">Special method names, Python language reference</a>)</p>
| 3 | 2009-11-30T14:34:53Z | [
"python",
"oop",
"function"
] |
Python - Exists a function that is called when an object does not implement a function? | 1,820,160 | <p>In Smalltalk there is a message <code>DoesNotUnderstand</code> that is called when an object does not understand a message (this is, when the object does not have the message sent implemented). </p>
<p>So, I like to know if in python there is a function that does the same thing.</p>
<p>In this example:</p>
<pre><... | 7 | 2009-11-30T14:31:48Z | 1,820,213 | <p>Here is a proposition for what you want to do:</p>
<pre><code>class callee:
def __init__(self, name):
self.name = name
def __call__(self):
print self.name, "has been called"
class A:
def __getattr__(self, attr):
return callee(attr)
a = A()
a.DoSomething()
>>> DoSome... | 7 | 2009-11-30T14:41:48Z | [
"python",
"oop",
"function"
] |
Python - Exists a function that is called when an object does not implement a function? | 1,820,160 | <p>In Smalltalk there is a message <code>DoesNotUnderstand</code> that is called when an object does not understand a message (this is, when the object does not have the message sent implemented). </p>
<p>So, I like to know if in python there is a function that does the same thing.</p>
<p>In this example:</p>
<pre><... | 7 | 2009-11-30T14:31:48Z | 1,830,740 | <p>I don't know why luc had the two separate classes. You can do it all with one class, if you use a closure. Like so:</p>
<pre><code>class A(object):
__ignored_attributes__ = set(["__str__"])
def __getattr__(self, name):
if __name__ in self.__ignored_attributes__:
return None
d... | 2 | 2009-12-02T04:57:54Z | [
"python",
"oop",
"function"
] |
tokenize a string keeping delimiters in Python | 1,820,336 | <p>Is there any equivalent to <code>str.split</code> in Python that also returns the delimiters?</p>
<p>I need to preserve the whitespace layout for my output after processing some of the tokens.</p>
<p>Example:</p>
<pre><code>>>> s="\tthis is an example"
>>> print s.split()
['this', 'is', 'an', '... | 17 | 2009-11-30T15:02:38Z | 1,820,371 | <p>How about</p>
<pre><code>import re
splitter = re.compile(r'(\s+|\S+)')
splitter.findall(s)
</code></pre>
| 19 | 2009-11-30T15:08:11Z | [
"python",
"string",
"split",
"tokenize"
] |
tokenize a string keeping delimiters in Python | 1,820,336 | <p>Is there any equivalent to <code>str.split</code> in Python that also returns the delimiters?</p>
<p>I need to preserve the whitespace layout for my output after processing some of the tokens.</p>
<p>Example:</p>
<pre><code>>>> s="\tthis is an example"
>>> print s.split()
['this', 'is', 'an', '... | 17 | 2009-11-30T15:02:38Z | 1,820,377 | <pre><code>>>> re.compile(r'(\s+)').split("\tthis is an example")
['', '\t', 'this', ' ', 'is', ' ', 'an', ' ', 'example']
</code></pre>
| 6 | 2009-11-30T15:08:56Z | [
"python",
"string",
"split",
"tokenize"
] |
tokenize a string keeping delimiters in Python | 1,820,336 | <p>Is there any equivalent to <code>str.split</code> in Python that also returns the delimiters?</p>
<p>I need to preserve the whitespace layout for my output after processing some of the tokens.</p>
<p>Example:</p>
<pre><code>>>> s="\tthis is an example"
>>> print s.split()
['this', 'is', 'an', '... | 17 | 2009-11-30T15:02:38Z | 1,820,378 | <p>the <code>re</code> module provides this functionality:</p>
<pre><code>>>> import re
>>> re.split('(\W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', '']
</code></pre>
<p>(quoted from the Python documentation).</p>
<p>For your example (split on whitespace), use <code>re... | 4 | 2009-11-30T15:09:01Z | [
"python",
"string",
"split",
"tokenize"
] |
tokenize a string keeping delimiters in Python | 1,820,336 | <p>Is there any equivalent to <code>str.split</code> in Python that also returns the delimiters?</p>
<p>I need to preserve the whitespace layout for my output after processing some of the tokens.</p>
<p>Example:</p>
<pre><code>>>> s="\tthis is an example"
>>> print s.split()
['this', 'is', 'an', '... | 17 | 2009-11-30T15:02:38Z | 1,820,485 | <p>Thanks guys for pointing for the <code>re</code> module, I'm still trying to decide between that and using my own function that returns a sequence...</p>
<pre><code>def split_keep_delimiters(s, delims="\t\n\r "):
delim_group = s[0] in delims
start = 0
for index, char in enumerate(s):
if delim_group... | -1 | 2009-11-30T15:28:21Z | [
"python",
"string",
"split",
"tokenize"
] |
tokenize a string keeping delimiters in Python | 1,820,336 | <p>Is there any equivalent to <code>str.split</code> in Python that also returns the delimiters?</p>
<p>I need to preserve the whitespace layout for my output after processing some of the tokens.</p>
<p>Example:</p>
<pre><code>>>> s="\tthis is an example"
>>> print s.split()
['this', 'is', 'an', '... | 17 | 2009-11-30T15:02:38Z | 1,820,543 | <p>Have you looked at pyparsing? Example borrowed from <a href="http://pyparsing.wikispaces.com/file/view/greeting.py" rel="nofollow">the pyparsing wiki</a>:</p>
<pre><code>>>> from pyparsing import Word, alphas
>>> greet = Word(alphas) + "," + Word(alphas) + "!"
>>> hello1 = 'Hello, World!... | 3 | 2009-11-30T15:39:03Z | [
"python",
"string",
"split",
"tokenize"
] |
How to temporarily move a django site into a subdirectory (for testing)? | 1,820,351 | <p>I am in the process of deploying a new Django site to replace a current Wordpress blog. As I get it setup, I want to test everything in the domain's subdirectory before I switch things to the root and "go live". For example: <code>http://example.com/django/</code></p>
<p>Editing my <code>.htaccess</code> file all... | 2 | 2009-11-30T15:04:57Z | 1,820,486 | <p>Set the following in your Apache directive:</p>
<pre><code> PythonOption django.root /django
</code></pre>
<p>Then django will trim <code>/django</code> off the front of every URL request.</p>
| 1 | 2009-11-30T15:28:24Z | [
"python",
"django",
"url",
".htaccess",
"fastcgi"
] |
How to temporarily move a django site into a subdirectory (for testing)? | 1,820,351 | <p>I am in the process of deploying a new Django site to replace a current Wordpress blog. As I get it setup, I want to test everything in the domain's subdirectory before I switch things to the root and "go live". For example: <code>http://example.com/django/</code></p>
<p>Editing my <code>.htaccess</code> file all... | 2 | 2009-11-30T15:04:57Z | 14,313,667 | <p>One way to do this would be to copy your current <code>mysite/mysite/urls.py</code> call it say <code>betaurls.py</code> to add <code>/django/</code> before each url, thus</p>
<pre><code>from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns(... | 0 | 2013-01-14T05:27:13Z | [
"python",
"django",
"url",
".htaccess",
"fastcgi"
] |
Appending lists from files to a single list in Python | 1,820,357 | <p>I'm trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here's what the files in the deferred folder contain:</p>
<pre><code>'173378981', '45000', '343434', '3453453', '34534545', '3452342', '234234', '42063008', 'Exempted', '10000'
'1000014833', '0', '0'... | 0 | 2009-11-30T15:05:26Z | 1,820,410 | <p>See <a href="http://docs.python.org/library/csv.html" rel="nofollow">the <code>csv</code> module</a>:</p>
<pre><code>BigList = []
for filename in glob.glob(deferredDir + '/*'):
PartList = csv.reader(open(filename))
BigList.extend(PartList)
</code></pre>
<p>Is that what you had in mind?</p>
| 1 | 2009-11-30T15:18:20Z | [
"python",
"list",
"io"
] |
Appending lists from files to a single list in Python | 1,820,357 | <p>I'm trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here's what the files in the deferred folder contain:</p>
<pre><code>'173378981', '45000', '343434', '3453453', '34534545', '3452342', '234234', '42063008', 'Exempted', '10000'
'1000014833', '0', '0'... | 0 | 2009-11-30T15:05:26Z | 1,820,416 | <p>The Python <code>cvs</code> module is likely a good answer:<br>
<a href="http://docs.python.org/library/csv.html" rel="nofollow">http://docs.python.org/library/csv.html</a></p>
<p><strong>Question:</strong></p>
<p><code>glob.glob()</code> returns an iterable already, so I do not see the point here...</p>
<pre><co... | 1 | 2009-11-30T15:18:47Z | [
"python",
"list",
"io"
] |
Appending lists from files to a single list in Python | 1,820,357 | <p>I'm trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here's what the files in the deferred folder contain:</p>
<pre><code>'173378981', '45000', '343434', '3453453', '34534545', '3452342', '234234', '42063008', 'Exempted', '10000'
'1000014833', '0', '0'... | 0 | 2009-11-30T15:05:26Z | 1,820,461 | <p>First, the last line in the store function needs to be like this <code>f.close()</code></p>
<p>Your store function saves the values in a newline-separated manner. To read all the files, should be enough:</p>
<pre><code>def getDeferredRecords():
"""docstring for getDeferredRecords"""
return dict((infile, li... | 2 | 2009-11-30T15:23:59Z | [
"python",
"list",
"io"
] |
Appending lists from files to a single list in Python | 1,820,357 | <p>I'm trying to write a function that reads files from a "deferred" directory which contains files that contain lists. Here's what the files in the deferred folder contain:</p>
<pre><code>'173378981', '45000', '343434', '3453453', '34534545', '3452342', '234234', '42063008', 'Exempted', '10000'
'1000014833', '0', '0'... | 0 | 2009-11-30T15:05:26Z | 1,820,810 | <p>Incorporating ideas from Tim Pietzcker, here are the re-written functions:</p>
<pre><code>def storeDeferredRecords(records):
"""docstring for createFile"""
now = datetime.datetime.now()
filename = deferredDir + '/' + now.strftime("%Y%m%d-%H%M%S")
f = csv.writer(open(filename, 'w'), delimiter=',')
f.writerows(r... | 0 | 2009-11-30T16:22:13Z | [
"python",
"list",
"io"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 1,820,396 | <p>You will want to do this, I think, in a <em>view</em> not in the <em>template</em>. So, something like:</p>
<pre><code>from django.http import HttpResponseRedirect
def myview(request):
if request.user.get_profile().is_store():
return HttpResponseRedirect("/path/")
# return regular view otherwise
... | 14 | 2009-11-30T15:14:58Z | [
"python",
"django"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 1,820,404 | <p>You wouldn't do this in the template, but in the view. Instead of calling render_to_response (which I presume you do now), you would call <a href="http://docs.djangoproject.com/en/dev/ref/request-response/" rel="nofollow">HttpResponseRedirect</a>.</p>
| 1 | 2009-11-30T15:16:55Z | [
"python",
"django"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 1,820,422 | <p>I think you might want to do the redirect in the view code.</p>
<p>For example, this would work in Django 1.1.</p>
<pre><code>from django.shortcuts import redirect
def my_view(request):
if request.user.get_profile().is_store:
return redirect('index')
# normal view code here
return ....
</code>... | 2 | 2009-11-30T15:19:40Z | [
"python",
"django"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 1,820,495 | <p>You really don't want to redirect in a template, as said in all other answers.</p>
<p>But if redirecting in a view is no option (why ever), you can do this:</p>
<pre><code>{% if user.get_profile.is_store %}
{% include '/path/to/template' %}
{% else %}
{% include '/path/to/another_template' %}
{% endif %}
<... | 3 | 2009-11-30T15:29:44Z | [
"python",
"django"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 5,583,185 | <p>Use the HTML's raw redirection.</p>
<pre><code>{% if user.get_profile.is_store %}
<meta http-equiv="REFRESH" content="0;url=http://redirect-url">
{% endif %}
</code></pre>
<p>or provide the redirection url as a context variable</p>
<pre><code>{% if user.get_profile.is_store %}
<meta http-equiv="R... | 9 | 2011-04-07T15:00:07Z | [
"python",
"django"
] |
Redirecting a user in a django template | 1,820,390 | <p>I have a django website that is spilt depending on what user type you are, I need to redirect users that are not entitled to see certain aspects of the site,</p>
<p>in my template, I have</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>how would I go abo... | 4 | 2009-11-30T15:10:34Z | 10,517,169 | <p>Of course sometimes we have views imported from django official code, or others that does not depend on us. We cannot place a redirect in those views, so the only way is through a template that these (untouchable) views are using.</p>
| 2 | 2012-05-09T13:30:03Z | [
"python",
"django"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,679 | <p>The standard library, especially the built-in functions. They seem trivial but can yield impressive results!</p>
<p>It really pays to know the basics of a default python installation. If you doubt that just follow the Stack Overflow python questions. Some answers are just amazing :)</p>
| 1 | 2009-11-30T15:58:58Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,687 | <p>The standard libraries, i.e. the ones considered more or less part of Python. Start with those, there is plenty to learn before starting on 3rd party stuff.</p>
<p>Things like:</p>
<ul>
<li><a href="http://docs.python.org/library/os.html" rel="nofollow">os</a></li>
<li><a href="http://docs.python.org/library/re.ht... | 8 | 2009-11-30T15:59:36Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,697 | <p>The <code>re</code> module is a must. <code>itertools</code> also often comes handy. </p>
<p>Generally speaking: Take a deep look at <a href="http://docs.python.org/library/index.html" rel="nofollow">Standard library</a>. Then you might think about wxPython for GUI, numPy for computations, Django for web and Amara ... | 5 | 2009-11-30T16:00:20Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,700 | <p>Check out the excellent <a href="http://www.doughellmann.com/projects/PyMOTW/" rel="nofollow">Python Module of the Week</a> blog series.</p>
| 8 | 2009-11-30T16:01:07Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,701 | <p>Since you ask about libraries, not specific modules in them, the <a href="http://docs.python.org/library/index.html" rel="nofollow">standard library</a> that comes with Python is the first and most fundamental answer; the programming challenges from a C++ book are unlikely to require anything beyond that (such as GU... | 2 | 2009-11-30T16:01:10Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,820,925 | <p>Actually, to work problems from a C++ book using Python, you mainly just need to master <a href="http://docs.python.org/library/stdtypes.html" rel="nofollow">Python's built-in types</a>, especially the data structures <code>tuple</code>, <code>list</code>, <code>set</code>, and <code>dict</code>; and the <a href="ht... | 4 | 2009-11-30T16:41:47Z | [
"python"
] |
Must Standard libraries for python beginner | 1,820,657 | <p>Though there can be many but as i am very new to python so which modules or classes within standard libraries i should know when programming in python, especially when i am practicing programming challenges from a C++ book? Libraries which can make my life easier? Since there can be no single correct answer, i am ma... | 3 | 2009-11-30T15:55:14Z | 1,821,021 | <p><a href="http://docs.python.org/library/math.html" rel="nofollow">math</a></p>
<p>Seems too fundamental, but when getting started with python (lets face it, I'm still learning it) I missed some functions in the math module that would have been helpful. I ended up writing my own versions which worked but I could hav... | 4 | 2009-11-30T16:55:53Z | [
"python"
] |
Django redirect not working | 1,820,852 | <p>I can see the problem, I attached my code and error page.</p>
<p>In my template, I have:</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>In my view, I have:</p>
<pre><code>def downloads(request):
"""
Downloads page, a user facing page for the trade memb... | 0 | 2009-11-30T16:28:44Z | 1,820,999 | <p>It looks like the user.get_profile() return value is empty, and therefore it fails on the next is_store() call:</p>
<pre><code>return not self.account is None
</code></pre>
<p>That fails, because self is empty (i.e. None).</p>
<p>[edit] After reading <a href="http://www.djangobook.com/en/1.0/chapter12/" rel="nofo... | 0 | 2009-11-30T16:53:26Z | [
"python",
"django",
"django-templates",
"django-views"
] |
Django redirect not working | 1,820,852 | <p>I can see the problem, I attached my code and error page.</p>
<p>In my template, I have:</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>In my view, I have:</p>
<pre><code>def downloads(request):
"""
Downloads page, a user facing page for the trade memb... | 0 | 2009-11-30T16:28:44Z | 1,821,012 | <p><code>self.account</code> is pointing at a non-existent <code>Account</code> object when it's trying to process <code>is_store()</code>. I would guess you are using a database that doesn't enforce foreign keys *cough*MySQL*cough*, and your data got messed up.</p>
| 3 | 2009-11-30T16:55:18Z | [
"python",
"django",
"django-templates",
"django-views"
] |
Django redirect not working | 1,820,852 | <p>I can see the problem, I attached my code and error page.</p>
<p>In my template, I have:</p>
<pre><code>{% if user.get_profile.is_store %}
<!--DO SOME LOGIC-->
{%endif%}
</code></pre>
<p>In my view, I have:</p>
<pre><code>def downloads(request):
"""
Downloads page, a user facing page for the trade memb... | 0 | 2009-11-30T16:28:44Z | 1,821,025 | <p>It's not redirect that is not working- it's your is_store() procedure or non-existing profile. You should check what exactly is self.account referring.<br>
As far as I can tell from looking at code, you have two tables in your database- one for baseaccount, which only stores user id, and account, which stores all fi... | 0 | 2009-11-30T16:56:00Z | [
"python",
"django",
"django-templates",
"django-views"
] |
Need a Python package suitable for visualizing queue simulations | 1,820,939 | <p>I am working on a simulation in Queueing Theory, within a wxPython GUI. (<a href="http://garlicsim.org" rel="nofollow">Project link</a>.) What would be a good tool for visualizing the simulations? The visualization should consist of simple objects, such as clients, servers, a facility and a population. They should a... | 3 | 2009-11-30T16:43:58Z | 1,821,006 | <p>Here's a list of some 2D Graphics packages you might consider:</p>
<p><a href="http://www.vrplumber.com/py3d.py?category=graphics" rel="nofollow">http://www.vrplumber.com/py3d.py?category=graphics</a></p>
| 0 | 2009-11-30T16:54:24Z | [
"python",
"wxpython",
"visualization",
"simulation",
"scientific-computing"
] |
Need a Python package suitable for visualizing queue simulations | 1,820,939 | <p>I am working on a simulation in Queueing Theory, within a wxPython GUI. (<a href="http://garlicsim.org" rel="nofollow">Project link</a>.) What would be a good tool for visualizing the simulations? The visualization should consist of simple objects, such as clients, servers, a facility and a population. They should a... | 3 | 2009-11-30T16:43:58Z | 1,821,152 | <p>wxPython has the OGL (Object Graphics Library) for doing this sort of thing. I have not used it so I don't know how useful or robust it is, but it should be easier than using raw wx graphics primitives.</p>
<p>It is in wx.lib.ogl.</p>
| 0 | 2009-11-30T17:20:28Z | [
"python",
"wxpython",
"visualization",
"simulation",
"scientific-computing"
] |
Need a Python package suitable for visualizing queue simulations | 1,820,939 | <p>I am working on a simulation in Queueing Theory, within a wxPython GUI. (<a href="http://garlicsim.org" rel="nofollow">Project link</a>.) What would be a good tool for visualizing the simulations? The visualization should consist of simple objects, such as clients, servers, a facility and a population. They should a... | 3 | 2009-11-30T16:43:58Z | 1,822,142 | <p>Have you considered <a href="http://www.nsnam.org/" rel="nofollow">using <strong>NS3</strong></a>? It may be a little more than what you're looking for, but it is the standard for open source queue simulations. Here's the documentation on <a href="http://www.nsnam.org/wiki/index.php/NS-3_Python_Bindings" rel="nofo... | 1 | 2009-11-30T20:15:38Z | [
"python",
"wxpython",
"visualization",
"simulation",
"scientific-computing"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.