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 |
|---|---|---|---|---|---|---|---|---|---|
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 1,835,162 | <p>The <code>str</code> object doesn't have an <code>__iter__</code> attribute</p>
<pre><code>>>> hasattr('', '__iter__')
False
</code></pre>
<p>so you can do a check</p>
<pre><code>assert hasattr(x, '__iter__')
</code></pre>
<p>and this will also raise a nice <code>AssertionError</code> for any other non-... | 3 | 2009-12-02T19:15:52Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 1,835,259 | <p>Remember that in Python we want to use "duck typing". So, anything that acts like a list can be treated as a list. So, don't check for the type of a list, just see if it acts like a list.</p>
<p>But strings act like a list too, and often that is not what we want. There are times when it is even a problem! So, c... | 121 | 2009-12-02T19:30:13Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 1,835,402 | <p>I tend to do this (if I really, really had to):</p>
<pre><code>for i in some_var:
if type(i) == type(list()):
#do something with a list
elif type(i) == type(tuple()):
#do something with a tuple
elif type(i) == type(str()):
#here's your string
</code></pre>
| -3 | 2009-12-02T19:59:42Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 1,835,599 | <p>Generally speaking, the fact that a function which iterates over an object works on strings as well as tuples and lists is more feature than bug. You certainly <em>can</em> use <code>isinstance</code> or duck typing to check an argument, but why should you?</p>
<p>That sounds like a rhetorical question, but it isn... | 5 | 2009-12-02T20:33:02Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 5,971,720 | <p>Python with PHP flavor:</p>
<pre><code>def is_array(var):
return isinstance(var, (list, tuple))
</code></pre>
| 16 | 2011-05-11T23:30:04Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 13,117,648 | <p>This is not intended to directly answer the OP, but I wanted to share some related ideas.</p>
<p>I was very interested in @steveha answer above, which seemed to give an example where duck typing seems to break. On second thought, however, his example suggests that duck typing is hard to conform to, but it does <em>... | 3 | 2012-10-29T07:42:20Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 14,657,269 | <p>I do this in my testcases.</p>
<pre><code>def assertIsIterable(self, item):
#add types here you don't want to mistake as iterables
if isinstance(item, basestring):
raise AssertionError("type %s is not iterable" % type(item))
#Fake an iteration.
try:
for x in item:
break... | 1 | 2013-02-02T00:25:26Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 21,522,971 | <pre><code>H = "Hello"
if type(H) is list or type(H) is tuple:
## Do Something.
else
## Do Something.
</code></pre>
| 32 | 2014-02-03T08:48:45Z | [
"python",
"list",
"types",
"assert"
] |
Python: check if an object is a list or tuple (but not string) | 1,835,018 | <p>This is what I normally do in order to ascertain that the input is a <code>list</code>/<code>tuple</code> - but not a <code>str</code>. Because many times I stumbled upon bugs where a function passes a <code>str</code> object by mistake, and the target function does <code>for x in lst</code> assuming that <code>lst<... | 257 | 2009-12-02T18:53:07Z | 37,842,328 | <pre><code>import collections
if isinstance(obj, collections.Sequence) and not isinstance(obj, basestring):
print "obj is a sequence (list, tuple, etc) but not a string or unicode"
</code></pre>
| 5 | 2016-06-15T17:46:47Z | [
"python",
"list",
"types",
"assert"
] |
Pivoting SQLite table, setwise like SQL should be | 1,835,391 | <p>I have some data. 224,000 rows of it, in a SQLite database. I want to extract time series information from it to feed a data visualisation tool. Essentially, each row in the db is an event that has (among other things not strictly relevant) a time-date group in seconds since the epoch and a name responsible for it. ... | 3 | 2009-12-02T19:57:35Z | 1,836,090 | <p>A good approach in cases like this is not to push SQL to the point where it becomes convoluted and hard to understand and maintain. Let SQL do what it conveniently can and post-process the query results in Python.</p>
<p>Here's a cut-down version of a simple crosstab generator that I wrote. The full version deliver... | 3 | 2009-12-02T21:54:19Z | [
"python",
"sql",
"sqlite",
"visualization"
] |
Pivoting SQLite table, setwise like SQL should be | 1,835,391 | <p>I have some data. 224,000 rows of it, in a SQLite database. I want to extract time series information from it to feed a data visualisation tool. Essentially, each row in the db is an event that has (among other things not strictly relevant) a time-date group in seconds since the epoch and a name responsible for it. ... | 3 | 2009-12-02T19:57:35Z | 1,847,034 | <p>I would first do your query</p>
<pre><code>SELECT COUNT(*),
name,
strf("%W:%Y", time, "unixepoch")
FROM events
GROUP BY strf("%W:%Y", time, "unixepoch"), name
ORDER BY time
</code></pre>
<p>and then do post processing with python. </p>
<p>So you don't have to iterate over 224,000 rows but o... | 1 | 2009-12-04T13:44:29Z | [
"python",
"sql",
"sqlite",
"visualization"
] |
Calling a function using ctypes with pointers to structs | 1,835,429 | <p>I am trying to call a C function sitting in a shared object from python, and using ctypes seems to be the best way of accomplishing this. I have to pass derived types to this function, with the following function prototype:</p>
<pre><code>int MyFunc (Config *config, int *argc, char **argv )
</code></pre>
<p>The <c... | 4 | 2009-12-02T20:04:02Z | 1,835,845 | <p>It doesn't look like your rewritten config structure is the same as the original one. If you're passing it back and forth the alignment would be off.</p>
<p>Edit: I see you've fixed part of it. But I'm not sure that c_char_p is the same as char**.</p>
| 1 | 2009-12-02T21:10:30Z | [
"python",
"c",
"ctypes"
] |
Calling a function using ctypes with pointers to structs | 1,835,429 | <p>I am trying to call a C function sitting in a shared object from python, and using ctypes seems to be the best way of accomplishing this. I have to pass derived types to this function, with the following function prototype:</p>
<pre><code>int MyFunc (Config *config, int *argc, char **argv )
</code></pre>
<p>The <c... | 4 | 2009-12-02T20:04:02Z | 1,868,963 | <p>char** corresponds to POINTER(c_char_p), not to c_char_p.</p>
| 2 | 2009-12-08T18:34:34Z | [
"python",
"c",
"ctypes"
] |
Python zlib not decodable when returned by an http response | 1,835,585 | <p>I'm using Amazon S3 to serve static files. When the Content-Type is just 'text/css' and I haven't compressed the file, it is returned ok. If I try to zlib.compress() the contents that will be returned and change Content-Encoding to 'gzip', the browser cannot decode the result. In Chrome, the error is</p>
<pre><cod... | 4 | 2009-12-02T20:30:48Z | 1,835,611 | <p><a href="http://www.faqs.org/rfcs/rfc1952.html" rel="nofollow">gzip</a> is not the same as <a href="http://www.ietf.org/rfc/rfc1950.txt" rel="nofollow">zlib</a>.</p>
| 2 | 2009-12-02T20:34:59Z | [
"python",
"http",
"http-headers",
"amazon-s3",
"zlib"
] |
Python zlib not decodable when returned by an http response | 1,835,585 | <p>I'm using Amazon S3 to serve static files. When the Content-Type is just 'text/css' and I haven't compressed the file, it is returned ok. If I try to zlib.compress() the contents that will be returned and change Content-Encoding to 'gzip', the browser cannot decode the result. In Chrome, the error is</p>
<pre><cod... | 4 | 2009-12-02T20:30:48Z | 1,836,406 | <p>It is decodable. The problem is that the sender is lying to the receiver -- not a good way of ensuring harmonious communication. Try calling it "zlib" instead of "gzip".</p>
| 0 | 2009-12-02T22:43:59Z | [
"python",
"http",
"http-headers",
"amazon-s3",
"zlib"
] |
Python zlib not decodable when returned by an http response | 1,835,585 | <p>I'm using Amazon S3 to serve static files. When the Content-Type is just 'text/css' and I haven't compressed the file, it is returned ok. If I try to zlib.compress() the contents that will be returned and change Content-Encoding to 'gzip', the browser cannot decode the result. In Chrome, the error is</p>
<pre><cod... | 4 | 2009-12-02T20:30:48Z | 2,714,461 | <p>I have this same problem.</p>
<p>If you send the header:</p>
<pre><code>Content-Encoding: gzip
</code></pre>
<p>Safari/Chrome show that error.</p>
<p>But if you instead send:</p>
<pre><code>Content-Encoding: deflate
</code></pre>
<p>Safari/Chrome decodes the input fine.</p>
| 4 | 2010-04-26T14:58:35Z | [
"python",
"http",
"http-headers",
"amazon-s3",
"zlib"
] |
Python zlib not decodable when returned by an http response | 1,835,585 | <p>I'm using Amazon S3 to serve static files. When the Content-Type is just 'text/css' and I haven't compressed the file, it is returned ok. If I try to zlib.compress() the contents that will be returned and change Content-Encoding to 'gzip', the browser cannot decode the result. In Chrome, the error is</p>
<pre><cod... | 4 | 2009-12-02T20:30:48Z | 14,342,944 | <p>Instead of using the module <code>zlib</code>, (<code>originalString = inputFile.read()</code> and then <code>compressedString = zlib.compress(originalString)</code>) I am now using the module <code>gzip</code>:</p>
<pre><code>stream = cStringIO.StringIO()
compressor = gzip.GzipFile(fileobj=stream, mode='w')
while ... | 0 | 2013-01-15T17:07:23Z | [
"python",
"http",
"http-headers",
"amazon-s3",
"zlib"
] |
mysqldb build error | 1,835,658 | <p>i remember installing Python + Django + MySQL + MySQLdb on my 32-bit Mac with Leopard 10.5.7.
I tried the same procedure with Mac Snow Leopard. But have unfortunately ran into a lot of errors...
i dont know but something weird is happening. Please look at the error log:</p>
<pre><code>Amit-Vermas-MacBook:mysql-pyth... | 1 | 2009-12-02T20:43:03Z | 1,837,093 | <p>The following blog post helped me compile MySQLdb 1.2.2 on the Mac:
<a href="http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/" rel="nofollow">http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/</a></p>
<p>However, later on I tried MySQLDB 1.2.3c1 and didn... | 0 | 2009-12-03T01:28:54Z | [
"python",
"django",
"osx",
"osx-snow-leopard"
] |
mysqldb build error | 1,835,658 | <p>i remember installing Python + Django + MySQL + MySQLdb on my 32-bit Mac with Leopard 10.5.7.
I tried the same procedure with Mac Snow Leopard. But have unfortunately ran into a lot of errors...
i dont know but something weird is happening. Please look at the error log:</p>
<pre><code>Amit-Vermas-MacBook:mysql-pyth... | 1 | 2009-12-02T20:43:03Z | 1,837,335 | <p>This is my personal makefile rule for that</p>
<pre><code>MYSQLDB_VERSION=1.2.3c1
MYSQLDB_TARGET=$(BUILD_FLAGS_DIR)/mysqldb
MYSQLDB_PACKAGE=MySQL-python-$(MYSQLDB_VERSION).tar.gz
MYSQLDB_PACKAGE_URL=http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/$(MYSQLDB_VERSION)/$(MYSQLDB_PACKAGE)
.PHONY... | 1 | 2009-12-03T02:51:51Z | [
"python",
"django",
"osx",
"osx-snow-leopard"
] |
mysqldb build error | 1,835,658 | <p>i remember installing Python + Django + MySQL + MySQLdb on my 32-bit Mac with Leopard 10.5.7.
I tried the same procedure with Mac Snow Leopard. But have unfortunately ran into a lot of errors...
i dont know but something weird is happening. Please look at the error log:</p>
<pre><code>Amit-Vermas-MacBook:mysql-pyth... | 1 | 2009-12-02T20:43:03Z | 1,837,530 | <p>The most likely explanation is that you are trying to link a 64-bit version of the MySQL libraries with a 32-bit-only version of Python (currently, all of the python.org installers for OS X are 32-bit only). (You can verify that by using the <code>file</code> command on the library files in <code>/usr/local/mysql/<... | 1 | 2009-12-03T03:57:06Z | [
"python",
"django",
"osx",
"osx-snow-leopard"
] |
mysqldb build error | 1,835,658 | <p>i remember installing Python + Django + MySQL + MySQLdb on my 32-bit Mac with Leopard 10.5.7.
I tried the same procedure with Mac Snow Leopard. But have unfortunately ran into a lot of errors...
i dont know but something weird is happening. Please look at the error log:</p>
<pre><code>Amit-Vermas-MacBook:mysql-pyth... | 1 | 2009-12-02T20:43:03Z | 1,838,538 | <p>It looks like you need to reinstall/update XCode (build tools)</p>
| 0 | 2009-12-03T08:42:25Z | [
"python",
"django",
"osx",
"osx-snow-leopard"
] |
What Python-only HTTP/1.1 web servers are available? | 1,835,668 | <p>There is CherryPy. Are there any others? </p>
| 2 | 2009-12-02T20:43:41Z | 1,835,705 | <p><a href="http://code.google.com/p/magnum-py/" rel="nofollow">magnum-py</a></p>
<p>or...</p>
<p><a href="http://fragments.turtlemeat.com/pythonwebserver.php" rel="nofollow">Make your own!</a></p>
| 2 | 2009-12-02T20:49:13Z | [
"python",
"http"
] |
What Python-only HTTP/1.1 web servers are available? | 1,835,668 | <p>There is CherryPy. Are there any others? </p>
| 2 | 2009-12-02T20:43:41Z | 1,835,720 | <p>Twisted includes a <a href="http://twistedmatrix.com/trac/wiki/TwistedWeb" rel="nofollow">web server</a>.</p>
| 2 | 2009-12-02T20:51:13Z | [
"python",
"http"
] |
What Python-only HTTP/1.1 web servers are available? | 1,835,668 | <p>There is CherryPy. Are there any others? </p>
| 2 | 2009-12-02T20:43:41Z | 1,837,070 | <p>also:</p>
<p>web.py (webpy.org)</p>
<p>paste (pythonpaste.org)</p>
| 1 | 2009-12-03T01:22:55Z | [
"python",
"http"
] |
buildout deployment strategies | 1,835,688 | <p>So I am <strong>applying</strong> zc.buildout to an existing django project. I am wondering about deploying it now. How do I achieve the sandbox effect on a production server?</p>
| 3 | 2009-12-02T20:46:02Z | 1,842,655 | <p>Not sure what you mean with "sandbox effect". If you mean "isolated build": yeah, that's what buildout does. Although it can use a per-user cache directory if you told it to in your<code>~/.buildout/default.cfg</code>. If you want really strict sandboxing on your production server you'll have to switch that off.</p... | 4 | 2009-12-03T20:23:55Z | [
"python",
"deployment",
"buildout"
] |
buildout deployment strategies | 1,835,688 | <p>So I am <strong>applying</strong> zc.buildout to an existing django project. I am wondering about deploying it now. How do I achieve the sandbox effect on a production server?</p>
| 3 | 2009-12-02T20:46:02Z | 12,582,594 | <p>Use <em>include site packages</em> option:</p>
<pre><code> [buildout]
include-site-packages = false
</code></pre>
<p>(I know I'm digging an old question, but it pops up in search results.)</p>
| 0 | 2012-09-25T12:03:52Z | [
"python",
"deployment",
"buildout"
] |
Codec Errors in Python | 1,835,696 | <p>Does anyone know the name of a codec that can translate any random assortment of bytes into a string? I have been getting the following error after encoding, encrypting, and decoding a string in <strong>tkinter.Text.</strong></p>
<pre><code>UnicodeDecodeError: 'utf8' codec can't decode
byte 0x99 in position 151: un... | 0 | 2009-12-02T20:47:54Z | 1,835,798 | <p>Strings are by definition a sequence of bytes that only have meaning when interpreted with the knowledge of the encoding. That's one reason why the equivalent of Python 2's string type in Python 3 is the bytes type. As long as you know the encoding of the strings you're working with, I'm not sure you specifically ... | 1 | 2009-12-02T21:04:27Z | [
"python",
"character-encoding",
"byte"
] |
Codec Errors in Python | 1,835,696 | <p>Does anyone know the name of a codec that can translate any random assortment of bytes into a string? I have been getting the following error after encoding, encrypting, and decoding a string in <strong>tkinter.Text.</strong></p>
<pre><code>UnicodeDecodeError: 'utf8' codec can't decode
byte 0x99 in position 151: un... | 0 | 2009-12-02T20:47:54Z | 1,836,667 | <p>Python's decode has error settings. The default is strict which throws an exception.</p>
<p>Wherever you are doing the decoding, you can specify 'ignore' or 'replace' as a setting, and this will take care of your problems.</p>
<p>Please see the <a href="http://docs.python.org/library/codecs.html" rel="nofollow">co... | 1 | 2009-12-02T23:40:08Z | [
"python",
"character-encoding",
"byte"
] |
Codec Errors in Python | 1,835,696 | <p>Does anyone know the name of a codec that can translate any random assortment of bytes into a string? I have been getting the following error after encoding, encrypting, and decoding a string in <strong>tkinter.Text.</strong></p>
<pre><code>UnicodeDecodeError: 'utf8' codec can't decode
byte 0x99 in position 151: un... | 0 | 2009-12-02T20:47:54Z | 1,853,365 | <p>In Python HOWTOs from the Python v3.1.1 documentation, there is a helpful section regarding Unicode HOWTO. The table of content contains an entry to <a href="http://docs.python.org/3.1/howto/unicode.html#python-s-unicode-support" rel="nofollow">Pythonâs Unicode Support</a> that explains string & byte.</p>
<p>... | 0 | 2009-12-05T20:31:44Z | [
"python",
"character-encoding",
"byte"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,835,816 | <p>Your second example is broken - the code will never throw a TypeError exception since you can iterate through both strings and lists. Iterating through an empty string or list is also valid - it will execute the body of the loop zero times.</p>
| 3 | 2009-12-02T21:07:08Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,835,835 | <p>Generally, the impression I've gotten is that exceptions should be reserved for exceptional circumstances. If the <code>result</code> is expected never to be empty (but might be, if, for instance, a disk crashed, etc), the second approach makes sense. If, on the other hand, an empty <code>result</code> is perfectl... | 3 | 2009-12-02T21:09:24Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,835,844 | <p>You often hear that Python encourages EAFP style ("it's easier to ask for forgiveness than permission") over LBYL style ("look before you leap"). To me, it's a matter of efficiency and readability.</p>
<p>In your example (say that instead of returning a list or an empty string, the function were to return a list or... | 108 | 2009-12-02T21:10:28Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,835,853 | <p>Your function should not return mixed types (i.e. list or empty string). It should return a list of values or just an empty list. Then you wouldn't need to test for anything, i.e. your code collapses to:</p>
<pre><code>for r in function():
# process items
</code></pre>
| 10 | 2009-12-02T21:11:16Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,835,864 | <p>As a general rule of thumb, you should <em>never</em> use try/catch or any exception handling stuff to control flow. Even though behind the scenes iteration is controlled via the raising of <code>StopIteration</code> exceptions, you still should prefer your first code snippet to the second.</p>
| -5 | 2009-12-02T21:12:45Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,836,111 | <p>Please ignore my solution if the code I provide is not obvious at first glance and you have to read the explanation after the code sample.</p>
<p>Can I assume that the "no value returned" means the return value is None? If yes, or if the "no value" is False boolean-wise, you can do the following, since your code es... | 8 | 2009-12-02T21:57:37Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,836,371 | <blockquote>
<p>Which of the following would be more preferable and why?</p>
</blockquote>
<p>Look Before You Leap is preferable in this case. With the exception approach, a TypeError could occur anywhere in your loop body and it'd get caught and thrown away, which is not what you want and will make debugging tricky... | 3 | 2009-12-02T22:39:14Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,837,284 | <p>As far as the performance is concerned, using try block for code that normally
doesnât raise exceptions is faster than using if statement everytime. So, the decision depends on the probability of excetional cases.</p>
| 0 | 2009-12-03T02:33:22Z | [
"python"
] |
Using try vs if in python | 1,835,756 | <p>Is there a rationale to decide which one of <code>try</code> or <code>if</code> constructs to use, when testing variable to have a value? </p>
<p>For example, there is a function that returns either a list or doesn't return a value. I want to check result before processing it. Which of the following would be more ... | 67 | 2009-12-02T20:58:37Z | 1,841,853 | <p><a href="http://stackoverflow.com/questions/1835756/using-try-vs-if-in-python/1836371#1836371">bobince</a> wisely points out that wrapping the second case can also catch TypeErrors in the loop, which is not what you want. If you do really want to use a try though, you can test if it's iterable before the loop</p>
... | 2 | 2009-12-03T18:21:27Z | [
"python"
] |
What is the range of values a float can have in Python? | 1,835,787 | <p>What are its smallest and biggest values in python?</p>
| 21 | 2009-12-02T21:02:28Z | 1,835,805 | <p>See this <a href="http://groups.google.com/group/comp.lang.python/msg/fa7a761411ced62b?pli=1">post</a>.</p>
<p>Relevant parts of the post:</p>
<pre>
In [2]: import kinds
In [3]: kinds.default_float_kind.M
kinds.default_float_kind.MAX kinds.default_float_kind.MIN
kinds.default_float_kind.MAX_10_EXP kind... | 11 | 2009-12-02T21:05:52Z | [
"python",
"floating-point"
] |
What is the range of values a float can have in Python? | 1,835,787 | <p>What are its smallest and biggest values in python?</p>
| 21 | 2009-12-02T21:02:28Z | 1,835,813 | <p>Python uses double-precision floats, which can hold values from about 10 to the -308 to 10 to the 308 power.</p>
<p><a href="http://en.wikipedia.org/wiki/Double%5Fprecision%5Ffloating-point%5Fformat" rel="nofollow">http://en.wikipedia.org/wiki/Double%5Fprecision%5Ffloating-point%5Fformat</a></p>
<p>Try this experi... | 4 | 2009-12-02T21:06:43Z | [
"python",
"floating-point"
] |
What is the range of values a float can have in Python? | 1,835,787 | <p>What are its smallest and biggest values in python?</p>
| 21 | 2009-12-02T21:02:28Z | 1,836,030 | <p>As a kind of theoretical complement to the previous answers, I would like to mention that the "magic" value ±308 comes directly from the binary representation of floats. <a href="http://en.wikipedia.org/wiki/Double_precision_floating-point_format" rel="nofollow">Double precision floats</a> are of the form ±c*2**q... | 6 | 2009-12-02T21:44:28Z | [
"python",
"floating-point"
] |
What is the range of values a float can have in Python? | 1,835,787 | <p>What are its smallest and biggest values in python?</p>
| 21 | 2009-12-02T21:02:28Z | 1,836,341 | <p>Just playing around; here is an algorithmic method to find the minimum and maximum positive float, hopefully in any python implementation where <code>float("+inf")</code> is acceptable:</p>
<pre><code>def find_float_limits():
"""Return a tuple of min, max positive numbers
representable by the platform's flo... | 2 | 2009-12-02T22:33:03Z | [
"python",
"floating-point"
] |
What is the range of values a float can have in Python? | 1,835,787 | <p>What are its smallest and biggest values in python?</p>
| 21 | 2009-12-02T21:02:28Z | 1,839,009 | <pre><code>>>> import sys
>>> sys.float_info
sys.floatinfo(max=1.7976931348623157e+308, max_exp=1024, max_10_exp=308,
min=2.2250738585072014e-308, min_exp=-1021, min_10_exp=-307, dig=15, mant_dig=53,
epsilon=2.2204460492503131e-16, radix=2, rounds=1)
</code></pre>
<p>The smallest is <code>sys.float_i... | 45 | 2009-12-03T10:22:39Z | [
"python",
"floating-point"
] |
Problem with variable scoping in Python | 1,835,809 | <p>This problem is partly due to my lack of completely understanding scoping in python, so I'll need to review that. Either way, here is a seriously trivial piece of code that keeps crashing on my Django test app.</p>
<p>Here's a snippet:</p>
<pre><code>@login_required
def someview(request):
try:
usergroup = reque... | 0 | 2009-12-02T21:06:34Z | 1,835,848 | <pre><code>HttpResponseRedirect('/accounts/login')
</code></pre>
<p>You're creating it but not returning it. Flow continues to the next line, which references <code>usergroup</code> despite it never having been assigned due to the exception.</p>
<p>The <code>except</code> is also troublesome. In general you should ne... | 10 | 2009-12-02T21:10:47Z | [
"python",
"django"
] |
Problem with variable scoping in Python | 1,835,809 | <p>This problem is partly due to my lack of completely understanding scoping in python, so I'll need to review that. Either way, here is a seriously trivial piece of code that keeps crashing on my Django test app.</p>
<p>Here's a snippet:</p>
<pre><code>@login_required
def someview(request):
try:
usergroup = reque... | 0 | 2009-12-02T21:06:34Z | 1,835,871 | <p>Try moving you if 'client' part inside you try block. Either that or define <code>usergroup = None</code> right above the try.</p>
| 0 | 2009-12-02T21:13:42Z | [
"python",
"django"
] |
Problem with variable scoping in Python | 1,835,809 | <p>This problem is partly due to my lack of completely understanding scoping in python, so I'll need to review that. Either way, here is a seriously trivial piece of code that keeps crashing on my Django test app.</p>
<p>Here's a snippet:</p>
<pre><code>@login_required
def someview(request):
try:
usergroup = reque... | 0 | 2009-12-02T21:06:34Z | 1,836,163 | <p>In cases where you have a <code>tryâ¦except</code> suite and you want code to run iff <em>no</em> exceptions have occurred, it's a good habit to write the code as follows:</p>
<pre><code>try:
# code that could fail
except Exception1:
# handle exception1
except Exception2:
# handle exception2
else: # th... | 0 | 2009-12-02T22:04:27Z | [
"python",
"django"
] |
Python long multiplication | 1,835,857 | <p>I'm in need of an algorithm faster than the current normal Python long multiplication.</p>
<p>I tried to find a decent Karatsuba implementation, but I can't.</p>
<pre><code>def main():
a=long(raw_input())
if(a<0):
a=a*-1
a=((a*(a+1)/2)-1)
print(-a)
else:
a=(a*(a+1))/2... | 4 | 2009-12-02T21:11:44Z | 1,835,874 | <p>I suggest you get the <a href="http://www.sagemath.org/" rel="nofollow">Sage math tool</a>, which has just about every Python math tool ever made rolled into one package. See if there is a nice fast arbitrary precision math tool in Sage that meets your needs.</p>
| 3 | 2009-12-02T21:14:42Z | [
"python",
"biginteger",
"multiplication"
] |
Python long multiplication | 1,835,857 | <p>I'm in need of an algorithm faster than the current normal Python long multiplication.</p>
<p>I tried to find a decent Karatsuba implementation, but I can't.</p>
<pre><code>def main():
a=long(raw_input())
if(a<0):
a=a*-1
a=((a*(a+1)/2)-1)
print(-a)
else:
a=(a*(a+1))/2... | 4 | 2009-12-02T21:11:44Z | 1,836,137 | <p>You could have a look at the implementation of the <a href="http://home.comcast.net/~casevh/" rel="nofollow">DecInt module</a> (pure Python version is available (Toom-Cook) although the fastest it will probably be when using <a href="http://code.google.com/p/gmpy/" rel="nofollow">gmpy</a>).</p>
| 2 | 2009-12-02T22:00:32Z | [
"python",
"biginteger",
"multiplication"
] |
Python long multiplication | 1,835,857 | <p>I'm in need of an algorithm faster than the current normal Python long multiplication.</p>
<p>I tried to find a decent Karatsuba implementation, but I can't.</p>
<pre><code>def main():
a=long(raw_input())
if(a<0):
a=a*-1
a=((a*(a+1)/2)-1)
print(-a)
else:
a=(a*(a+1))/2... | 4 | 2009-12-02T21:11:44Z | 1,836,200 | <p>15.9 ms on my slow notebook. It is the print that is slowing you down. Converting to binary numbers to decimal is quite slow, which is a required step of printing it out. If you need to output the number you should try the DecInt ChristopheD mentioned already.</p>
<p>DecInt will be slower doing the multiply but mak... | 8 | 2009-12-02T22:10:14Z | [
"python",
"biginteger",
"multiplication"
] |
Python long multiplication | 1,835,857 | <p>I'm in need of an algorithm faster than the current normal Python long multiplication.</p>
<p>I tried to find a decent Karatsuba implementation, but I can't.</p>
<pre><code>def main():
a=long(raw_input())
if(a<0):
a=a*-1
a=((a*(a+1)/2)-1)
print(-a)
else:
a=(a*(a+1))/2... | 4 | 2009-12-02T21:11:44Z | 1,845,764 | <p>I'm the author of the DecInt (Decimal Integer) library so I'll make a few comments.</p>
<p>The DecInt library was specifically designed to work with very large integers that needed to be converted to decimal format. The problem with converting to decimal format is that most arbitrary-precision libraries store value... | 21 | 2009-12-04T09:06:59Z | [
"python",
"biginteger",
"multiplication"
] |
Need a zip of Python 2.6 for windows | 1,835,930 | <p>Not the source codes, thats the only thing i seem to find. I can't install py2.6 because it would overtake 2.5 and cause mayor mess in my pc.</p>
| 1 | 2009-12-02T21:27:07Z | 1,835,980 | <p>How would it overtake 2.5? You can install both in parallel, just make sure that you unselect the option to "Register Extensions" during the install of 2.6.</p>
<p>I have several Python installations on my PC in parallel, one of them my "standard" one that I expect to run when I doubleclick on a <code>.py</code> fi... | 8 | 2009-12-02T21:36:25Z | [
"python",
"zip"
] |
Need a zip of Python 2.6 for windows | 1,835,930 | <p>Not the source codes, thats the only thing i seem to find. I can't install py2.6 because it would overtake 2.5 and cause mayor mess in my pc.</p>
| 1 | 2009-12-02T21:27:07Z | 1,836,803 | <p>I have Pythons 2.3, 2.4, 2.5, 2.6, and 3.1 all installed on my PC. Download the .msi from python.org, and install it.</p>
| 2 | 2009-12-03T00:07:31Z | [
"python",
"zip"
] |
Python universal database interface? | 1,836,061 | <p>Does there exist, or is there an intention to create, a universal database frontend for Python like Perl's DBI? I am aware of Python's DB-API, but all the separate packages are leaving me somewhat aggravated.</p>
| 1 | 2009-12-02T21:49:47Z | 1,836,125 | <p>Well...DBAPI <em>is</em> that frontend:</p>
<blockquote>
<p>This API has been defined to encourage similarity between the
Python modules that are used to access databases. By doing this,
we hope to achieve a consistency leading to more easily understood
modules, code that is generally more portable across ... | 1 | 2009-12-02T21:58:51Z | [
"python",
"database"
] |
Python universal database interface? | 1,836,061 | <p>Does there exist, or is there an intention to create, a universal database frontend for Python like Perl's DBI? I am aware of Python's DB-API, but all the separate packages are leaving me somewhat aggravated.</p>
| 1 | 2009-12-02T21:49:47Z | 1,836,266 | <p>AFAIK there is no one Python module that implements the DB-API to multiple databases and that's pretty much by design: why bring in unneeded functionality and possibly require the underlying database libraries to be installed if you are not going to use them? You can argue with that design decision but that's the w... | 3 | 2009-12-02T22:19:27Z | [
"python",
"database"
] |
A Friendship relationship question | 1,836,176 | <p>I am having difficulties with listing this type of data. Scenario is
as follows:</p>
<ol>
<li>user1 add's a friend called user2</li>
<li>user2 confirms that user1 is his friend</li>
</ol>
<p>what should happen is user2 and user1 see's each others name in their
friends list. What's happening now is I am able to add... | 0 | 2009-12-02T22:06:28Z | 1,836,531 | <p>It's not obvious that your friendship model is associative. Is my friends list the list of all friendships in which I am the <code>from_user</code>? Or is it all friendships in which I am either the <code>from_user</code> or the <code>to_user</code>?</p>
<p>If it's the former, then every friend relationship is re... | 1 | 2009-12-02T23:08:27Z | [
"python",
"django",
"models"
] |
A Friendship relationship question | 1,836,176 | <p>I am having difficulties with listing this type of data. Scenario is
as follows:</p>
<ol>
<li>user1 add's a friend called user2</li>
<li>user2 confirms that user1 is his friend</li>
</ol>
<p>what should happen is user2 and user1 see's each others name in their
friends list. What's happening now is I am able to add... | 0 | 2009-12-02T22:06:28Z | 1,838,268 | <p>Based upon this page: <a href="http://docs.djangoproject.com/en/dev/topics/db/queries/" rel="nofollow">http://docs.djangoproject.com/en/dev/topics/db/queries/</a></p>
<p>The following code:</p>
<pre><code>friends = Friendship.objects.filter(
Q(to_friend=user) | Q(confirmed=3)
)
</code></pre>
<p>equates to... | 0 | 2009-12-03T07:32:48Z | [
"python",
"django",
"models"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,388 | <p>You should be able to find a good algorithm in this book: <a href="http://www.algorist.com/" rel="nofollow">The Algorithm Design Manual</a> by Steven Skiena.</p>
<p>The book has a whole bunch of algorithms for various purposes. You want a graph clustering algorithm, I think. I don't have my copy of the book handy... | 0 | 2009-12-02T22:41:39Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,424 | <p>I recommend the book <a href="http://oreilly.com/catalog/9780596529321" rel="nofollow">Programming Collective Intelligence</a> from Toby Segaran. Chapter 3 describes different clustering methods like <a href="http://en.wikipedia.org/wiki/Hierarchical%5Fclustering" rel="nofollow">Hierarchical Clustering</a> and <a hr... | 5 | 2009-12-02T22:47:55Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,432 | <p>There are two common metrics that can be used to find similarities between users:</p>
<ol>
<li><p><strong>Euclidean Distance</strong>, that is exactly what you are thinking: imagine a n-dimensional graph that has for each axis a song that is reviewed by two involved users (<em>u1</em> and *u2) and the value on its ... | 10 | 2009-12-02T22:49:31Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,439 | <p>If you want the most accurate results, then no, you'd have to iterate over everything.</p>
<p>If your database is large enough, you could just take a statistical sampling, say taking between 1,000 -10,000 users and matching against that.</p>
<p>You would also be better off to add some more tables to the database, ... | 3 | 2009-12-02T22:51:12Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,464 | <p>Ilya Grigorik did a series on recommendation algorithms, though he was focusing on Ruby. It appears to be under the <strong>machine learning</strong> section in his <a href="http://www.igvita.com/archives/" rel="nofollow">archives</a>, but there isn't a direct section link.</p>
| 1 | 2009-12-02T22:57:04Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,568 | <p>I think a lot of people on here are missing the simplicity of the question. He didn't say anything about creating a rating prediction system. He just wants to compute the similarity between each user's song rating behavior and each other user's song rating behavior. The Pearson correlation coefficient gives exactly ... | 1 | 2009-12-02T23:14:54Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Similarity Between Users Based On Votes | 1,836,352 | <p>lets say i have a set of users, a set of songs, and a set of votes on each song:</p>
<pre><code>=========== =========== =======
User Song Vote
=========== =========== =======
user1 song1 [score]
user1 song2 [score]
user1 song3 [score]
user2 song1 [score]... | 6 | 2009-12-02T22:34:53Z | 1,836,969 | <p>If you want to do it in a approximate way without visiting all the records, you can use the Jaccard Coefficient. Probably needs some adaptation if you want to consider the scores. But I guess that's the best solutions if your system is too big and you don't have the time to check all the records. </p>
| 1 | 2009-12-03T00:55:20Z | [
"python",
"mysql",
"database",
"information-retrieval",
"similarity"
] |
Subprocess Popen and PIPE in Python | 1,836,588 | <p>The following code prints an empty line as an output which is false.
The problem is not in the permissions, since I tested the command with 777 permissions for the pdf -file. <strong>How can you fix the command to give a right output?</strong></p>
<pre><code>import subprocess
from subprocess import PIPE, Popen
outp... | 4 | 2009-12-02T23:19:53Z | 1,836,672 | <p>pdftotext creates a file by default. To send the result to standard output, use:</p>
<pre><code>pdftotext file.pdf -
</code></pre>
<p>or in Python:</p>
<pre><code>output = Popen(['pdftotext', '/home/aal/Desktop/lkn_pdf/appa.pdf', '-'], stdout=PIPE).communicate()[0]
</code></pre>
| 6 | 2009-12-02T23:42:00Z | [
"python",
"subprocess",
"pipe",
"popen"
] |
Documenting module/class/function bodies in python sphinx docs | 1,836,633 | <p>Is there a way with Sphinx documentation to output a function or class body (the code itself) with the autodoc feature? I'm using autodoc to much success. In addition to the docstrings getting pulled in to the documentation I want like a link to click for each function where it will show you the source... is that po... | 1 | 2009-12-02T23:30:58Z | 1,837,637 | <p>I don't believe so. Autodoc is only for pulling the documentation out of the source code.</p>
| 1 | 2009-12-03T04:27:33Z | [
"python",
"documentation",
"python-sphinx"
] |
Documenting module/class/function bodies in python sphinx docs | 1,836,633 | <p>Is there a way with Sphinx documentation to output a function or class body (the code itself) with the autodoc feature? I'm using autodoc to much success. In addition to the docstrings getting pulled in to the documentation I want like a link to click for each function where it will show you the source... is that po... | 1 | 2009-12-02T23:30:58Z | 2,735,235 | <p>If this still matters: The <a href="http://sphinx.pocoo.org/latest/ext/viewcode.html" rel="nofollow">viewcode extension</a> can do this, but needs the development version (1.0) of Sphinx</p>
| 2 | 2010-04-29T06:39:57Z | [
"python",
"documentation",
"python-sphinx"
] |
python help display regular expression result | 1,836,637 | <p>I am doing simple regular expressions in python</p>
<p>I am trying the re.split but things like ['\r\n', '\r\n'] are coming instead of the answer.
Can someone please tell me how to display the actual text please?</p>
<p>I tried this statement:</p>
<pre><code>t_html = re.split("<[a-zA-Z0-9\s\w\W]*>[a-zA-Z0-9... | 0 | 2009-12-02T23:32:39Z | 1,836,664 | <p>re.split by its very nature splits on the pattern but does not preserve it. If you want to return the string matched by the pattern you can put parentheses around the pattern: re.split((R),string) where R is your expression. If you want to say find all non overlapping matches use re.findall which will return a list.... | 0 | 2009-12-02T23:39:56Z | [
"python",
"regex"
] |
python help display regular expression result | 1,836,637 | <p>I am doing simple regular expressions in python</p>
<p>I am trying the re.split but things like ['\r\n', '\r\n'] are coming instead of the answer.
Can someone please tell me how to display the actual text please?</p>
<p>I tried this statement:</p>
<pre><code>t_html = re.split("<[a-zA-Z0-9\s\w\W]*>[a-zA-Z0-9... | 0 | 2009-12-02T23:32:39Z | 1,837,430 | <p>If you want to use a regex to parse html, see <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">here</a>.</p>
| 0 | 2009-12-03T03:23:28Z | [
"python",
"regex"
] |
Can I remove leading zeros in a url in django? | 1,836,721 | <p>Am redirecting urls from a legacy site, which gets me to a url like this:</p>
<pre>http://example.com/blog/01/detail</pre>
<p>I would like to automatically <em>remove the leading zeros</em> from these urls (seems it doesn't matter how many zeros are in there <code>001</code> <code>0001</code> <code>000001</code> w... | 1 | 2009-12-02T23:51:56Z | 1,836,743 | <p>Perhaps</p>
<pre><code>url(u'^blog/0*(?P<object_id>\d+)/detail$',
list_detail.object_detail,
{ 'queryset' : Blog.objects.all(), },
name='blog_detail',)
</code></pre>
| 1 | 2009-12-02T23:55:25Z | [
"python",
"django",
".htaccess"
] |
Can I remove leading zeros in a url in django? | 1,836,721 | <p>Am redirecting urls from a legacy site, which gets me to a url like this:</p>
<pre>http://example.com/blog/01/detail</pre>
<p>I would like to automatically <em>remove the leading zeros</em> from these urls (seems it doesn't matter how many zeros are in there <code>001</code> <code>0001</code> <code>000001</code> w... | 1 | 2009-12-02T23:51:56Z | 1,836,754 | <p>You can fix it by eiditing either the urls.py regex or the .htaccess regex:</p>
<h3>In Django</h3>
<pre><code>'^blog/0*(?P<object_id>\d+)/detail$'
</code></pre>
<h3>In .htaccess</h3>
<pre><code>RewriteRule ^blog-0*([0-9]+) http://example.com/blog/$1 [R=301]
</code></pre>
| 3 | 2009-12-02T23:56:38Z | [
"python",
"django",
".htaccess"
] |
how to update a Django page without a page reload? | 1,836,861 | <p>My Django app displays data from a database. This data changes without user intervention, i.e. behind the scenes. Whenever it changes, I would like the webpage to update the changed sections without a full page reload.</p>
<p>Obviously AJAX springs to mind. When the page is loaded initially (or manually, fully re-l... | 13 | 2009-12-03T00:20:55Z | 1,837,016 | <p>You have two choices</p>
<ol>
<li>Have the browser poll using setTimeout()</li>
<li>Look into Comet -- this is a technique for pushing data from the server to the browser.</li>
</ol>
<p>Here's an article on <a href="http://www.rkblog.rk.edu.pl/w/p/django-and-comet/">Comet in Django</a></p>
| 7 | 2009-12-03T01:06:55Z | [
"javascript",
"python",
"ajax",
"django"
] |
how to update a Django page without a page reload? | 1,836,861 | <p>My Django app displays data from a database. This data changes without user intervention, i.e. behind the scenes. Whenever it changes, I would like the webpage to update the changed sections without a full page reload.</p>
<p>Obviously AJAX springs to mind. When the page is loaded initially (or manually, fully re-l... | 13 | 2009-12-03T00:20:55Z | 1,837,023 | <p>two approaches:</p>
<ol>
<li><p>just update the database and wait until the next AJAX query. that means it should do the query periodically, you'll have to balance between immediacy and server load. it helps a little if you can do a cheap query to just verify if there has been an update. maybe make that check re... | 6 | 2009-12-03T01:08:28Z | [
"javascript",
"python",
"ajax",
"django"
] |
Django-based skill implementation | 1,836,881 | <p>I'm working on a RPG using django and am considering different options for implementing part of the skill system.</p>
<p>Say I have a base skill class ie, something like:</p>
<pre><code>class Skill (models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
blah blah blah
</cod... | 3 | 2009-12-03T00:28:29Z | 1,837,045 | <p>I'm kind of tired (late here in Sweden), so I am sorry if i misunderstood, but the first thing that popped into my head was <a href="http://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany" rel="nofollow">extra fields on many-to-many relationships</a>.</p>
| 1 | 2009-12-03T01:15:54Z | [
"python",
"django"
] |
Django-based skill implementation | 1,836,881 | <p>I'm working on a RPG using django and am considering different options for implementing part of the skill system.</p>
<p>Say I have a base skill class ie, something like:</p>
<pre><code>class Skill (models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
blah blah blah
</cod... | 3 | 2009-12-03T00:28:29Z | 1,837,526 | <p>I would set up some inheritance.</p>
<pre><code>class BaseSkill(models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
type = models.CharField()
....
class FireSkill(BaseSkill):
burn_time = models.PositiveIntegerField()
def save():
self.type = 'fire_skill'
... | 1 | 2009-12-03T03:56:02Z | [
"python",
"django"
] |
Django-based skill implementation | 1,836,881 | <p>I'm working on a RPG using django and am considering different options for implementing part of the skill system.</p>
<p>Say I have a base skill class ie, something like:</p>
<pre><code>class Skill (models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
blah blah blah
</cod... | 3 | 2009-12-03T00:28:29Z | 1,837,527 | <p>When I've seen this, there have been two classes: one for the Skill as an abstract instance (e.g. a skill in speaking Swedish, a skill in Excel development) and then the actual skills possessed by a person with a foreign key to the Skill.</p>
| 1 | 2009-12-03T03:56:27Z | [
"python",
"django"
] |
Django-based skill implementation | 1,836,881 | <p>I'm working on a RPG using django and am considering different options for implementing part of the skill system.</p>
<p>Say I have a base skill class ie, something like:</p>
<pre><code>class Skill (models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
blah blah blah
</cod... | 3 | 2009-12-03T00:28:29Z | 1,837,838 | <p>Perhaps you might consider separating a skill and it's associated effect. More that likely, skills will end up having one or more effect associated with them, and that effect could potentially be used by multiple skills.</p>
<p>For example, an effect could be "Does N frost damage to current target". That effect c... | 5 | 2009-12-03T05:28:20Z | [
"python",
"django"
] |
Django-based skill implementation | 1,836,881 | <p>I'm working on a RPG using django and am considering different options for implementing part of the skill system.</p>
<p>Say I have a base skill class ie, something like:</p>
<pre><code>class Skill (models.Model):
name = models.CharField()
cost = models.PositiveIntegerField()
blah blah blah
</cod... | 3 | 2009-12-03T00:28:29Z | 1,838,446 | <p>You could also use single table and save inner model based off object in a pickled field.</p>
| 0 | 2009-12-03T08:22:29Z | [
"python",
"django"
] |
Passing numpy.arange() an argument | 1,836,966 | <p>I'm trying to pass the values that I want numpy.arange to use.</p>
<p>The code is: </p>
<pre><code>for x in numpy.arange(argument)
</code></pre>
<p>where argument is:</p>
<p>argument = (.1,6.3,.1) (tuple)</p>
<p>TypeError: arange: scaler arguements expected instead of a tuple</p>
<p>arguement = [.1,6.3,.1] (li... | 0 | 2009-12-03T00:54:59Z | 1,837,006 | <p><code>arange</code> is like python's <code>range</code> function.</p>
<p>Perhaps you were looking for <code>numpy.array</code>?</p>
<p>Or maybe you really did want the range to be from 0.1 to 6.3 in steps of 0.1. In that case, use Python's argument unpacking syntax:</p>
<pre><code>arguments = (.1, 6.3, .1)
numpy.... | 2 | 2009-12-03T01:03:59Z | [
"python",
"numpy"
] |
Does pytables support NULL? | 1,837,181 | <p>I have table looks like this</p>
<pre><code>------------------
GeneId | ProteinId
1 | 157
2 | -
3 | 587
4 | 897
5 | -
6 | 120
</code></pre>
<p>In realational database, I can treat ProteinId column as INT and use NULL for "-" data. However, I can't find th... | 2 | 2009-12-03T01:55:04Z | 1,837,385 | <p>As <a href="http://www.pytables.org/moin/HintsForSQLUsers">the docs</a> say,</p>
<blockquote>
<p>Cells in a PyTables' table always have
a value of the cell type, so there is
no NULL. Instead, cells take a default
value (zero or empty) which can be
changed in the type declaration, like
this: col_name = S... | 5 | 2009-12-03T03:09:45Z | [
"python",
"database"
] |
Are there any pure Python, BSD-ish open source SVG libraries? | 1,837,262 | <p>I'm looking for a pure Python library to help put together SVG images. It doesn't need to be fast.</p>
<p>I know <a href="http://codeboje.de/pysvg/" rel="nofollow">pySVG</a> exists, but I'm not interested in a GPL library (and I can't use GPL libraries for this particular project).</p>
<p>Basic SVG elements aren'... | 1 | 2009-12-03T02:23:41Z | 1,837,320 | <p>If your backend is OpenGL, I recommend <a href="http://www.supereffective.org/pages/Squirtle-SVG-Library" rel="nofollow">Squirtle-SVG-Library</a> that draws SVG images using pyglet. </p>
| 1 | 2009-12-03T02:46:15Z | [
"python",
"svg"
] |
Are there any pure Python, BSD-ish open source SVG libraries? | 1,837,262 | <p>I'm looking for a pure Python library to help put together SVG images. It doesn't need to be fast.</p>
<p>I know <a href="http://codeboje.de/pysvg/" rel="nofollow">pySVG</a> exists, but I'm not interested in a GPL library (and I can't use GPL libraries for this particular project).</p>
<p>Basic SVG elements aren'... | 1 | 2009-12-03T02:23:41Z | 1,837,705 | <p>I wrote a library that I use to generate XHTML and SVG and I posted it <a href="http://carrickbender.com/XMLlib.tgz" rel="nofollow">here</a>. It's pretty easy, each element has a corresponding all upper case class, the __init__ parameters are child elements and keyword parameters are attributes. The <strong>Transf... | 2 | 2009-12-03T04:47:12Z | [
"python",
"svg"
] |
How to get restructuredText to add a class to every html <p> tag? | 1,837,308 | <p>I'm using Django's markup package to transform restructuredText into html. Is there a way to customize the HTML writer to add a class attribute to each <code><p></code> tag?</p>
<p>I could use the <a href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#class">class directive</a> for each paragr... | 5 | 2009-12-03T02:43:23Z | 1,837,474 | <p>You don't say why you want to add a class to every paragraph, but it might be easier to take a different approach. For example, if you are trying to style the paragraphs, you can use a different CSS technique to select all the paragraphs in the output:</p>
<p>CSS:</p>
<pre><code>div.resttext p {
/* all the st... | 4 | 2009-12-03T03:36:35Z | [
"python",
"django",
"restructuredtext"
] |
How to get restructuredText to add a class to every html <p> tag? | 1,837,308 | <p>I'm using Django's markup package to transform restructuredText into html. Is there a way to customize the HTML writer to add a class attribute to each <code><p></code> tag?</p>
<p>I could use the <a href="http://docutils.sourceforge.net/docs/ref/rst/directives.html#class">class directive</a> for each paragr... | 5 | 2009-12-03T02:43:23Z | 3,682,110 | <p>Subclass the built-in <code>html4css1</code> writer, using <a href="http://www.arnebrodowski.de/blog/write-your-own-restructuredtext-writer.html" rel="nofollow">this</a> as a reference..</p>
<pre><code>from docutils.writers import html4css1
class MyHTMLWriter(html4css1.Writer):
"""
This docutils writer will us... | 4 | 2010-09-10T03:38:09Z | [
"python",
"django",
"restructuredtext"
] |
Pulling HTML from a Webpage in Java | 1,837,471 | <p>I want to pull the entire HTML source code file from a website in Java (or Python or PHP if it is easier in those languages to display). I wish only to view the HTML and scan through it with a few methods- not edit or manipulate it in any way, and I really wish that I do not write it to a new file unless there is no... | 0 | 2009-12-03T03:35:52Z | 1,837,487 | <p>In Python:</p>
<pre><code>import urllib
# Get a file-like object for the Python Web site's home page.
f = urllib.urlopen("http://www.python.org")
# Read from the object, storing the page's contents in 's'.
s = f.read()
f.close()
</code></pre>
<p>Please see <a href="http://www.boddie.org.uk/python/HTML.html" rel="n... | 2 | 2009-12-03T03:41:13Z | [
"java",
"python",
"html",
"webpage",
"pull"
] |
Pulling HTML from a Webpage in Java | 1,837,471 | <p>I want to pull the entire HTML source code file from a website in Java (or Python or PHP if it is easier in those languages to display). I wish only to view the HTML and scan through it with a few methods- not edit or manipulate it in any way, and I really wish that I do not write it to a new file unless there is no... | 0 | 2009-12-03T03:35:52Z | 1,837,497 | <p>In Java:</p>
<pre><code>URL url = new URL("http://stackoverflow.com");
URLConnection connection = new URLConnection(url);
InputStream stream = url.openConnection();
// ... read stream like any file stream
</code></pre>
<p>This code, is good for scripting purposes and internal use. I would argue against using it f... | 5 | 2009-12-03T03:44:10Z | [
"java",
"python",
"html",
"webpage",
"pull"
] |
Pulling HTML from a Webpage in Java | 1,837,471 | <p>I want to pull the entire HTML source code file from a website in Java (or Python or PHP if it is easier in those languages to display). I wish only to view the HTML and scan through it with a few methods- not edit or manipulate it in any way, and I really wish that I do not write it to a new file unless there is no... | 0 | 2009-12-03T03:35:52Z | 1,838,037 | <p>Maybe you should also consider an alternative like running a standard utility like <a href="http://linux.about.com/od/commands/l/blcmdl1%5Fwget.htm" rel="nofollow">wget</a> or <a href="http://linux.about.com/od/commands/l/blcmdl1%5Fcurl.htm" rel="nofollow">curl</a> from the command line to fetch the site tree into a... | 0 | 2009-12-03T06:25:36Z | [
"java",
"python",
"html",
"webpage",
"pull"
] |
Python2.6 Backtrack/Ubuntu wxPython | 1,837,558 | <p>I wrote a python app and it needs python2.6. I'm trying to get it to run in Backtrack 4 which is a pen-testing linux distro based on debian/ubuntu. I'v managed to install python2.6 along side of python2.5. Now I'm trying to install wxPython for 2.6 from the repos but I can't get it to install it for python2.6 rather... | 0 | 2009-12-03T04:05:20Z | 1,837,597 | <p>There is pre-built version of python, wxwidgets, wxpython in ubuntu packages.</p>
<p>You don't need to build from the sources(unless you have special reasons), you can install it from the following links.</p>
<p><a href="http://packages.ubuntu.com/jaunty/python2.6" rel="nofollow">http://packages.ubuntu.com/jaunty/... | 1 | 2009-12-03T04:15:40Z | [
"python",
"ubuntu",
"wxpython"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,837,697 | <p>Just use gzip compression, and save 60-70% with 0% effort!</p>
| 18 | 2009-12-03T04:46:09Z | [
"python",
"c",
"utf-8",
"compression"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,837,711 | <p>Do you understand that files are divided into bytes? Thus, if you did that, you'd have 7 bits of the first letter in bytes 1, plus 1 bit of the second letter, then in byte two, you'd have 6 bits of the second letter, and 2 bits of the third, so on. It would look like this:</p>
<pre><code>|AAAAAAAB|BBBBBBCC|CCCCCDDD... | 6 | 2009-12-03T04:48:20Z | [
"python",
"c",
"utf-8",
"compression"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,837,718 | <p>Your idea is unlikely to work. If you write the byte 0x05 into a file, the byte gets written, all 8 bits of it - with leading zeros. To actually accomplish what you need, you can encode each 8 bytes in 7 bytes (since you only need 8*7 bits to encode 8 values). One approach is keep the 7 values in the 7 low bits of t... | 1 | 2009-12-03T04:51:04Z | [
"python",
"c",
"utf-8",
"compression"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,837,742 | <p>Your idea is on the right track, but needs some development. If you're interested in this kind of data compression, you may want to investigate <a href="http://en.wikipedia.org/wiki/Huffman%5Fcoding" rel="nofollow">Huffman coding</a>. This is a simple data compression technique that is used in many real-world situat... | 3 | 2009-12-03T04:56:28Z | [
"python",
"c",
"utf-8",
"compression"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,838,614 | <p>What you need is UTF-7.</p>
<p><strong>Edit:</strong> UTF-7 has the advantage of bloating "only" special characters, so if special characters are rare in the input, you get far less bytes than by just converting UTF-8 to 7 bit. That's what UTF-7 is for.</p>
| -2 | 2009-12-03T08:57:43Z | [
"python",
"c",
"utf-8",
"compression"
] |
Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits | 1,837,686 | <p>I wish to take a file encoded in UTF-8 that doesn't use more than 128 different characters, then move it to a 7-bit encoding to save the 1/8 of space. For example, if I have a 16 MB text file that only uses the first 128(ascii) characters, I would like to shave off the extra bit to reduce the file to 14MB.</p>
<p>H... | 2 | 2009-12-03T04:43:05Z | 1,839,384 | <p>"this would simply leave an extra 0 on the binary string--11011001 might get mapped to 01000001 rather than 1000001, and I won't actually save space."</p>
<p>Correct. Your plan will do nothing.</p>
| 0 | 2009-12-03T11:35:44Z | [
"python",
"c",
"utf-8",
"compression"
] |
Using the Python shell in Vi mode on Windows | 1,837,693 | <p>I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my <code>~/.inputrc</code>:</p>
<pre><code>set editing-mode vi
</code></pre>
<p>This lets me use Vi-style editing inside the Python shell.</p>
<p>But can this be made to work when using Python on a... | 3 | 2009-12-03T04:45:21Z | 1,837,737 | <p><a href="http://www.cygwin.com/" rel="nofollow">cygwin</a> can give you many Unix-y advantages on your "Windows XP box" (using its own Python build, among other things -- avoiding some of the Windows-only limitations of the "standard Windows builds") -- try it out!</p>
| 1 | 2009-12-03T04:55:37Z | [
"python",
"windows",
"vi",
"readline"
] |
Using the Python shell in Vi mode on Windows | 1,837,693 | <p>I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my <code>~/.inputrc</code>:</p>
<pre><code>set editing-mode vi
</code></pre>
<p>This lets me use Vi-style editing inside the Python shell.</p>
<p>But can this be made to work when using Python on a... | 3 | 2009-12-03T04:45:21Z | 4,305,481 | <p>Answering my own question, it looks like you can use the <a href="http://ipython.scipy.org/moin/PyReadline/Intro" rel="nofollow">PyReadline</a> library in conjunction with <a href="http://ipython.scipy.org/moin/" rel="nofollow">IPython</a> to get most of the Vi functionality I miss on Linux. I still haven't figured ... | 0 | 2010-11-29T15:58:01Z | [
"python",
"windows",
"vi",
"readline"
] |
Using the Python shell in Vi mode on Windows | 1,837,693 | <p>I know that you can use the Python shell in Vi mode on Unix-like operating systems. For example, I have this line in my <code>~/.inputrc</code>:</p>
<pre><code>set editing-mode vi
</code></pre>
<p>This lets me use Vi-style editing inside the Python shell.</p>
<p>But can this be made to work when using Python on a... | 3 | 2009-12-03T04:45:21Z | 9,759,079 | <p>Install <a href="http://pypi.python.org/pypi/pyreadline" rel="nofollow">PyReadline</a></p>
<p>Setup your <code>pyreadlineconfig.ini</code> and <code>PYTHONSTARTUPFILE</code> files as per the PyReadline instructions.</p>
<p>Then add the following to your <code>pyreadlineconfig.ini</code> file:</p>
<pre><code>set_m... | 2 | 2012-03-18T14:22:31Z | [
"python",
"windows",
"vi",
"readline"
] |
Invalid Token when using Octal numbers | 1,837,874 | <p>I'm a beginner in python and I'm trying to use a octal number in my script, but when I try it, it returns me that error:</p>
<pre><code>>>> a = 010
SyntaxError: invalid token (<pyshell#0>, line 1)
>>> 01
SyntaxError: invalid token (<pyshell#1>, line 1)
</code></pre>
<p>There's somethi... | 28 | 2009-12-03T05:39:29Z | 1,837,896 | <p>Try <code>0o10</code>, may be because of python 3, or pyshell itself.</p>
<p>PEP says, </p>
<blockquote>
<p>octal literals must now be specified
with a leading "0o" or "0O" instead of
"0";</p>
</blockquote>
<p><a href="http://www.python.org/dev/peps/pep-3127/">http://www.python.org/dev/peps/pep-3127/</a></p... | 45 | 2009-12-03T05:45:23Z | [
"python",
"syntax",
"python-3.x",
"octal"
] |
Programatically updating a spreadsheet hosted on google docs | 1,837,937 | <p>I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update.</p>
<p>I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas.</p>
<p>I'm using... | 8 | 2009-12-03T05:58:04Z | 1,857,611 | <p>This is really complicated. I understand that you can edit your spreadsheets with Python using their API, Google tends to offer that ability on many of their web services and it's all done by sending HTTP post requests made of XML somehow, I hope you know that part, I don't.</p>
<p>According to <a href="http://code... | 2 | 2009-12-07T03:13:04Z | [
"python",
"google-docs"
] |
Programatically updating a spreadsheet hosted on google docs | 1,837,937 | <p>I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update.</p>
<p>I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas.</p>
<p>I'm using... | 8 | 2009-12-03T05:58:04Z | 1,871,363 | <p>Couldn't you could export your spreadsheet as a xls and then upload it as a new doc with a (slightly) different name, specifying the new name in the XML metadata?</p>
<p>The Download and Create/upload Document sections at <a href="http://code.google.com/apis/documents/overview.html" rel="nofollow">http://code.googl... | 1 | 2009-12-09T03:12:21Z | [
"python",
"google-docs"
] |
Programatically updating a spreadsheet hosted on google docs | 1,837,937 | <p>I've got a pre-existing spreadsheet hosted on google docs. Each month I update this document. I've got a template workseet in the spreadseet that I'd like to clone and then update.</p>
<p>I'd prefer to clone the worksheet rather than create it from scratch as it has some pretty complex formulas.</p>
<p>I'm using... | 8 | 2009-12-03T05:58:04Z | 1,872,474 | <p>First of all, I've never worked with Python before - but I'll tell you how I did this in C++.</p>
<p>I've used cURL to make a GET request to the <a href="http://code.google.com/intl/nl/apis/documents/docs/3.0/developers%5Fguide%5Fprotocol.html#DownloadingDocs" rel="nofollow">google documents API</a>. The binary dat... | 2 | 2009-12-09T08:49:13Z | [
"python",
"google-docs"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.