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 |
|---|---|---|---|---|---|---|---|---|---|
104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN? | 383,738 | <p>We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read:</p>
<pre>(104, 'Connection reset by peer')</pre>
<p>When I listen in with wireshark, the "good" and "bad" respons... | 20 | 2008-12-20T21:04:42Z | 1,196,886 | <p>I realize you are using python, but I found this Java article to be useful.</p>
<p><a href="http://java.sun.com/javase/6/docs/technotes/guides/net/articles/connection_release.html">http://java.sun.com/javase/6/docs/technotes/guides/net/articles/connection_release.html</a></p>
| 5 | 2009-07-28T21:35:46Z | [
"python",
"sockets",
"wsgi",
"httplib2",
"werkzeug"
] |
Django objects.filter, how "expensive" would this be? | 383,760 | <p>I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database se... | 1 | 2008-12-20T21:30:12Z | 383,776 | <p>filter itself doesn't execute a query, no query is executed until you explicitly fetch items from query (e.g. get), and list( query ) also executes it.</p>
| 4 | 2008-12-20T21:43:51Z | [
"python",
"sql",
"django",
"search",
"optimization"
] |
Django objects.filter, how "expensive" would this be? | 383,760 | <p>I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database se... | 1 | 2008-12-20T21:30:12Z | 383,797 | <p>You can see the query that will be generated by using:</p>
<pre><code>soknad_list.query.as_sql()[0]
</code></pre>
<p>You can then put that into your database shell to see how long the query takes, or use EXPLAIN (if your database backend supports it) to see how expensive it is.</p>
| 2 | 2008-12-20T22:02:29Z | [
"python",
"sql",
"django",
"search",
"optimization"
] |
Django objects.filter, how "expensive" would this be? | 383,760 | <p>I am trying to make a search view in Django. It is a search form with freetext input + some options to select, so that you can filter on years and so on. This is some of the code I have in the view so far, the part that does the filtering. And I would like some input on how expensive this would be on the database se... | 1 | 2008-12-20T21:30:12Z | 383,829 | <p>As Aaron mentioned, you should get a hold of the query text that is going to be run against the database and use an EXPLAIN (or other some method) to view the query execution plan. Once you have a hold of the execution plan for the query you can see what is going on in the database itself. There are a lot of operati... | -1 | 2008-12-20T22:35:20Z | [
"python",
"sql",
"django",
"search",
"optimization"
] |
Best way to return the language of a given string | 383,966 | <p>More specifically, I'm trying to check if given string (a sentence) is in Turkish. </p>
<p>I can check if the string has Turkish characters such as Ã, Å, Ã, Ã, Ä etc. However that's not very reliable as those might be converted to C, S, U, O, G before I receive the string.</p>
<p>Another method is to have the... | 7 | 2008-12-21T01:12:56Z | 383,988 | <p>One option would be to use a Bayesian Classifier such as <a href="http://www.divmod.org/trac/wiki/DivmodReverend">Reverend</a>. The Reverend homepage gives this suggestion for a naive language detector:</p>
<pre><code>from reverend.thomas import Bayes
guesser = Bayes()
guesser.train('french', 'le la les du un une ... | 14 | 2008-12-21T01:40:58Z | [
"python",
"algorithm",
"string"
] |
Best way to return the language of a given string | 383,966 | <p>More specifically, I'm trying to check if given string (a sentence) is in Turkish. </p>
<p>I can check if the string has Turkish characters such as Ã, Å, Ã, Ã, Ä etc. However that's not very reliable as those might be converted to C, S, U, O, G before I receive the string.</p>
<p>Another method is to have the... | 7 | 2008-12-21T01:12:56Z | 384,062 | <p>A simple statistical method that I've used before:</p>
<p>Get a decent amount of sample training text in the language you want to detect. Split it up into trigrams, e.g.</p>
<p>"Hello foobar" in trigrams is:
'Hel', 'ell', 'llo', 'lo ', 'o f', ' fo', 'foo', 'oob', 'oba', 'bar'</p>
<p>For all of the source data, c... | 10 | 2008-12-21T03:32:36Z | [
"python",
"algorithm",
"string"
] |
Best way to return the language of a given string | 383,966 | <p>More specifically, I'm trying to check if given string (a sentence) is in Turkish. </p>
<p>I can check if the string has Turkish characters such as Ã, Å, Ã, Ã, Ä etc. However that's not very reliable as those might be converted to C, S, U, O, G before I receive the string.</p>
<p>Another method is to have the... | 7 | 2008-12-21T01:12:56Z | 384,515 | <p>Why not just use an existing spell checking library?
Spell check for several languages, choose language with lowest error count.</p>
| -1 | 2008-12-21T14:26:36Z | [
"python",
"algorithm",
"string"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 384,125 | <p>I already knew about the color escapes, I used them in my bash prompt a while ago. Thanks anyway.<br>
What I wanted was to integrate it with the logging module, which I eventually did after a couple of tries and errors.<br>
Here is what I end up with:</p>
<pre><code>BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, W... | 119 | 2008-12-21T05:17:39Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 1,336,640 | <p>Here is a solution that should work on any platform. If it doesn't just tell me and I will update it.</p>
<p>How it works: on platform supporting ANSI escapes is using them (non-Windows) and on Windows it does use API calls to change the console colors.</p>
<p>The script does hack the logging.StreamHandler.emit me... | 56 | 2009-08-26T18:29:35Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 2,205,909 | <p>I modified the original example provided by Sorin and subclassed StreamHandler to a ColorizedConsoleHandler.</p>
<p>The downside of their solution is that it modifies the message, and because that is modifying the actual logmessage any other handlers will get the modified message as well.</p>
<p>This resulted in l... | 8 | 2010-02-05T08:36:51Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 2,532,931 | <p>I updated the example from airmind supporting tags for foreground and background.
Just use the color variables $BLACK - $WHITE in your log formatter string. To set the background just use $BG-BLACK - $BG-WHITE.</p>
<pre><code>import logging
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = range(8)
COLORS =... | 12 | 2010-03-28T12:49:40Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 2,666,796 | <p>Another minor remix of airmind's approach that keeps everything in one class:</p>
<pre><code>class ColorFormatter(logging.Formatter):
FORMAT = ("[$BOLD%(name)-20s$RESET][%(levelname)-18s] "
"%(message)s "
"($BOLD%(filename)s$RESET:%(lineno)d)")
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA,... | 6 | 2010-04-19T11:01:26Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 4,672,282 | <p>The bit I had trouble with was setting up the formatter properly:</p>
<pre><code>class ColouredFormatter(logging.Formatter):
def __init__(self, msg):
logging.Formatter.__init__(self, msg)
self._init_colour = _get_colour()
def close(self):
# restore the colour information to what... | 1 | 2011-01-12T18:07:31Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 4,691,726 | <p>Look at the following solution. The stream handler should be the thing doing the colouring, then you have the option of colouring words rather than just the whole line (with the Formatter). </p>
<p><a href="http://plumberjack.blogspot.com/2010/12/colorizing-logging-output-in-terminals.html">http://plumberjack.blogs... | 10 | 2011-01-14T13:52:14Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 7,995,762 | <p>Quick and dirty solution for predefined log levels and without defining a new class.</p>
<pre><code>logging.addLevelName( logging.WARNING, "\033[1;31m%s\033[1;0m" % logging.getLevelName(logging.WARNING))
logging.addLevelName( logging.ERROR, "\033[1;41m%s\033[1;0m" % logging.getLevelName(logging.ERROR))
</code></pre... | 39 | 2011-11-03T13:31:53Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 16,630,038 | <p>Just answered the same on similar question: <a href="http://stackoverflow.com/questions/2330245/python-change-text-color-in-shell/16630004#16630004">Python | change text color in shell</a></p>
<p>The idea is to use the <a href="https://github.com/kennethreitz/clint" rel="nofollow">clint</a> library. Which has suppo... | -1 | 2013-05-18T23:34:28Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 16,847,935 | <p>Years ago I wrote a colored stream handler for my own use. Then I came across this page and found a collection of code snippets that people are copy/pasting :-(. My stream handler currently only works on UNIX (Linux, Mac OS X) but the advantage is that it's <a href="https://pypi.python.org/pypi/coloredlogs">availabl... | 29 | 2013-05-31T00:16:27Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 20,698,959 | <p>Now there is a released PyPi module for customizable colored logging output:</p>
<p><a href="https://pypi.python.org/pypi/rainbow_logging_handler/">https://pypi.python.org/pypi/rainbow_logging_handler/</a></p>
<p>and</p>
<p><a href="https://github.com/laysakura/rainbow_logging_handler">https://github.com/laysakur... | 6 | 2013-12-20T08:08:40Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 23,964,880 | <p><strong>Update</strong>: Because this is an itch that I've been meaning to scratch for so long, I went ahead and wrote a library for lazy people like me who just want simple ways to do things: <a href="https://github.com/ManufacturaInd/zenlog">zenlog</a></p>
<p>Colorlog is excellent for this. It's <a href="https://... | 16 | 2014-05-30T23:39:51Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 26,183,545 | <p>Here's my solution:</p>
<pre><code>class ColouredFormatter(logging.Formatter):
RESET = '\x1B[0m'
RED = '\x1B[31m'
YELLOW = '\x1B[33m'
BRGREEN = '\x1B[01;32m' # grey in solarized for terminals
def format(self, record, colour=False):
message = super().format(record)
if not colou... | 2 | 2014-10-03T17:10:01Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 28,266,098 | <p>Use <a href="https://github.com/ilovecode1/pyfancy" rel="nofollow">pyfancy</a>.</p>
<p>Example:</p>
<pre><code>print(pyfancy.RED + "Hello Red!" + pyfancy.END)
</code></pre>
| 0 | 2015-02-01T18:16:55Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 29,948,976 | <p>While the other solutions seem fine they have some issues. Some do colour the whole lines which some times is not wanted and some omit any configuration you might have all together. The solution below doesn't affect anything but the message itself.</p>
<p><strong>Code</strong></p>
<pre><code>class ColoredFormatter... | 0 | 2015-04-29T16:03:16Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 30,649,849 | <p>I have two submissions to add, one of which colorizes just the message (ColoredFormatter), and one of which colorizes the entire line (ColorizingStreamHandler). These also include more ANSI color codes than previous solutions.</p>
<p>Some content has been sourced (with modification) from:
The post above, and <a hr... | 1 | 2015-06-04T16:56:59Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 31,991,678 | <pre><code>import logging
import sys
colors = {'pink': '\033[95m', 'blue': '\033[94m', 'green': '\033[92m', 'yellow': '\033[93m', 'red': '\033[91m',
'ENDC': '\033[0m', 'bold': '\033[1m', 'underline': '\033[4m'}
logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)
def str_color(color, data):
return ... | 4 | 2015-08-13T14:52:25Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 32,093,299 | <p>A simple but very flexible tool for coloring ANY terminal text is '<a href="http://nojhan.github.io/colout/" rel="nofollow">colout</a>'.</p>
<pre><code>pip install colout
myprocess | colout REGEX_WITH_GROUPS color1,color2...
</code></pre>
<p>Where any text in the output of 'myprocess' which matches group 1 of the ... | 1 | 2015-08-19T10:45:15Z | [
"python",
"logging",
"colors"
] |
How can I color Python logging output? | 384,076 | <p>Some time ago, I saw a Mono application with colored output, presumably because of its log system (because all the messages were standardized). </p>
<p>Now, Python has the <code>logging</code> module, which lets you specify a lot of options to customize output. So, I'm imagining something similar would be possible ... | 174 | 2008-12-21T03:57:45Z | 37,895,226 | <p>You can import the <a href="https://github.com/borntyping/python-colorlog" rel="nofollow">colorlog</a> module and use its <code>ColoredFormatter</code> for colorizing log messages.</p>
<h2>Example</h2>
<p>Boilerplate for main module:</p>
<pre><code>import logging
import os
try:
import colorlog
have_colorl... | 1 | 2016-06-18T09:05:22Z | [
"python",
"logging",
"colors"
] |
Database does not update automatically with MySQL and Python | 384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | 24 | 2008-12-21T07:57:04Z | 384,240 | <p>I am not certain, but I am going to guess you are using a INNODB table, and you haven't done a commit. I believe MySQLdb enable transactions automatically.</p>
<p>Call <code>conn.commit()</code> before calling <code>close</code>.</p>
<p>From the FAQ: <a href="http://mysql-python.sourceforge.net/FAQ.html#my-data-... | 42 | 2008-12-21T08:08:32Z | [
"python",
"mysql",
"mysql-python"
] |
Database does not update automatically with MySQL and Python | 384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | 24 | 2008-12-21T07:57:04Z | 384,311 | <p>You need to commit changes manually or turn auto-commit on.</p>
<p>The reason SELECT returns the modified (but not persisted) data is because the connection is still in the same transaction.</p>
| 7 | 2008-12-21T10:11:28Z | [
"python",
"mysql",
"mysql-python"
] |
Database does not update automatically with MySQL and Python | 384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | 24 | 2008-12-21T07:57:04Z | 384,338 | <p>I've found that Python's connector automatically turns autocommit off, and there doesn't appear to be any way to change this behaviour. Of course you can turn it back on, but then looking at the query logs, it stupidly does two pointless queries after connect to turn autocommit off then back on.</p>
| 1 | 2008-12-21T10:53:43Z | [
"python",
"mysql",
"mysql-python"
] |
Database does not update automatically with MySQL and Python | 384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | 24 | 2008-12-21T07:57:04Z | 384,452 | <p>MySQLdb has autocommit off by default, which may be confusing at first. Your connection exists in its own transaction and you will not be able to see the changes you make from other connections until you commit that transaction.</p>
<p>You can either do <code>conn.commit()</code> after the update statement as other... | 22 | 2008-12-21T13:19:16Z | [
"python",
"mysql",
"mysql-python"
] |
Database does not update automatically with MySQL and Python | 384,228 | <p>I'm having some trouble updating a row in a MySQL database. Here is the code I'm trying to run:</p>
<pre><code>import MySQLdb
conn=MySQLdb.connect(host="localhost", user="root", passwd="pass", db="dbname")
cursor=conn.cursor()
cursor.execute("UPDATE compinfo SET Co_num=4 WHERE ID=100")
cursor.execute("SELECT Co_n... | 24 | 2008-12-21T07:57:04Z | 588,076 | <p>I did a lot of work with MySQL database in Python and I used to always forget to commit the query. SO Zoredashe is correct.</p>
| 0 | 2009-02-25T21:53:16Z | [
"python",
"mysql",
"mysql-python"
] |
Code refactoring help - how to reorganize validations | 384,291 | <p>We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram:</p>
<p>user input <=> model object <=> database storage</p>
<p>validations are needed with request coming from user input but ... | 0 | 2008-12-21T09:40:28Z | 384,791 | <p>Doing validation in the constructor really isn't the "Django way". Since the data you need to validate is coming from the client-side, using <a href="http://docs.djangoproject.com/en/dev/topics/forms/" rel="nofollow">new forms</a> (probably with a <a href="http://docs.djangoproject.com/en/dev/topics/forms/modelform... | 1 | 2008-12-21T18:46:17Z | [
"python",
"django",
"optimization",
"refactoring",
"web-applications"
] |
Code refactoring help - how to reorganize validations | 384,291 | <p>We have a web application that takes user inputs or database lookups to form some operations against some physical resources. The design can be simply presented as following diagram:</p>
<p>user input <=> model object <=> database storage</p>
<p>validations are needed with request coming from user input but ... | 0 | 2008-12-21T09:40:28Z | 384,904 | <p>Thanks Daniel for your reply. Especially for the newforms API, I will definitely spend time digging into it and see if I can adopt it for the better long-term benefits. But just for the sake of getting my work done for this iteration (meet my deadline before EOY), I'd probably still have to stick with the current le... | 0 | 2008-12-21T20:28:35Z | [
"python",
"django",
"optimization",
"refactoring",
"web-applications"
] |
How do you manage your Django applications? | 384,333 | <p>I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications.</p>
<p>Let's take a kind of SO as an example. Which applications would you use?
I'd say there should be the ... | 7 | 2008-12-21T10:48:19Z | 384,377 | <p>I'll tell you how I am approaching such question: I usually sit with a sheet of paper and draw the boxes (functionalities) and arrows (interdependencies between functionalities). I am sure there are methodologies or other things that could help you, but my approach usually works for me (YMMV, of course).</p>
<p>Kno... | 0 | 2008-12-21T12:07:27Z | [
"python",
"django",
"project",
"structure"
] |
How do you manage your Django applications? | 384,333 | <p>I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications.</p>
<p>Let's take a kind of SO as an example. Which applications would you use?
I'd say there should be the ... | 7 | 2008-12-21T10:48:19Z | 384,427 | <p>You should try and separate the project in as much applications as possible. For most projects an application will not contain more than 5 models. For example a project like SO would have separate applications for UsersProfiles, Questions, Tags (there's a ready one in django for this), etc. If there was a system wit... | 5 | 2008-12-21T12:56:59Z | [
"python",
"django",
"project",
"structure"
] |
How do you manage your Django applications? | 384,333 | <p>I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications.</p>
<p>Let's take a kind of SO as an example. Which applications would you use?
I'd say there should be the ... | 7 | 2008-12-21T10:48:19Z | 384,494 | <p>Just like any set of dependencies... try to find the most useful stand-alone aspects of the project and make those stand-alone apps. Other Django Apps will have higher level functionality, and reuse the parts of the lowest level apps that you have set up.</p>
<p>In my project, I have a calendar app with its own E... | 3 | 2008-12-21T14:03:39Z | [
"python",
"django",
"project",
"structure"
] |
How do you manage your Django applications? | 384,333 | <p>I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications.</p>
<p>Let's take a kind of SO as an example. Which applications would you use?
I'd say there should be the ... | 7 | 2008-12-21T10:48:19Z | 384,497 | <p>There aren't hard-and-fast rules, but I would say it's better to err on the side of more specialized applications. Ideally an application should handle just one functional concern: i.e. "tagging" or "commenting" or "auth/auth" or "posts." This type of design will also help you reuse available open source applicati... | 6 | 2008-12-21T14:08:05Z | [
"python",
"django",
"project",
"structure"
] |
How do you manage your Django applications? | 384,333 | <p>I just wanted to try to build a project with django. Therefore I have a (basic) question on how to manage such a project. Since I cannot find any guidelines or so on how to split a project into applications.</p>
<p>Let's take a kind of SO as an example. Which applications would you use?
I'd say there should be the ... | 7 | 2008-12-21T10:48:19Z | 388,021 | <p>A good question to ask yourself when deciding whether or not to write an app is "could I use this in another project?". If you think you could, then consider what it would take to make the application as independent as possible; How can you reduce the dependancies so that the app doesn't rely on anything specific t... | 3 | 2008-12-23T02:34:09Z | [
"python",
"django",
"project",
"structure"
] |
Using Python Web GET data | 384,336 | <p>I'm trying to pass information to a python page via the url. I have the following link text:</p>
<pre><code>"<a href='complete?id=%s'>" % (str(r[0]))
</code></pre>
<p>on the complete page, I have this:</p>
<pre><code>import cgi
def complete():
form = cgi.FieldStorage()
db = MySQLdb.connect(user="", ... | 0 | 2008-12-21T10:53:09Z | 384,355 | <p>The error means that <code>form["id"]</code> failed to find the key <code>"id"</code> in <code>cgi.FieldStorage()</code>.</p>
<p>To test what keys are in the called URL, use <a href="http://docs.python.org/library/cgi.html#cgi.test" rel="nofollow">cgi.test()</a>:</p>
<blockquote>
<p>cgi.test()</p>
<p>Robust... | 1 | 2008-12-21T11:26:32Z | [
"python",
"form-data"
] |
Using Python Web GET data | 384,336 | <p>I'm trying to pass information to a python page via the url. I have the following link text:</p>
<pre><code>"<a href='complete?id=%s'>" % (str(r[0]))
</code></pre>
<p>on the complete page, I have this:</p>
<pre><code>import cgi
def complete():
form = cgi.FieldStorage()
db = MySQLdb.connect(user="", ... | 0 | 2008-12-21T10:53:09Z | 384,359 | <p>First off, you should make dictionary lookups via</p>
<pre><code>possibly_none = my_dict.get( "key_name" )
</code></pre>
<p>Because this assigns None to the variable, if the key is not in the dict. You can then use the </p>
<pre><code>if key is not None:
do_stuff
</code></pre>
<p>idiom (yes, I'm a fan of nul... | 0 | 2008-12-21T11:32:46Z | [
"python",
"form-data"
] |
Using Python Web GET data | 384,336 | <p>I'm trying to pass information to a python page via the url. I have the following link text:</p>
<pre><code>"<a href='complete?id=%s'>" % (str(r[0]))
</code></pre>
<p>on the complete page, I have this:</p>
<pre><code>import cgi
def complete():
form = cgi.FieldStorage()
db = MySQLdb.connect(user="", ... | 0 | 2008-12-21T10:53:09Z | 390,735 | <p>Have you tried printing out the value of form to make sure you're getting what you think you're getting? You do have a little problem with your code though... you should be doing form["id"].value to get the value of the item from FieldStorage. Another alternative is to just do it yourself, like so:</p>
<pre><code>i... | 1 | 2008-12-24T04:24:29Z | [
"python",
"form-data"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 384,540 | <p>As for future plans of MySQLdb, you might want to ask the author (Andy Dustman).<br>
His blog is here: <a href="http://mysql-python.blogspot.com/" rel="nofollow">http://mysql-python.blogspot.com/</a></p>
| 1 | 2008-12-21T14:54:44Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 385,225 | <p>You're probably better off using Python 2.x at the moment. It's going to be a while before all Python packages are ported to 3.x, and I expect writing a library or application with 3.x at the moment would be quite frustrating.</p>
| 0 | 2008-12-22T00:02:24Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 1,448,215 | <p>not sure if you're still looking, but you could try this:
<a href="http://sourceforge.net/projects/mypysql/" rel="nofollow">http://sourceforge.net/projects/mypysql/</a></p>
| 1 | 2009-09-19T09:16:10Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 3,611,517 | <p>I was looking for it too, but also found nothing, so I ported MySQL-python-1.2.3 to py3k
you can read it here
<a href="http://sourceforge.net/p/mysql-python/discussion/70460/thread/61e3a3c9/" rel="nofollow">http://sourceforge.net/p/mysql-python/discussion/70460/thread/61e3a3c9/</a></p>
| 7 | 2010-08-31T17:19:17Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 5,288,582 | <p>It appears the MySQLdb is pretty much a dead project. However, <a href="https://github.com/PyMySQL/PyMySQL/">PyMySQL</a> is a dbapi compliant, pure-python implementation of a mysql client, and it has python 3 support.</p>
<p>EDIT: There's also <a href="https://launchpad.net/myconnpy">MySQL Connector/Python</a>. Sam... | 29 | 2011-03-13T09:42:27Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 6,160,255 | <p>You can download the mysql-connector-python module compatible with Python3: </p>
<blockquote>
<p><a href="http://rpm.pbone.net/index.php3/stat/4/idpl/15667200/dir/rawhide/com/mysql-connector-python3-0.3.2-2.fc16.noarch.rpm.html" rel="nofollow">http://rpm.pbone.net/index.php3/stat/4/idpl/15667200/dir/rawhide/com/... | 1 | 2011-05-28T07:18:35Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 12,905,382 | <p>There is an official Python 2/3 library, downloadable from MySQL website.
Oracle released version 1.0.7 to public on 29 September 2012.</p>
<p>It's pure Python and works with MySQL 4.1+</p>
<p>See more details here: <a href="http://dev.mysql.com/doc/connector-python/en/connector-python.html" rel="nofollow">http://... | 0 | 2012-10-15T23:22:43Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 17,156,299 | <p>Here is a working repository for Python 3: <a href="https://github.com/davispuh/MySQL-for-Python-3" rel="nofollow">https://github.com/davispuh/MySQL-for-Python-3</a></p>
| 2 | 2013-06-17T20:30:52Z | [
"python",
"mysql",
"python-3.x"
] |
MySQL-db lib for Python 3.x? | 384,471 | <p>So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.</p>
| 29 | 2008-12-21T13:37:38Z | 39,008,521 | <p>There are currently a few options for using Python 3 with mysql:</p>
<p><a href="https://pypi.python.org/pypi/mysql-connector-python" rel="nofollow">https://pypi.python.org/pypi/mysql-connector-python</a></p>
<ul>
<li>Officially supported by Oracle</li>
<li>Pure python</li>
<li>A little slow</li>
<li>Not compatibl... | 0 | 2016-08-18T01:17:10Z | [
"python",
"mysql",
"python-3.x"
] |
PIL and numpy | 384,759 | <p>Alright, I'm toying around with converting a PIL image object back and forth to a numpy array so I can do some faster pixel by pixel transformations than PIL's PixelAccess object would allow. I've figured out how to place the pixel information in a useful 3D numpy array by way of:</p>
<pre><code>pic = Image.open("... | 67 | 2008-12-21T18:21:32Z | 384,926 | <p>You're not saying how exactly <code>putdata()</code> is not behaving. I'm assuming you're doing </p>
<pre><code>>>> pic.putdata(a)
Traceback (most recent call last):
File "...blablabla.../PIL/Image.py", line 1185, in putdata
self.im.putdata(data, scale, offset)
SystemError: new style getargs format b... | 81 | 2008-12-21T20:46:21Z | [
"python",
"image",
"numpy",
"python-imaging-library"
] |
PIL and numpy | 384,759 | <p>Alright, I'm toying around with converting a PIL image object back and forth to a numpy array so I can do some faster pixel by pixel transformations than PIL's PixelAccess object would allow. I've figured out how to place the pixel information in a useful 3D numpy array by way of:</p>
<pre><code>pic = Image.open("... | 67 | 2008-12-21T18:21:32Z | 1,095,878 | <p>Open I as an array:</p>
<pre><code>>>> I = numpy.asarray(PIL.Image.open('test.jpg'))
</code></pre>
<p>Do some stuff to I, then, convert it back to an image:</p>
<pre><code>>>> im = PIL.Image.fromarray(numpy.uint8(I))
</code></pre>
<p><a href="http://barnesc.blogspot.com/2007/09/filter-numpy-ima... | 66 | 2009-07-08T02:33:17Z | [
"python",
"image",
"numpy",
"python-imaging-library"
] |
PIL and numpy | 384,759 | <p>Alright, I'm toying around with converting a PIL image object back and forth to a numpy array so I can do some faster pixel by pixel transformations than PIL's PixelAccess object would allow. I've figured out how to place the pixel information in a useful 3D numpy array by way of:</p>
<pre><code>pic = Image.open("... | 67 | 2008-12-21T18:21:32Z | 37,675,266 | <p>You need to convert your image to a numpy array this way:</p>
<pre><code>import numpy
import PIL
img = PIL.Image.open("foo.jpg").convert("L")
imgarr = numpy.array(img)
</code></pre>
| 1 | 2016-06-07T09:18:59Z | [
"python",
"image",
"numpy",
"python-imaging-library"
] |
Checking 2-dimensional array (like eight queens puzzle) | 384,874 | <p>My problem is very similar to eight queens puzzle.</p>
<p>I've got 2-dimensional array (N x N) that for example, looks like this:</p>
<pre><code>0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
</code></pre>
<p>I'm checking horizontally, vertically and diagonally for occurrences of 1</p>
<pre><code... | 5 | 2008-12-21T20:00:55Z | 384,887 | <p>One possible solution:</p>
<pre><code>def collision(x1, y1, x2, y2):
return x1 == x2 or y1 == y2 or abs(x1-x2) == abs(y1-y2)
</code></pre>
<p>i.e. there is a collision if the two points are on the same horizontal row, same vertical row or same diagonal (vertical distance == horizontal distance).</p>
| 19 | 2008-12-21T20:10:32Z | [
"python",
"arrays",
"puzzle"
] |
Checking 2-dimensional array (like eight queens puzzle) | 384,874 | <p>My problem is very similar to eight queens puzzle.</p>
<p>I've got 2-dimensional array (N x N) that for example, looks like this:</p>
<pre><code>0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
</code></pre>
<p>I'm checking horizontally, vertically and diagonally for occurrences of 1</p>
<pre><code... | 5 | 2008-12-21T20:00:55Z | 384,908 | <p>I think it would be much faster if you didn't solve it mathematically but first check all rows for multiple occurrences of 1s, then all columns and finally all diagonal lines.</p>
<p>Here is some code to test the diagonal lines in a simple way. (It's JavaScript, sorry!)</p>
<pre><code>var count = 0;
for (column = ... | 0 | 2008-12-21T20:31:52Z | [
"python",
"arrays",
"puzzle"
] |
Checking 2-dimensional array (like eight queens puzzle) | 384,874 | <p>My problem is very similar to eight queens puzzle.</p>
<p>I've got 2-dimensional array (N x N) that for example, looks like this:</p>
<pre><code>0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
</code></pre>
<p>I'm checking horizontally, vertically and diagonally for occurrences of 1</p>
<pre><code... | 5 | 2008-12-21T20:00:55Z | 384,953 | <p>Your description sounds like an instance of an exact cover problem, which can be solved using an algorithm Knuth calls <a href="http://en.wikipedia.org/wiki/Algorithm_X" rel="nofollow">Algorithm X</a>. I have implemented a <a href="http://hewgill.com/sudoku/" rel="nofollow">Sudoku solver in Javascript</a> using this... | 2 | 2008-12-21T21:06:14Z | [
"python",
"arrays",
"puzzle"
] |
Checking 2-dimensional array (like eight queens puzzle) | 384,874 | <p>My problem is very similar to eight queens puzzle.</p>
<p>I've got 2-dimensional array (N x N) that for example, looks like this:</p>
<pre><code>0,0,0,0,1 y
0,0,0,0,0 |
0,0,0,0,0 V
0,0,0,1,0
0,0,0,0,0
x->
</code></pre>
<p>I'm checking horizontally, vertically and diagonally for occurrences of 1</p>
<pre><code... | 5 | 2008-12-21T20:00:55Z | 385,515 | <p>Assuming you actually do have an N-dimensional space, which you probably don't, you can use this collision detector:</p>
<pre><code>def collision(t1, t2):
return len(set([abs(a-b) for a,b in zip(t1, t2)] + [0])) <= 2
</code></pre>
<p>Pass it a pair of tuples with whatever arity you like, and it will return ... | 0 | 2008-12-22T04:01:08Z | [
"python",
"arrays",
"puzzle"
] |
How do I send a custom header with urllib2 in a HTTP Request? | 385,262 | <p>I want to send a custom "Accept" header in my request when using urllib2.urlopen(..). How do I do that?</p>
| 42 | 2008-12-22T00:39:53Z | 385,411 | <p>Not quite. Creating a <code>Request</code> object does not actually send the request, and Request objects have no <code>Read()</code> method. (Also: <code>read()</code> is lowercase.) All you need to do is pass the <code>Request</code> as the first argument to <code>urlopen()</code> and that will give you your re... | 91 | 2008-12-22T02:29:01Z | [
"python",
"header",
"urllib2"
] |
How do I send a custom header with urllib2 in a HTTP Request? | 385,262 | <p>I want to send a custom "Accept" header in my request when using urllib2.urlopen(..). How do I do that?</p>
| 42 | 2008-12-22T00:39:53Z | 32,026,467 | <pre><code>import urllib2
request_headers = {
"Accept-Language": "en-US,en;q=0.5",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Referer": "http://thewebsite.com",
"Connection": "keep-alive"
}
r... | 8 | 2015-08-15T15:51:41Z | [
"python",
"header",
"urllib2"
] |
How do I send a custom header with urllib2 in a HTTP Request? | 385,262 | <p>I want to send a custom "Accept" header in my request when using urllib2.urlopen(..). How do I do that?</p>
| 42 | 2008-12-22T00:39:53Z | 37,414,162 | <p>Beside the other solutions mentioned already, you could use <code>add_header</code> method.</p>
<p>So the example provided py @pantsgolem will be: </p>
<pre><code>import urllib2
request = urllib2.Request("http://www.google.com")
request.add_header('Accept','text/html')
##Show the header having the key 'Accept'
... | 1 | 2016-05-24T12:50:28Z | [
"python",
"header",
"urllib2"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,360 | <p>Using Python's <a href="http://docs.python.org/library/stdtypes.html#string-formatting" rel="nofollow">string formatting</a> (use <a href="http://docs.python.org/library/stdtypes.html#str.format" rel="nofollow">str.format()</a> with Python 3.0):</p>
<pre><code>from decimal import Decimal
def format_number(i):
... | 0 | 2008-12-22T01:53:00Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,363 | <pre><code>def floatstrip(x):
if x == int(x):
return str(int(x))
else:
return str(x)
</code></pre>
<p>Be aware, though, that Python represents 0.1 as an imprecise float, on my system 0.10000000000000001 .</p>
| 5 | 2008-12-22T01:56:28Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,366 | <pre><code>from decimal import Decimal
'%g' % (Decimal(str(x)))
</code></pre>
| 3 | 2008-12-22T01:59:23Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,392 | <p><code>rstrip</code> doesn't do what you want it to do, it strips <em>any</em> of the characters you give it and not a suffix:</p>
<pre><code>>>> '30000.0'.rstrip('.0')
'3'
</code></pre>
<p>Actually, just <code>'%g' % i</code> will do what you want.
EDIT: as Robert pointed out in his comment this won't wo... | 14 | 2008-12-22T02:18:07Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,395 | <pre><code>>>> '%g' % 0
'0'
>>> '%g' % 0.0
'0'
>>> '%g' % 0.1
'0.1'
>>> '%g' % 1.0
'1'
</code></pre>
| 0 | 2008-12-22T02:21:37Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,398 | <p>Us the 0 prcision and add a period if you want one. EG "%.0f."</p>
<pre><code>>>> print "%.0f."%1.0
1.
>>>
</code></pre>
| -1 | 2008-12-22T02:23:35Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,406 | <pre><code>(str(i)[-2:] == '.0' and str(i)[:-2] or str(i) for i in ...)
</code></pre>
| 5 | 2008-12-22T02:25:58Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 385,487 | <p>If you only care about 1 decimal place of precision (as in your examples), you can just do:</p>
<pre><code>("%.1f" % i).replace(".0", "")
</code></pre>
<p>This will convert the number to a string with 1 decimal place and then remove it if it is a zero:</p>
<pre><code>>>> ("%.1f" % 0).replace(".0", "")
'0... | 2 | 2008-12-22T03:37:18Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 399,925 | <pre><code>>>> x = '1.0'
>>> int(float(x))
1
>>> x = 1
>>> int(float(x))
1
</code></pre>
| 3 | 2008-12-30T10:16:19Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 1,616,837 | <pre><code>str(x)[-2:] == '.0' and int(x) or x
</code></pre>
| 1 | 2009-10-24T03:23:32Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 12,080,042 | <p>See <a href="http://www.python.org/dev/peps/pep-3101/">PEP 3101</a>:</p>
<pre>
'g' - General format. This prints the number as a fixed-point
number, unless the number is too large, in which case
it switches to 'e' exponent notation.
</pre>
<p>Old style:</p>
<pre><code>>>> "%g" % float(10)
'10... | 28 | 2012-08-22T19:23:16Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 16,953,234 | <p>To print a <code>float</code> that has an integer value as an <code>int</code>:</p>
<pre><code>format = "%d" if f.is_integer() else "%s"
print(format % f)
</code></pre>
<p><a href="http://ideone.com/eaUpLj" rel="nofollow">Example</a></p>
<pre><code> 0.0 -> 0
0.1 -> 0.1
1... | 2 | 2013-06-06T03:24:24Z | [
"python"
] |
dropping trailing '.0' from floats | 385,325 | <p>I'm looking for a way to convert numbers to string format, dropping any redundant '.0' </p>
<p>The input data is a mix of floats and strings. Desired output:</p>
<p>0 --> '0'</p>
<p>0.0 --> '0'</p>
<p>0.1 --> '0.1'</p>
<p>1.0 --> '1'</p>
<p>I've come up with the following generator expression, but I wonder ... | 22 | 2008-12-22T01:33:33Z | 18,383,452 | <p>So much ugliness out thereâ¦</p>
<p>My personal favorite is to convert <code>float</code>s that don't require to be a <code>float</code> (= when they actually are integers) to <code>int</code>, thus removing the, now useless, trailing <code>0</code></p>
<p><code>(int(i) if i.is_integer() else i for i in lst)</cod... | 3 | 2013-08-22T14:34:28Z | [
"python"
] |
Python 3 porting workflow? | 385,394 | <p>I have a small project I want to try porting to Python 3 - how do I go about this?</p>
<p>I have made made the code run without warnings using <code>python2.6 -3</code> (mostly removing <code>.has_key()</code> calls), but I am not sure of the best way to use the 2to3 tool.</p>
<blockquote>
<p>Use the 2to3 tool t... | 5 | 2008-12-22T02:18:22Z | 385,397 | <p>Aha, you can pipe the 2to3 output to the <code>patch</code> command, which can write the modified file to a new file:</p>
<pre><code>mv something.py py2.6_something.py
2to3 py2.6_something.py | patch -o something.py
</code></pre>
| 5 | 2008-12-22T02:22:23Z | [
"python",
"python-3.x",
"porting"
] |
Python 3 porting workflow? | 385,394 | <p>I have a small project I want to try porting to Python 3 - how do I go about this?</p>
<p>I have made made the code run without warnings using <code>python2.6 -3</code> (mostly removing <code>.has_key()</code> calls), but I am not sure of the best way to use the 2to3 tool.</p>
<blockquote>
<p>Use the 2to3 tool t... | 5 | 2008-12-22T02:18:22Z | 386,897 | <p>2.x should be your codebase of active development, so 2to3 should really be run in a branch or temporary directory. I'm not sure why you'd want to have the 2.x and 3.x versions lying around in the same directory. distutils has a build_2to3 script that will run 2to3 on a 3.0 install.</p>
| 0 | 2008-12-22T17:55:55Z | [
"python",
"python-3.x",
"porting"
] |
Prototype based object orientation. The good, the bad and the ugly? | 385,403 | <p>I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to tradi... | 10 | 2008-12-22T02:25:02Z | 385,417 | <p>Okay, first of all, the prototype model isn't all that different in reality; Smalltalk uses a similar sort of scheme; the class is an object with the classes methods.</p>
<p>Looked at from the class POV, a class is really the equivalence class of objects with the same data, and all the same methods; you can look at... | 0 | 2008-12-22T02:31:15Z | [
"javascript",
"python",
"language-agnostic",
"lua",
"oop"
] |
Prototype based object orientation. The good, the bad and the ugly? | 385,403 | <p>I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to tradi... | 10 | 2008-12-22T02:25:02Z | 385,467 | <p>To conserve the bandwidth here is the link to <a href="http://stackoverflow.com/questions/355848/what-is-the-best-way-to-emulate-classes-in-javascript-with-or-without-a-framewo#356343">my answer on "How can I emulate âclassesâ in JavaScript? (with or without a third-party library)"</a>. It contains further refer... | 7 | 2008-12-22T03:15:34Z | [
"javascript",
"python",
"language-agnostic",
"lua",
"oop"
] |
Prototype based object orientation. The good, the bad and the ugly? | 385,403 | <p>I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to tradi... | 10 | 2008-12-22T02:25:02Z | 385,571 | <p>Prototype-based OO lends itself poorly to static type checking, which some might consider a bad or ugly thing. Prototype-based OO <em>does</em> have a standard way of creating new objects, you <strong>clone and modify existing objects</strong>. You can also build factories, etc.</p>
<p>I think what people like mo... | 13 | 2008-12-22T04:34:49Z | [
"javascript",
"python",
"language-agnostic",
"lua",
"oop"
] |
Prototype based object orientation. The good, the bad and the ugly? | 385,403 | <p>I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to tradi... | 10 | 2008-12-22T02:25:02Z | 408,410 | <p>Before worrying about how to emulate class-based inheritance in JavaScript, have a quick read of <em><a href="http://javascript.crockford.com/prototypal.html" rel="nofollow">Prototypal Inheritance in JavaScript</a></em>.</p>
| 2 | 2009-01-03T00:50:41Z | [
"javascript",
"python",
"language-agnostic",
"lua",
"oop"
] |
Prototype based object orientation. The good, the bad and the ugly? | 385,403 | <p>I come from classes object orientation languages and recently I have been learning those fancy dynamic languages (JavaScript, Python and Lua) and I want some tips about how to use OO in those languages. It would be useful to know the pitfalls and the shortcomings of such approach and the advantages compared to tradi... | 10 | 2008-12-22T02:25:02Z | 3,958,261 | <p>Classical inheritance is inherently flawed in terms of flexibility, in that we are saying "this object is of this type and no other". Some languages introduce multiple inheritance to alleviate this, but multiple inheritance has its own pitfalls, and so the benefits of pure composition over inheritance (which, in a s... | 1 | 2010-10-18T10:31:26Z | [
"javascript",
"python",
"language-agnostic",
"lua",
"oop"
] |
Extract float/double value | 385,558 | <p>How do I extract a double value from a string using regex.</p>
<pre><code>import re
pattr = re.compile(???)
x = pattr.match("4.5")
</code></pre>
| 17 | 2008-12-22T04:28:01Z | 385,597 | <p>A regexp from the <a href="http://perldoc.perl.org/perlretut.html#Building-a-regexp" rel="nofollow"><code>perldoc perlretut</code></a>:</p>
<pre><code>import re
re_float = re.compile("""(?x)
^
[+-]?\ * # first, match an optional sign *and space*
( # then match integers or f.p. mantis... | 38 | 2008-12-22T04:56:22Z | [
"python",
"regex"
] |
Extract float/double value | 385,558 | <p>How do I extract a double value from a string using regex.</p>
<pre><code>import re
pattr = re.compile(???)
x = pattr.match("4.5")
</code></pre>
| 17 | 2008-12-22T04:28:01Z | 386,177 | <p>Here's the easy way. Don't use regex's for built-in types.</p>
<pre><code>try:
x = float( someString )
except ValueError, e:
# someString was NOT floating-point, what now?
</code></pre>
| 16 | 2008-12-22T12:41:31Z | [
"python",
"regex"
] |
Extract float/double value | 385,558 | <p>How do I extract a double value from a string using regex.</p>
<pre><code>import re
pattr = re.compile(???)
x = pattr.match("4.5")
</code></pre>
| 17 | 2008-12-22T04:28:01Z | 6,278,082 | <p>a float as regular expression in brute force. there are smaller differences to the version of J.F. Sebastian:</p>
<pre><code>import re
if __name__ == '__main__':
x = str(1.000e-123)
reFloat = r'(^[+-]?\d+(?:\.\d+)?(?:[eE][+-]\d+)?$)'
print re.match(reFloat,x)
>>> <_sre.SRE_Match object at 0x0054D... | 1 | 2011-06-08T11:33:59Z | [
"python",
"regex"
] |
Extract float/double value | 385,558 | <p>How do I extract a double value from a string using regex.</p>
<pre><code>import re
pattr = re.compile(???)
x = pattr.match("4.5")
</code></pre>
| 17 | 2008-12-22T04:28:01Z | 28,832,504 | <p>For parse int and float (point separator) values:</p>
<pre><code>re.findall( r'\d+\.*\d*', 'some 12 12.3 0 any text 0.8' )
</code></pre>
<p>result:</p>
<pre><code>['12', '12.3', '0', '0.8']
</code></pre>
| 3 | 2015-03-03T13:01:36Z | [
"python",
"regex"
] |
Typecasting in Python | 385,572 | <p>I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.</p>
<p>How can I do this?</p>
| 12 | 2008-12-22T04:35:18Z | 385,580 | <p>Python only has a single <code>int</code> type. To convert a string to an <code>int</code>, use <code>int()</code> like this:</p>
<pre><code>>>> str = '123'
>>> num = int(str)
>>> num
123
</code></pre>
<p><strong>Edit:</strong> Also to convert to float, use <code>float()</code> in the ex... | 3 | 2008-12-22T04:42:51Z | [
"python",
"string",
"int",
"bit",
"casting"
] |
Typecasting in Python | 385,572 | <p>I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.</p>
<p>How can I do this?</p>
| 12 | 2008-12-22T04:35:18Z | 385,583 | <p>You can convert a string to a 32-bit signed integer with the <code>int</code> function:</p>
<pre><code>str = "1234"
i = int(str) // i is a 32-bit integer
</code></pre>
<p>If the string does not represent an integer, you'll get a <code>ValueError</code> exception. Note, however, that if the string does represent ... | 26 | 2008-12-22T04:44:48Z | [
"python",
"string",
"int",
"bit",
"casting"
] |
Typecasting in Python | 385,572 | <p>I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.</p>
<p>How can I do this?</p>
| 12 | 2008-12-22T04:35:18Z | 386,116 | <p>The following types -- for the most part -- don't exist in Python in the first place. In Python, strings are converted to ints, longs or floats, because that's all there is.</p>
<p>You're asking for conversions that aren't relevant to Python in the first place. Here's the list of types you asked for and their Pyt... | 3 | 2008-12-22T12:15:11Z | [
"python",
"string",
"int",
"bit",
"casting"
] |
Typecasting in Python | 385,572 | <p>I need to convert strings in Python to other types such as unsigned and signed 8, 16, 32, and 64 bit ints, doubles, floats, and strings.</p>
<p>How can I do this?</p>
| 12 | 2008-12-22T04:35:18Z | 386,651 | <p>I don't think this can necessarily be answered well without more information. As others have said, there are only int and long for integers in python -- the language doesn't adhere to the bit-width and signedness archetypes of lower-level programming languages.</p>
<p>If you're operating completely within python, t... | 0 | 2008-12-22T16:22:34Z | [
"python",
"string",
"int",
"bit",
"casting"
] |
Phone numbers to links in Python | 385,632 | <p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p>
<pre><code>import re
from string import digits
PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})')
def numbers2links(s):
result = ""
last_match_... | 2 | 2008-12-22T05:44:41Z | 385,647 | <p>A few things that will clean up your existing regex without really changing the functionality:</p>
<p>Replace {0,1} with ?, [(] with (, [)] with ). You also might as well just make your [2-9] b e a \d as well, so you can make those patterns be \d{3} and \d{4} for the last part. I doubt it will really increase the r... | 0 | 2008-12-22T05:57:05Z | [
"python",
"regex",
"mobile-website",
"phone-number"
] |
Phone numbers to links in Python | 385,632 | <p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p>
<pre><code>import re
from string import digits
PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})')
def numbers2links(s):
result = ""
last_match_... | 2 | 2008-12-22T05:44:41Z | 385,674 | <p>Why not re-use the work of others - for example, from <a href="http://regexlib.com/REDetails.aspx?regexp_id=458" rel="nofollow">RegExpLib.com</a>?</p>
<p>My second suggestion is to remember there are other countries besides the USA, and quite a few of them have telephones ;-) Please don't forget us during your soft... | 0 | 2008-12-22T06:37:28Z | [
"python",
"regex",
"mobile-website",
"phone-number"
] |
Phone numbers to links in Python | 385,632 | <p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p>
<pre><code>import re
from string import digits
PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})')
def numbers2links(s):
result = ""
last_match_... | 2 | 2008-12-22T05:44:41Z | 385,813 | <p>Your regexp only parses a specific format, which is not the international standard. If you limit yourself to one country, it may work.</p>
<p>Otherwise, the international standard is <a href="http://www.itu.int/rec/T-REC-E.123/en" rel="nofollow">ITU E.123</a> : "Notation for national and international telephone num... | 1 | 2008-12-22T08:55:16Z | [
"python",
"regex",
"mobile-website",
"phone-number"
] |
Phone numbers to links in Python | 385,632 | <p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p>
<pre><code>import re
from string import digits
PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})')
def numbers2links(s):
result = ""
last_match_... | 2 | 2008-12-22T05:44:41Z | 385,869 | <p>First off, reliably capturing phone numbers with a single regular expression is notoriously difficult with a strong tendency to being impossible. Not every country has a definition of a "phone number" that is as narrow as it is in the U.S. Even in the U.S., things are more complicated than they seem (from the <a hre... | 1 | 2008-12-22T09:41:01Z | [
"python",
"regex",
"mobile-website",
"phone-number"
] |
Phone numbers to links in Python | 385,632 | <p>I'm working a piece of code to turn phone numbers into links for mobile phone - I've got it but it feels really dirty.</p>
<pre><code>import re
from string import digits
PHONE_RE = re.compile('([(]{0,1}[2-9]\d{2}[)]{0,1}[-_. ]{0,1}[2-9]\d{2}[-_. ]{0,1}\d{4})')
def numbers2links(s):
result = ""
last_match_... | 2 | 2008-12-22T05:44:41Z | 387,101 | <p>Nice first take :) I think this version is a bit more readable (and probably a teensy bit faster). The key thing to note here is the use of <a href="http://docs.python.org/library/re.html#module-contents" rel="nofollow">re.sub</a>. Keeps us away from the nasty match indexes...</p>
<pre><code>import re
PHONE_RE ... | 5 | 2008-12-22T19:26:03Z | [
"python",
"regex",
"mobile-website",
"phone-number"
] |
need help - bit-field conversion | 386,151 | <p>I want to convert strings to bit-fields.Also,convert them to binary and then use.
Need help with this..help me ..</p>
| -3 | 2008-12-22T12:29:23Z | 386,161 | <p>they're all binary already... Which language are we talking about?</p>
<p>I'd start by looking at the string as an array of characters and working with each character individually.</p>
| 0 | 2008-12-22T12:33:30Z | [
"python",
"string",
"bits",
"bit-fields"
] |
need help - bit-field conversion | 386,151 | <p>I want to convert strings to bit-fields.Also,convert them to binary and then use.
Need help with this..help me ..</p>
| -3 | 2008-12-22T12:29:23Z | 386,188 | <p>I think the <a href="http://www.python.org/doc/2.5.2/lib/module-struct.html" rel="nofollow">struct module</a> is what you're after.</p>
<p>Example of usage: </p>
<pre><code>>>> from struct import *
>>> pack('hhl', 1, 2, 3)
'\x00\x01\x00\x02\x00\x00\x00\x03'
>>> unpack('hhl', '\x00\x01\x0... | 2 | 2008-12-22T12:49:44Z | [
"python",
"string",
"bits",
"bit-fields"
] |
Python Performance - have you ever had to rewrite in something else? | 386,655 | <p>Has anyone ever had code in Python, that turned out not to perform fast enough?</p>
<p>I mean, you were forced to <em>choose another language</em> because of it?</p>
<p>We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most sce... | 42 | 2008-12-22T16:23:13Z | 386,674 | <p>Yes, I have. I wrote a row-count program for a binary (length-prefixed rather than delimited) bcp output file once and ended up having to redo it in C because the python one was too slow. This program was quite small (it only took a couple of days to re-write it in C), so I didn't bother to try and build a hybrid ... | 33 | 2008-12-22T16:28:08Z | [
"python",
"performance",
"optimization",
"rewrite"
] |
Python Performance - have you ever had to rewrite in something else? | 386,655 | <p>Has anyone ever had code in Python, that turned out not to perform fast enough?</p>
<p>I mean, you were forced to <em>choose another language</em> because of it?</p>
<p>We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most sce... | 42 | 2008-12-22T16:23:13Z | 386,689 | <p>I used to prototype lots of things in python for doing things like log processing. When they didn't run fast enough, I'd rewrite them in ocaml.</p>
<p>In many cases, the python was fine and I was happy with it. In some cases, as it started approaching 23 hours to do a days' logs, I'd get to rewriting. :)</p>
<p... | 2 | 2008-12-22T16:34:44Z | [
"python",
"performance",
"optimization",
"rewrite"
] |
Python Performance - have you ever had to rewrite in something else? | 386,655 | <p>Has anyone ever had code in Python, that turned out not to perform fast enough?</p>
<p>I mean, you were forced to <em>choose another language</em> because of it?</p>
<p>We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most sce... | 42 | 2008-12-22T16:23:13Z | 386,702 | <p>This is a much more difficult question to answer than people are willing to admit. </p>
<p>For example, it may be that I am able to write a program that performs better in Python than it does in C. The fallacious conclusion from that statement is "Python is therefore faster than C". In reality, it may be because... | 18 | 2008-12-22T16:40:55Z | [
"python",
"performance",
"optimization",
"rewrite"
] |
Python Performance - have you ever had to rewrite in something else? | 386,655 | <p>Has anyone ever had code in Python, that turned out not to perform fast enough?</p>
<p>I mean, you were forced to <em>choose another language</em> because of it?</p>
<p>We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most sce... | 42 | 2008-12-22T16:23:13Z | 386,706 | <p>You can always write parts of your application in Python. Not every component is equally important for performance. Python integrates easily with C++ natively, or with Java via Jython, or with .NET via IronPython.</p>
<p>By the way, IronPython is more efficient than the C implementation of Python on some benchmark... | 2 | 2008-12-22T16:42:26Z | [
"python",
"performance",
"optimization",
"rewrite"
] |
Python Performance - have you ever had to rewrite in something else? | 386,655 | <p>Has anyone ever had code in Python, that turned out not to perform fast enough?</p>
<p>I mean, you were forced to <em>choose another language</em> because of it?</p>
<p>We are investigating using Python for a couple of larger projects, and my feeling is that in most cases, Python is plenty fast enough for most sce... | 42 | 2008-12-22T16:23:13Z | 386,752 | <p>I've been working for a while now, developing an application that operate on large structured data, stored in several-gigabytes-thick-database and well, Python is good enough for that. The application has GUI client with a multitude of controls (lists, trees, notebooks, virtual lists and more), and a console server.... | 2 | 2008-12-22T17:05:58Z | [
"python",
"performance",
"optimization",
"rewrite"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.