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 listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
How can I check for a blank image in Qt or PyQt? | 1,110,403 | <p>I have generated a collection of images. Some of them are blank as in their background is white. I have access to the QImage object of each of the images. Is there a Qt way to check for blank images? If not, can someone recommend the best way to do it in Python?</p>
| 4 | 2009-07-10T15:52:21Z | 1,110,455 | <p>Well, I would count the colors in the image. If there is only one, then the image is blank. I do not know enough Python or qt to write code for this but I am sure there is a library that can tell you how many colors there are in an image (I am going to look into using ImageMagick for this right after I post this).</... | 1 | 2009-07-10T15:59:38Z | [
"python",
"qt4",
"pyqt4"
] |
How can I check for a blank image in Qt or PyQt? | 1,110,403 | <p>I have generated a collection of images. Some of them are blank as in their background is white. I have access to the QImage object of each of the images. Is there a Qt way to check for blank images? If not, can someone recommend the best way to do it in Python?</p>
| 4 | 2009-07-10T15:52:21Z | 1,110,492 | <p>I don't know about Qt, but there is an easy and efficient way to do it in <a href="http://www.pythonware.com/products/pil/">PIL</a>
Using the <a href="http://www.pythonware.com/library/pil/handbook/image.htm">getextrema</a> method, example:</p>
<pre><code>im = Image.open('image.png')
bands = im.split()
isBlank = al... | 5 | 2009-07-10T16:07:25Z | [
"python",
"qt4",
"pyqt4"
] |
Why does Django's signal handling use weak references for callbacks by default? | 1,110,668 | <p>The <a href="http://docs.djangoproject.com/en/dev/ref/signals/">Django docs</a> say this on the subject:</p>
<blockquote>
<p>Note also that Django stores signal
handlers as weak references by
default, so if your handler is a local
function, it may be garbage collected.
To prevent this, pass weak=False whe... | 15 | 2009-07-10T16:47:10Z | 1,110,874 | <p>Signals handlers are stored as weak references to avoid the object they reference from not being garbage collected (for example after explicit deletion of the signal handler), just because a signal is still flying around.</p>
| 8 | 2009-07-10T17:26:14Z | [
"python",
"django",
"garbage-collection",
"weak-references",
"django-signals"
] |
Why does Django's signal handling use weak references for callbacks by default? | 1,110,668 | <p>The <a href="http://docs.djangoproject.com/en/dev/ref/signals/">Django docs</a> say this on the subject:</p>
<blockquote>
<p>Note also that Django stores signal
handlers as weak references by
default, so if your handler is a local
function, it may be garbage collected.
To prevent this, pass weak=False whe... | 15 | 2009-07-10T16:47:10Z | 1,111,287 | <p>Bound methods keep a reference to the object they belong to (otherwise, they cannot fill <code>self</code>, cf. the <a href="http://docs.python.org/library/stdtypes.html?highlight=im%5Fself" rel="nofollow">Python documentation</a>). Consider the following code:</p>
<pre><code>import gc
class SomeLargeObject(object)... | 4 | 2009-07-10T18:46:07Z | [
"python",
"django",
"garbage-collection",
"weak-references",
"django-signals"
] |
Python subprocess question | 1,110,804 | <p>I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.</p>
<p>My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess... | 4 | 2009-07-10T17:16:05Z | 1,110,847 | <p>The short answer is that there is no such thing as a good cross platform system for process management, without designing that concept into your system. This is especially in the standar libraries. Even the various unix versions have their own compatibility issues.</p>
<p>Your best bet is to instrument all the proc... | 0 | 2009-07-10T17:22:49Z | [
"python",
"subprocess"
] |
Python subprocess question | 1,110,804 | <p>I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.</p>
<p>My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess... | 4 | 2009-07-10T17:16:05Z | 1,112,027 | <p>Use the <a href="http://docs.python.org/library/multiprocessing.html" rel="nofollow">multiprocessing</a> module in the Python 2.6 standard library. </p>
<p>It has a <a href="http://docs.python.org/library/multiprocessing.html#multiprocessing.Queue" rel="nofollow">Queue class</a> that can be used for both reading a... | 3 | 2009-07-10T21:16:58Z | [
"python",
"subprocess"
] |
Python subprocess question | 1,110,804 | <p>I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.</p>
<p>My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess... | 4 | 2009-07-10T17:16:05Z | 1,116,958 | <p>I do this in a separate thread, using message queues to communicate between the threads. In my case the subprocess prints % complete to stdout. I wanted the main thread to put up a pretty progress bar.</p>
<pre><code> if sys.platform == 'win32':
self.shell = False
self.startupinfo = subprocess.STA... | 1 | 2009-07-12T21:25:18Z | [
"python",
"subprocess"
] |
Python subprocess question | 1,110,804 | <p>I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal.</p>
<p>My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess... | 4 | 2009-07-10T17:16:05Z | 1,295,006 | <p>Forgive my ignorance on this topic, but couldn't you just launch python with the -u flag for "unbuffered"? </p>
<p>This might also be of interest...
<a href="http://www.gossamer-threads.com/lists/python/python/658167" rel="nofollow">http://www.gossamer-threads.com/lists/python/python/658167</a></p>
| 0 | 2009-08-18T16:28:37Z | [
"python",
"subprocess"
] |
python sqlalchemy performance? | 1,110,805 | <p>HI ï¼ I made a ICAPServer (similar with httpserver) for which the performance is very important.
The DB module is sqlalchemy.
I then made a test about the performance of sqlalchemy, as a result, i found that it takes about 30ms for sqlalchemy to write <50kb data to DB (Oracle), i don`t know if the result is norm... | 1 | 2009-07-10T17:16:11Z | 1,110,888 | <p>You can only push SQLAlchemy so far as a programmer. I would agree with you that the rest of the performance is up to your DBA, including creating proper indexes on tables, etc.</p>
| 1 | 2009-07-10T17:28:23Z | [
"python",
"sqlalchemy"
] |
python sqlalchemy performance? | 1,110,805 | <p>HI ï¼ I made a ICAPServer (similar with httpserver) for which the performance is very important.
The DB module is sqlalchemy.
I then made a test about the performance of sqlalchemy, as a result, i found that it takes about 30ms for sqlalchemy to write <50kb data to DB (Oracle), i don`t know if the result is norm... | 1 | 2009-07-10T17:16:11Z | 1,110,960 | <p>You should first <em>measure</em> where your bottleneck is, for example using the <a href="http://docs.python.org/library/profile.html">profile</a> module.</p>
<p>Then optimize, if you have the possibility to, the slowest part of the system.</p>
| 5 | 2009-07-10T17:41:18Z | [
"python",
"sqlalchemy"
] |
python sqlalchemy performance? | 1,110,805 | <p>HI ï¼ I made a ICAPServer (similar with httpserver) for which the performance is very important.
The DB module is sqlalchemy.
I then made a test about the performance of sqlalchemy, as a result, i found that it takes about 30ms for sqlalchemy to write <50kb data to DB (Oracle), i don`t know if the result is norm... | 1 | 2009-07-10T17:16:11Z | 1,110,990 | <p>I had some issues with sqlalchemy's performance as well - I think you should first figure out in which ways you are using it ... they recommend that for big data sets is better to use the sql expression language. Either ways try and optimize the sqlalchemy code and have the Oracle database optimized as well, so you ... | 1 | 2009-07-10T17:46:49Z | [
"python",
"sqlalchemy"
] |
Get time zone information of the system in Python? | 1,111,056 | <p>I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.</p>
| 26 | 2009-07-10T17:59:28Z | 1,111,079 | <p>Check out the Python <a href="http://docs.python.org/library/time.html" rel="nofollow">Time</a> Module.</p>
<pre><code>from time import gmtime, strftime
print strftime("%z", gmtime())
</code></pre>
<p>Pacific Standard Time</p>
| 4 | 2009-07-10T18:04:15Z | [
"python",
"datetime"
] |
Get time zone information of the system in Python? | 1,111,056 | <p>I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.</p>
| 26 | 2009-07-10T17:59:28Z | 1,111,110 | <p>That should work:</p>
<pre><code>import time
time.tzname
</code></pre>
<p>it returns a tuple of two strings: the first is the name of the local non-DST timezone, the second is the name of the local DST timezone.</p>
| 43 | 2009-07-10T18:09:09Z | [
"python",
"datetime"
] |
Get time zone information of the system in Python? | 1,111,056 | <p>I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.</p>
| 26 | 2009-07-10T17:59:28Z | 1,111,887 | <p>If you prefer UTC offsets over strings:</p>
<pre><code>time.timezone / -(60*60)
</code></pre>
| 4 | 2009-07-10T20:44:15Z | [
"python",
"datetime"
] |
Get time zone information of the system in Python? | 1,111,056 | <p>I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.</p>
| 26 | 2009-07-10T17:59:28Z | 10,854,983 | <p>Gives a UTC offset like in ThomasH's answer, but takes daylight savings into account.</p>
<pre><code>>>> import time
>>> offset = time.timezone if (time.localtime().tm_isdst == 0) else time.altzone
>>> offset / 60 / 60 * -1
-9
</code></pre>
<p>The value of <code>time.timezone</code> or <... | 19 | 2012-06-01T17:44:34Z | [
"python",
"datetime"
] |
Get time zone information of the system in Python? | 1,111,056 | <p>I want to get the default timezone (PST) of my system from Python. What's the best way to do that? I'd like to avoid forking another process.</p>
| 26 | 2009-07-10T17:59:28Z | 13,406,277 | <p>The code snippets for calculating offset are incorrect, see <a href="http://bugs.python.org/issue7229">http://bugs.python.org/issue7229</a>.</p>
<p>The correct way to handle this is:</p>
<pre><code>def local_time_offset(t=None):
"""Return offset of local zone from GMT, either at present or at time t."""
# ... | 10 | 2012-11-15T21:11:00Z | [
"python",
"datetime"
] |
How to build an Ecommerce Shopping Cart in Django? | 1,111,173 | <p>Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ?</p>
| 1 | 2009-07-10T18:22:48Z | 1,111,460 | <p>Satchmo project is a known open source shopping cart.<br />
<a href="http://www.satchmoproject.com/" rel="nofollow">http://www.satchmoproject.com/</a></p>
| 5 | 2009-07-10T19:17:46Z | [
"python",
"django",
"shopping-cart"
] |
How to build an Ecommerce Shopping Cart in Django? | 1,111,173 | <p>Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ?</p>
| 1 | 2009-07-10T18:22:48Z | 1,111,510 | <p>Ingredients:</p>
<ul>
<li>one cup PayPal (or subsitute with other equivalent payment system)</li>
<li>few cups html</li>
<li>add css to taste</li>
<li>add django if desired</li>
</ul>
<p>Cooking:</p>
<ul>
<li>Mix well.</li>
<li>Bake for 1-2 month.</li>
</ul>
<p>Release as open source :-) </p>
| 2 | 2009-07-10T19:27:35Z | [
"python",
"django",
"shopping-cart"
] |
How to build an Ecommerce Shopping Cart in Django? | 1,111,173 | <p>Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ?</p>
| 1 | 2009-07-10T18:22:48Z | 1,111,525 | <p>There's a book coming out that talks about just that. See here:</p>
<p><a href="http://www.apress.com/book/view/9781430225355">http://www.apress.com/book/view/9781430225355</a></p>
| 7 | 2009-07-10T19:29:44Z | [
"python",
"django",
"shopping-cart"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,111,278 | <p>PHP's memory management issues are overlooked because it's a language designed for the web, where long lasting processes aren't a problem.</p>
<p>This is the main reason I never favor PHP.</p>
| -4 | 2009-07-10T18:42:51Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,111,391 | <p>Whatever language you know better. I think this should be the first criterion.</p>
| 5 | 2009-07-10T19:03:24Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,111,393 | <p>I don't think you'll get a good answer to this one. Everyone uses php, and python ecommerce is probably mainly in-house built. If there was a popular python solution (something like django for web platforms) - then I doubt there would be any discussion.</p>
<p>However - as of now I have yet to see a good all-in one... | 2 | 2009-07-10T19:03:53Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,111,394 | <p>I'd think that the overall implementation of any solution you choose (whether off-the-shelf or custom built) will be more important than any inherent speed differences between Python and PHP.</p>
<p>There are some truly shocking examples out there so it's worth doing research based upon your exact requirements. A s... | 2 | 2009-07-10T19:04:02Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,111,400 | <p>I would say that PHP carts are probably more mature and have more features than the Django ones. (Note I've only had experience with 2 PHP shopping carts and no Python ones)</p>
<p>On the other hand, PHP is a poorly designed language and is usually slower than Python in benchmarks. Depending on your needs, a Python... | 1 | 2009-07-10T19:04:26Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,112,457 | <p>I'm personally a fan of Python, specificity with Django for the web. For ecommerce applications there is the <a href="http://www.satchmoproject.com/" rel="nofollow">Satchmo Project</a>.</p>
| 4 | 2009-07-10T23:43:55Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 1,112,465 | <p>Honestly, the languages don't really matter. </p>
<p>Both PHP and Python are capable to develop great websites and there are many examples for that.</p>
| 4 | 2009-07-10T23:46:55Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 2,787,433 | <p>This is a challenging question to answer. If you are going for an off the-shelf package you're going to need to use PHP - this then gives you a range of packages including Magento, osCommerce (yuck) and so on.</p>
<p>If you are planning to develop a bespoke, or partially bespoke solution, then you probably want to... | 2 | 2010-05-07T09:13:35Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 9,123,535 | <p>More important than the language is the developer's ability to translate business logic into elegant and maintainable code. But I <i>would</i> recommend building with an MVC framework in whatever language you choose. Both PHP and Python have options there (django, CakePHP are popular choices).</p>
| 1 | 2012-02-03T04:06:07Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
How do Python and PHP compare for ecommerce? | 1,111,207 | <p>If I were to start an ecommerce store, which language would you suggest I start with? Python or PHP?</p>
<p>And would it be wise to use Python for an ecommerce site in favor of PHP? PHP has lots of shopping carts, both open source and commercial. </p>
<p>Is Python the future of Web Development ?</p>
<p>Edit:</... | 5 | 2009-07-10T18:28:39Z | 38,287,718 | <p>I prefer php since its rapidly used for web application and continuously developed by a very large community. Also when you are in php you have to less worry about server, URL etc stuff how works. So you can dig into deep of developments. And finally now php 7 comes out and itâs vast stable then previous with OOP.... | 0 | 2016-07-10T01:12:23Z | [
"php",
"python",
"django",
"e-commerce",
"turbogears"
] |
@staticmethod gives SyntaxError: invalid syntax | 1,111,227 | <p>I have been using a python script for a long while and all of sudden it gives me:</p>
<pre><code> File "youtube-dl.py", line 103
@staticmethod
^
SyntaxError: invalid syntax
</code></pre>
<p>If you want to see the script, its right here: <a href="http://bitbucket.org/rg3/youtube-dl/raw/2009.06.29/youtube-d... | 1 | 2009-07-10T18:31:40Z | 1,111,235 | <p>You might be using an old Python version that didn't support <a href="http://www.python.org/dev/peps/pep-0318/" rel="nofollow">decorators</a> yet.</p>
| 4 | 2009-07-10T18:33:43Z | [
"python"
] |
Problem loading a specific website through Qt Webkit | 1,111,267 | <p>I am currently using the following PyQt code to create a simple browser:</p>
<pre><code>import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.robeez.com"))
web.show()
sys.exit(app.exec_())
</code></pre>
... | 0 | 2009-07-10T18:40:37Z | 1,111,422 | <p>try <a href="http://code.google.com/p/arora/" rel="nofollow">arora</a> (a very simple wrapping on top of QtWebKit); if it works, its your code. if it doesn't, its the website.</p>
| 0 | 2009-07-10T19:09:29Z | [
"python",
"webkit",
"pyqt",
"qtwebkit"
] |
Problem loading a specific website through Qt Webkit | 1,111,267 | <p>I am currently using the following PyQt code to create a simple browser:</p>
<pre><code>import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.robeez.com"))
web.show()
sys.exit(app.exec_())
</code></pre>
... | 0 | 2009-07-10T18:40:37Z | 1,201,076 | <p>For some reason <a href="http://www.robeeez.com" rel="nofollow">http://www.robeeez.com</a> which I think redirects to rebeez.com DOES work.
In some cases rebeez.com sends out a blank index.html page, dillo and wget also receive
nothing as does the qt45 demo browser. So is it the browser or the way the site is set u... | 0 | 2009-07-29T15:23:14Z | [
"python",
"webkit",
"pyqt",
"qtwebkit"
] |
Problem loading a specific website through Qt Webkit | 1,111,267 | <p>I am currently using the following PyQt code to create a simple browser:</p>
<pre><code>import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("http://www.robeez.com"))
web.show()
sys.exit(app.exec_())
</code></pre>
... | 0 | 2009-07-10T18:40:37Z | 1,503,085 | <p>Try sending the Accept-Language header also, it then works for me.</p>
| 0 | 2009-10-01T10:15:59Z | [
"python",
"webkit",
"pyqt",
"qtwebkit"
] |
How do I print a Python datetime in the local timezone? | 1,111,317 | <p>Let's say I have a variable t that's set to this:</p>
<pre><code>datetime.datetime(2009, 7, 10, 18, 44, 59, 193982, tzinfo=<UTC>)
</code></pre>
<p>If I say <code>str(t)</code>, i get:</p>
<pre><code>'2009-07-10 18:44:59.193982+00:00'
</code></pre>
<p>How can I get a similar string, except printed in the lo... | 10 | 2009-07-10T18:50:59Z | 1,111,345 | <p>Think your should look around: datetime.astimezone()</p>
<p><strong><a href="http://docs.python.org/library/datetime.html#datetime.datetime.astimezone">http://docs.python.org/library/datetime.html#datetime.datetime.astimezone</a></strong></p>
<p>Also see pytz module - it's quite easy to use -- as example:</p>
<pr... | 12 | 2009-07-10T18:54:42Z | [
"python",
"timezone"
] |
How do I print a Python datetime in the local timezone? | 1,111,317 | <p>Let's say I have a variable t that's set to this:</p>
<pre><code>datetime.datetime(2009, 7, 10, 18, 44, 59, 193982, tzinfo=<UTC>)
</code></pre>
<p>If I say <code>str(t)</code>, i get:</p>
<pre><code>'2009-07-10 18:44:59.193982+00:00'
</code></pre>
<p>How can I get a similar string, except printed in the lo... | 10 | 2009-07-10T18:50:59Z | 1,111,655 | <p>I wrote something like this the other day:</p>
<pre><code>import time, datetime
def nowString():
# we want something like '2007-10-18 14:00+0100'
mytz="%+4.4d" % (time.timezone / -(60*60) * 100) # time.timezone counts westwards!
dt = datetime.datetime.now()
dts = dt.strftime('%Y-%m-%d %H:%M') # %Z... | 0 | 2009-07-10T19:57:17Z | [
"python",
"timezone"
] |
How do I print a Python datetime in the local timezone? | 1,111,317 | <p>Let's say I have a variable t that's set to this:</p>
<pre><code>datetime.datetime(2009, 7, 10, 18, 44, 59, 193982, tzinfo=<UTC>)
</code></pre>
<p>If I say <code>str(t)</code>, i get:</p>
<pre><code>'2009-07-10 18:44:59.193982+00:00'
</code></pre>
<p>How can I get a similar string, except printed in the lo... | 10 | 2009-07-10T18:50:59Z | 2,071,364 | <p>I believe the best way to do this is to use the <code>LocalTimezone</code> class defined in the <code>datetime.tzinfo</code> documentation (goto <a href="http://docs.python.org/library/datetime.html#tzinfo-objects">http://docs.python.org/library/datetime.html#tzinfo-objects</a> and scroll down to the "Example tzinfo... | 8 | 2010-01-15T12:23:54Z | [
"python",
"timezone"
] |
How do I print a Python datetime in the local timezone? | 1,111,317 | <p>Let's say I have a variable t that's set to this:</p>
<pre><code>datetime.datetime(2009, 7, 10, 18, 44, 59, 193982, tzinfo=<UTC>)
</code></pre>
<p>If I say <code>str(t)</code>, i get:</p>
<pre><code>'2009-07-10 18:44:59.193982+00:00'
</code></pre>
<p>How can I get a similar string, except printed in the lo... | 10 | 2009-07-10T18:50:59Z | 18,647,007 | <p><a href="http://stackoverflow.com/a/18646797/2697658">This answer</a> shows a simple way to use <a href="http://docs.python.org/2/library/datetime.html#datetime.datetime.astimezone" rel="nofollow">astimezone</a>.</p>
| 0 | 2013-09-05T22:33:22Z | [
"python",
"timezone"
] |
How do I print a Python datetime in the local timezone? | 1,111,317 | <p>Let's say I have a variable t that's set to this:</p>
<pre><code>datetime.datetime(2009, 7, 10, 18, 44, 59, 193982, tzinfo=<UTC>)
</code></pre>
<p>If I say <code>str(t)</code>, i get:</p>
<pre><code>'2009-07-10 18:44:59.193982+00:00'
</code></pre>
<p>How can I get a similar string, except printed in the lo... | 10 | 2009-07-10T18:50:59Z | 18,812,308 | <p>I use this function <code>datetime_to_local_timezone()</code>, which seems overly convoluted but I found no simpler version of a function that converts a <code>datetime</code> instance to the local time zone, as configured in the <em>operating system</em>, with the UTC offset that was in effect <em>at that time</em>... | 0 | 2013-09-15T12:21:39Z | [
"python",
"timezone"
] |
Is there anything like HTTP::Recorder for Python? | 1,111,356 | <p>I really like Perl's <a href="http://search.cpan.org/~leira/HTTP-Recorder-0.05/" rel="nofollow">HTTP::Recorder</a>. Is there something like it for Python?</p>
| 2 | 2009-07-10T18:56:40Z | 1,111,469 | <p>I'm aware of Scotch and FunkLoad, but I don't know how they compare with HTTP::Recorder. See the following links for more details:</p>
<ul>
<li><p><a href="http://darcs.idyll.org/~t/projects/scotch/doc/" rel="nofollow">http://darcs.idyll.org/~t/projects/scotch/doc/</a></p>
<ul>
<li>also see the subsection "Other ... | 4 | 2009-07-10T19:19:20Z | [
"python",
"http",
"proxy",
"record"
] |
Is it really OK to do object closeing/disposing in __del__? | 1,111,505 | <p>I have been thinking about how I write classes in Python. More specifically how the constructor is implemented and how the object should be destroyed. I don't want to rely on CPython's reference counting to do object cleanup. This basically tells me I should use with statements to manage my object life times and tha... | 7 | 2009-07-10T19:26:49Z | 1,111,564 | <p>Not necessarily. You'll encounter problems when you have cyclic references. Eli Bendersky does a good job of explaining this in his blog post:</p>
<ul>
<li><a href="http://eli.thegreenplace.net/2009/06/12/safely-using-destructors-in-python/">Safely using destructors in Python</a></li>
</ul>
| 8 | 2009-07-10T19:37:47Z | [
"python"
] |
Is it really OK to do object closeing/disposing in __del__? | 1,111,505 | <p>I have been thinking about how I write classes in Python. More specifically how the constructor is implemented and how the object should be destroyed. I don't want to rely on CPython's reference counting to do object cleanup. This basically tells me I should use with statements to manage my object life times and tha... | 7 | 2009-07-10T19:26:49Z | 1,112,052 | <p>If you are sure you will not go into cyclic references, then using <code>__del__</code> in that way is OK: as soon as the reference count goes to zero, the CPython VM will call that method and destroy the object. </p>
<p>If you plan to use cyclic references - please think it very thoroughly, and check if weak refe... | 0 | 2009-07-10T21:21:52Z | [
"python"
] |
Is it really OK to do object closeing/disposing in __del__? | 1,111,505 | <p>I have been thinking about how I write classes in Python. More specifically how the constructor is implemented and how the object should be destroyed. I don't want to rely on CPython's reference counting to do object cleanup. This basically tells me I should use with statements to manage my object life times and tha... | 7 | 2009-07-10T19:26:49Z | 1,113,173 | <p>Short answer : No.</p>
<p>Long answer: Using <code>__del__</code> is tricky, mainly because it's not guaranteed to be called. That means you can't do things there that absolutely has to be done. This in turn means that <code>__del__</code> basically only can be used for cleanups that would happen sooner or later an... | 10 | 2009-07-11T07:38:25Z | [
"python"
] |
Why is BeautifulSoup throwing this HTMLParseError? | 1,111,656 | <p>I thought BeautifulSoup will be able to handle malformed documents, but when I sent it the source of a page, the following traceback got printed:</p>
<pre><code>
Traceback (most recent call last):
File "mx.py", line 7, in
s = BeautifulSoup(content)
File "build\bdist.win32\egg\BeautifulSoup.py", line 1499, ... | 1 | 2009-07-10T19:57:17Z | 1,111,787 | <p>In my experience BeautifulSoup isn't that fault tolerant. I had to use it once for a small script and ran into these problems. I think using a regular expression to strip out the tags helped a bit, but I eventually just gave up and moved the script over to Ruby and Nokogiri.</p>
| 1 | 2009-07-10T20:25:16Z | [
"python",
"exception",
"parsing",
"beautifulsoup",
"malformed"
] |
Why is BeautifulSoup throwing this HTMLParseError? | 1,111,656 | <p>I thought BeautifulSoup will be able to handle malformed documents, but when I sent it the source of a page, the following traceback got printed:</p>
<pre><code>
Traceback (most recent call last):
File "mx.py", line 7, in
s = BeautifulSoup(content)
File "build\bdist.win32\egg\BeautifulSoup.py", line 1499, ... | 1 | 2009-07-10T19:57:17Z | 1,112,480 | <p>Worked fine for me using BeautifulSoup version 3.0.7. The latest is 3.1.0, but there's a note on the BeautifulSoup home page to try 3.0.7a if you're having trouble. I think I ran into a similar problem as yours some time ago and reverted, which fixed the problem; I'd try that. </p>
<p>If you want to stick with y... | 5 | 2009-07-10T23:52:26Z | [
"python",
"exception",
"parsing",
"beautifulsoup",
"malformed"
] |
Why is BeautifulSoup throwing this HTMLParseError? | 1,111,656 | <p>I thought BeautifulSoup will be able to handle malformed documents, but when I sent it the source of a page, the following traceback got printed:</p>
<pre><code>
Traceback (most recent call last):
File "mx.py", line 7, in
s = BeautifulSoup(content)
File "build\bdist.win32\egg\BeautifulSoup.py", line 1499, ... | 1 | 2009-07-10T19:57:17Z | 1,112,713 | <p>The problem appears to be the<br />
<code>contents = contents.replace(/</g, '&lt;');</code><br />
in line 258 plus the similar<br />
<code>contents = contents.replace(/>/g, '&gt;');</code><br />
in the next line.</p>
<p>I'd just use re.sub to clobber all occurrences of r"replace(/[<>]/" with some... | 1 | 2009-07-11T01:51:12Z | [
"python",
"exception",
"parsing",
"beautifulsoup",
"malformed"
] |
Replace URL with a link using regex in python | 1,112,012 | <p>how do I convert some text to a link? Back in PHP, I used this piece of code that worked well for my purpose:</p>
<pre><code> $text = preg_replace("#(^|[\n ])(([\w]+?://[\w\#$%&~.\-;:=,?@\[\]+]*)(/[\w\#$%&~/.\-;:=,?@\[\]+]*)?)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\3</a>", $text... | 3 | 2009-07-10T21:12:32Z | 1,112,670 | <p>The code below is a simple translation to python. You should confirm that it actually does what you want. For more information, please see the <a href="http://www.amk.ca/python/howto/regex/regex.html" rel="nofollow">Python Regular Expression HOWTO</a>.</p>
<pre><code>import re
pat1 = re.compile(r"(^|[\n ])(([\w]... | 5 | 2009-07-11T01:28:11Z | [
"python",
"regex",
"url",
"hyperlink"
] |
Accessing Clipboard in Python version 3.1 | 1,112,057 | <p>I want to access the clipboard using Python 3.1. I've obviously come across win32clipboard, but it requires pywin32 and in its site I only found download versions for up to Python 2.13 or so.</p>
<p>Bottom line: Is there a way to access the clipboard in Python 3.1 or do I have to revert to an old Python version?</p... | 0 | 2009-07-10T21:23:36Z | 1,112,081 | <p>No you don't need to revert, it will be quite strange. Go to <strong><a href="http://sourceforge.net/projects/pywin32/files/" rel="nofollow">http://sourceforge.net/projects/pywin32/files/</a></strong> and download package for Python 3.1 from there.</p>
| 1 | 2009-07-10T21:29:04Z | [
"python",
"clipboard"
] |
What are the different possible values for __name__ in a Python script, and what do they mean? | 1,112,198 | <p>Checking to see if <code>__name__ == '__main__'</code> is a common idiom to run some code when the file is being called directly, rather than through a module.</p>
<p>In the process of writing a custom command for Django's manage.py, I found myself needing to use <code>code.InteractiveConsole</code>, which gives th... | 6 | 2009-07-10T21:59:09Z | 1,112,223 | <p><code>__name__</code> is usually the module name, but it's changed to <code>'__main__'</code> when the module in question is executed directly instead of being imported by another one.</p>
<p>I understand that other values can only be set directly by the code you're running.</p>
| 4 | 2009-07-10T22:04:25Z | [
"python"
] |
What are the different possible values for __name__ in a Python script, and what do they mean? | 1,112,198 | <p>Checking to see if <code>__name__ == '__main__'</code> is a common idiom to run some code when the file is being called directly, rather than through a module.</p>
<p>In the process of writing a custom command for Django's manage.py, I found myself needing to use <code>code.InteractiveConsole</code>, which gives th... | 6 | 2009-07-10T21:59:09Z | 1,112,293 | <p>from the <a href="http://docs.python.org/library/code.html#code.InteractiveInterpreter">document</a> of class code.InteractiveInterpreter([locals]):<br />
The optional locals argument specifies the dictionary in which code will be executed; it defaults to a newly created dictionary with key <code>'__name__'</code> s... | 6 | 2009-07-10T22:30:21Z | [
"python"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 1,112,350 | <p>Register your handler with <code>signal.signal</code> like this:</p>
<pre><code>#!/usr/bin/env python
import signal
import sys
def signal_handler(signal, frame):
print('You pressed Ctrl+C!')
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
print('Press Ctrl+C')
signal.pause()
</code></pre>
... | 405 | 2009-07-10T22:52:48Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 1,112,352 | <p>You can handle Ctrl-C by catching the <code>KeyboardInterrupt</code> exception. You can implement any clean-up code in the exception handler.</p>
| 18 | 2009-07-10T22:52:51Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 1,112,357 | <p>You can treat it like an exception (KeyboardInterrupt), like any other. Make a new file and run it from your shell with the following contents to see what I mean:</p>
<pre><code>import time, sys
x = 1
while True:
try:
print x
time.sleep(.3)
x += 1
except KeyboardInterrupt:
p... | 110 | 2009-07-10T22:54:24Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 1,112,360 | <p>You can use the functions in Python's built-in <a href="http://docs.python.org/library/signal.html" rel="nofollow">signal module</a> to set up signal handlers in python. Specifically the <code>signal.signal(signalnum, handler)</code> function is used to register the <code>handler</code> function for signal <code>sig... | 3 | 2009-07-10T22:54:43Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 1,112,363 | <p>From Python's <a href="http://docs.python.org/library/signal.html">documentation</a>:</p>
<pre class="lang-py prettyprint-override"><code>import signal
import time
def handler(signum, frame):
print 'Here you go'
signal.signal(signal.SIGINT, handler)
time.sleep(10) # Press Ctrl+c here
</code></pre>
| 14 | 2009-07-10T22:56:19Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 10,972,804 | <p>And as a context manager:</p>
<pre><code>import signal
class GracefulInterruptHandler(object):
def __init__(self, sig=signal.SIGINT):
self.sig = sig
def __enter__(self):
self.interrupted = False
self.released = False
self.original_handler = signal.getsignal(self.sig)
... | 34 | 2012-06-10T22:23:26Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 32,025,948 | <h1>Yet Another Snippet</h1>
<p>Referred <code>main</code> as the main function and <code>exit_gracefully</code> as the <kbd>CTRL</kbd> + <kbd>c</kbd> handler</p>
<pre><code>if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
pass
finally:
exit_gracefully()
</code></pr... | 4 | 2015-08-15T15:00:27Z | [
"python",
"control",
"signals"
] |
How do I capture SIGINT in Python? | 1,112,343 | <p>I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a <kbd>Ctrl</kbd>+<kbd>C</kbd> signal, and I'd like to do some cleanup.</p>
<p>In Perl I'd do this:</p>
<pre class="lang-perl prettyprint-override"><code>$SIG{'INT'} = 'exit_grac... | 286 | 2009-07-10T22:49:21Z | 35,798,485 | <p>I adapted the code from @udi to support multiple signals (nothing fancy) :</p>
<pre><code>class GracefulInterruptHandler(object):
def __init__(self, signals=(signal.SIGINT, signal.SIGTERM)):
self.signals = signals
self.original_handlers = {}
def __enter__(self):
self.interrupted = F... | 0 | 2016-03-04T14:27:35Z | [
"python",
"control",
"signals"
] |
Perl equivalent of (Python-) list comprehension | 1,112,444 | <p>I'm looking for ways to express this Python snippet in Perl:</p>
<pre><code>data = {"A": None, "B": "yes", "C": None}
key_list = [k for k in data if data[k]]
# in this case the same as filter(lambda k: data[k], data) but let's ignore that
</code></pre>
<p>So looking at it one way, I just want the keys where the ... | 13 | 2009-07-10T23:39:07Z | 1,112,455 | <p>Use <a href="http://perldoc.perl.org/functions/grep.html">grep</a>:</p>
<pre><code>#!/usr/bin/perl
use strict;
use warnings;
my %data = ("A" => 0, "B" => "yes", "C" => 0 );
my @keys = grep { $data{$_} } keys %data;
</code></pre>
<p>Grep returns the values from the list on the right-hand side for which t... | 13 | 2009-07-10T23:42:52Z | [
"python",
"perl",
"list-comprehension"
] |
Perl equivalent of (Python-) list comprehension | 1,112,444 | <p>I'm looking for ways to express this Python snippet in Perl:</p>
<pre><code>data = {"A": None, "B": "yes", "C": None}
key_list = [k for k in data if data[k]]
# in this case the same as filter(lambda k: data[k], data) but let's ignore that
</code></pre>
<p>So looking at it one way, I just want the keys where the ... | 13 | 2009-07-10T23:39:07Z | 1,112,462 | <p>I think you want <a href="http://perldoc.perl.org/functions/grep.html"><code>grep</code></a>:</p>
<pre><code>#!/usr/bin/env perl
use strict;
use warnings;
my %data = ( A => undef, B => 'yes', C => undef );
my @keys = grep { defined $data{$_} } keys %data;
print "Key: $_\n" for @keys;
</code></pre>
<p>I... | 21 | 2009-07-10T23:46:05Z | [
"python",
"perl",
"list-comprehension"
] |
Perl equivalent of (Python-) list comprehension | 1,112,444 | <p>I'm looking for ways to express this Python snippet in Perl:</p>
<pre><code>data = {"A": None, "B": "yes", "C": None}
key_list = [k for k in data if data[k]]
# in this case the same as filter(lambda k: data[k], data) but let's ignore that
</code></pre>
<p>So looking at it one way, I just want the keys where the ... | 13 | 2009-07-10T23:39:07Z | 1,113,675 | <p>For variation on the theme have a look at <a href="http://search.cpan.org/dist/autobox/">autobox</a> (see its implementations <a href="http://search.cpan.org/dist/autobox-Core/">autobox::Core</a> and <a href="http://search.cpan.org/dist/Moose-Autobox/">Moose::Autobox</a> )</p>
<pre><code>use autobox::Core;
my %da... | 6 | 2009-07-11T13:03:46Z | [
"python",
"perl",
"list-comprehension"
] |
os.path.basename works with URLs, why? | 1,112,545 | <pre><code>>>> os.path.basename('http://example.com/file.txt')
'file.txt'
</code></pre>
<p>.. and I thought <code>os.path.*</code> work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.</p>
| 6 | 2009-07-11T00:16:17Z | 1,112,556 | <p>On windows, look at the source code: C:\Python25\Lib\ntpath.py</p>
<pre><code>def basename(p):
"""Returns the final component of a pathname"""
return split(p)[1]
</code></pre>
<p>os.path.split (in the same file) just split "\" (and sth. else)</p>
| 3 | 2009-07-11T00:19:59Z | [
"python",
"url",
"path"
] |
os.path.basename works with URLs, why? | 1,112,545 | <pre><code>>>> os.path.basename('http://example.com/file.txt')
'file.txt'
</code></pre>
<p>.. and I thought <code>os.path.*</code> work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.</p>
| 6 | 2009-07-11T00:16:17Z | 1,112,557 | <p>Use the source Luke:</p>
<pre><code>
def basename(p):
"""Returns the final component of a pathname"""
i = p.rfind('/') + 1
return p[i:]
</code></pre>
<p><strong>Edit (response to clarification):</strong></p>
<p>It works for URLs by accident, that's it. Because of that, exploiting its behaviour could b... | 2 | 2009-07-11T00:20:40Z | [
"python",
"url",
"path"
] |
os.path.basename works with URLs, why? | 1,112,545 | <pre><code>>>> os.path.basename('http://example.com/file.txt')
'file.txt'
</code></pre>
<p>.. and I thought <code>os.path.*</code> work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.</p>
| 6 | 2009-07-11T00:16:17Z | 1,112,575 | <p>Why? Because it's useful for parsing URLs as well as local file paths. Why not?</p>
| 0 | 2009-07-11T00:29:58Z | [
"python",
"url",
"path"
] |
os.path.basename works with URLs, why? | 1,112,545 | <pre><code>>>> os.path.basename('http://example.com/file.txt')
'file.txt'
</code></pre>
<p>.. and I thought <code>os.path.*</code> work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.</p>
| 6 | 2009-07-11T00:16:17Z | 1,112,701 | <p>In practice many functions of <code>os.path</code> are just string manipulation functions (which just <em>happen</em> to be especially handy for path manipulation) -- and since that's innocuous and occasionally handy, while formally speaking "incorrect", I doubt this will change anytime soon -- for more details, use... | 12 | 2009-07-11T01:45:00Z | [
"python",
"url",
"path"
] |
os.path.basename works with URLs, why? | 1,112,545 | <pre><code>>>> os.path.basename('http://example.com/file.txt')
'file.txt'
</code></pre>
<p>.. and I thought <code>os.path.*</code> work only on local paths and not URLs? Note that the above example was run on Windows too .. with similar result.</p>
| 6 | 2009-07-11T00:16:17Z | 35,088,278 | <p>Forward slash is also an acceptable path delimiter in Windows.</p>
<p>It is merely that the command line does not accept paths that begin with a / because that character is reserved for args switches.</p>
| 1 | 2016-01-29T15:37:15Z | [
"python",
"url",
"path"
] |
Import python package from local directory into interpreter | 1,112,618 | <p>I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in <code>sys.path.insert(0,'.')</code>. Is there a better way? </p>
<p>Also, </p>
<pre><code>from . import mypackage
</code></pre>
<p>fails w... | 36 | 2009-07-11T00:57:52Z | 1,112,623 | <p>Using <code>sys.path</code> should include current directory already.</p>
<p>Try:</p>
<pre><code>import .
</code></pre>
<p>or:</p>
<pre><code>from . import sth
</code></pre>
<p>however it may be not a good practice, so why not just use:</p>
<pre><code>import mypackage
</code></pre>
| 1 | 2009-07-11T01:00:51Z | [
"python"
] |
Import python package from local directory into interpreter | 1,112,618 | <p>I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in <code>sys.path.insert(0,'.')</code>. Is there a better way? </p>
<p>Also, </p>
<pre><code>from . import mypackage
</code></pre>
<p>fails w... | 36 | 2009-07-11T00:57:52Z | 1,112,654 | <p>See the documentation for sys.path:</p>
<p><a href="http://docs.python.org/library/sys.html#sys.path">http://docs.python.org/library/sys.html#sys.path</a></p>
<p>To quote:</p>
<blockquote>
<p>If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from... | 9 | 2009-07-11T01:23:31Z | [
"python"
] |
Import python package from local directory into interpreter | 1,112,618 | <p>I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in <code>sys.path.insert(0,'.')</code>. Is there a better way? </p>
<p>Also, </p>
<pre><code>from . import mypackage
</code></pre>
<p>fails w... | 36 | 2009-07-11T00:57:52Z | 1,112,661 | <p>You can use relative imports only from in a module that was in turn imported as part of a package -- your script or interactive interpreter wasn't, so of course <code>from . import</code> (which means "import from the same package I got imported from") doesn't work. <code>import mypackage</code> will be fine once yo... | 20 | 2009-07-11T01:24:47Z | [
"python"
] |
Import python package from local directory into interpreter | 1,112,618 | <p>I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in <code>sys.path.insert(0,'.')</code>. Is there a better way? </p>
<p>Also, </p>
<pre><code>from . import mypackage
</code></pre>
<p>fails w... | 36 | 2009-07-11T00:57:52Z | 2,204,578 | <p>A simple way to make it work is to run your script from the parent directory using python's <code>-m</code> flag, e.g. <code>python -m packagename.scriptname</code>. Obviously in this situation you need an <code>__init__.py</code> file to turn your directory into a package.</p>
| 3 | 2010-02-05T01:52:44Z | [
"python"
] |
Import python package from local directory into interpreter | 1,112,618 | <p>I'm developing/testing a package in my local directory. I want to import it in the interpreter (v2.5), but sys.path does not include the current directory. Right now I type in <code>sys.path.insert(0,'.')</code>. Is there a better way? </p>
<p>Also, </p>
<pre><code>from . import mypackage
</code></pre>
<p>fails w... | 36 | 2009-07-11T00:57:52Z | 22,091,228 | <p>Keep it simple:</p>
<pre><code> try:
from . import mymodule # "myapp" case
except:
import mymodule # "__main__" case
</code></pre>
| 2 | 2014-02-28T09:33:52Z | [
"python"
] |
Where to put message queue consumer in Django? | 1,112,645 | <p>I'm using Carrot for a message queue in a Django project and followed <a href="http://github.com/ask/carrot/tree/master" rel="nofollow">the tutorial</a>, and it works fine. But the example runs in the console, and I'm wondering how I apply this in Django. The publisher class I'm calling from one of my models in mode... | 1 | 2009-07-11T01:15:39Z | 1,112,764 | <p>The consumer is simply a long running script in the example you cite from the tutorial. It pops a message from the queue, does something, then calls wait and essentially goes to sleep until another message comes in. </p>
<p>This script could just be running at the console under your account or configured as a uni... | 5 | 2009-07-11T02:16:28Z | [
"python",
"django",
"message-queue",
"rabbitmq",
"amqp"
] |
Where to put message queue consumer in Django? | 1,112,645 | <p>I'm using Carrot for a message queue in a Django project and followed <a href="http://github.com/ask/carrot/tree/master" rel="nofollow">the tutorial</a>, and it works fine. But the example runs in the console, and I'm wondering how I apply this in Django. The publisher class I'm calling from one of my models in mode... | 1 | 2009-07-11T01:15:39Z | 1,160,225 | <p>If what you are doing is processing tasks, please check out celery: <a href="http://github.com/ask/celery/" rel="nofollow">http://github.com/ask/celery/</a></p>
| 0 | 2009-07-21T16:17:45Z | [
"python",
"django",
"message-queue",
"rabbitmq",
"amqp"
] |
Safety of Python 'eval' For List Deserialization | 1,112,665 | <p>Are there any security exploits that could occur in this scenario:</p>
<pre><code>eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False})
</code></pre>
<p>where <code>unsanitized_user_input</code> is a str object. The string is user-generated and could be nasty. Assuming our web fr... | 6 | 2009-07-11T01:25:19Z | 1,112,684 | <p>It is indeed dangerous and the safest alternative is <code>ast.literal_eval</code> (see the <a href="http://docs.python.org/library/ast.html#module-ast" rel="nofollow">ast</a> module in the standard library). You can of course build and alter an <code>ast</code> to provide e.g. evaluation of variables and the like b... | 18 | 2009-07-11T01:33:02Z | [
"python",
"google-app-engine",
"eval"
] |
Safety of Python 'eval' For List Deserialization | 1,112,665 | <p>Are there any security exploits that could occur in this scenario:</p>
<pre><code>eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False})
</code></pre>
<p>where <code>unsanitized_user_input</code> is a str object. The string is user-generated and could be nasty. Assuming our web fr... | 6 | 2009-07-11T01:25:19Z | 1,112,692 | <p>Generally, you should never allow <strong>anyone</strong> to post code. </p>
<p>So called "paid professional programmers" have a hard-enough time writing code that actually works.</p>
<p>Accepting code from the anonymous public -- without benefit of formal QA -- is the worst of all possible scenarios.</p>
<p>Prof... | 3 | 2009-07-11T01:38:39Z | [
"python",
"google-app-engine",
"eval"
] |
Safety of Python 'eval' For List Deserialization | 1,112,665 | <p>Are there any security exploits that could occur in this scenario:</p>
<pre><code>eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False})
</code></pre>
<p>where <code>unsanitized_user_input</code> is a str object. The string is user-generated and could be nasty. Assuming our web fr... | 6 | 2009-07-11T01:25:19Z | 1,112,699 | <p>If you can prove beyond doubt that <code>unsanitized_user_input</code> is a <code>str</code> instance from the Python built-ins with nothing tampered, then this is always safe. In fact, it'll be safe even without all those extra arguments since <code>eval(repr(astr)) = astr</code> for all such string objects. You pu... | 8 | 2009-07-11T01:42:00Z | [
"python",
"google-app-engine",
"eval"
] |
Safety of Python 'eval' For List Deserialization | 1,112,665 | <p>Are there any security exploits that could occur in this scenario:</p>
<pre><code>eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False})
</code></pre>
<p>where <code>unsanitized_user_input</code> is a str object. The string is user-generated and could be nasty. Assuming our web fr... | 6 | 2009-07-11T01:25:19Z | 1,113,480 | <p>With everything as you describe, it is technically safe to eval repred strings, however, I'd avoid doing it anyway as it's asking for trouble:</p>
<ul>
<li><p>There could be some weird corner-case where your assumption that only repred strings are stored (eg. a bug / different pathway into the storage that doesn't ... | 4 | 2009-07-11T10:57:19Z | [
"python",
"google-app-engine",
"eval"
] |
Safety of Python 'eval' For List Deserialization | 1,112,665 | <p>Are there any security exploits that could occur in this scenario:</p>
<pre><code>eval(repr(unsanitized_user_input), {"__builtins__": None}, {"True":True, "False":False})
</code></pre>
<p>where <code>unsanitized_user_input</code> is a str object. The string is user-generated and could be nasty. Assuming our web fr... | 6 | 2009-07-11T01:25:19Z | 1,114,008 | <blockquote>
<pre><code>repr([unsanitized_user_input_1,
unsanitized_user_input_2,
...
</code></pre>
<p>... <code>unsanitized_user_input</code> is a <code>str</code> object</p>
</blockquote>
<p>You shouldn't have to serialise strings to store them in a database..</p>
<p>If these are all strings, as yo... | 1 | 2009-07-11T16:03:55Z | [
"python",
"google-app-engine",
"eval"
] |
Python Win32 Extensions not Available? | 1,112,784 | <p>I am trying to get a post-commit.bat script running on a Windows Vista Ultimate machine for Trac. </p>
<p>I have installed Trac and its working fine - but when I run this script I get the error:</p>
<p><strong>"The Python Win32 extensions for NT (service, event, logging) appear not to be Available."</strong></p>
... | 2 | 2009-07-11T02:38:20Z | 1,112,794 | <p>have u installed the <a href="http://sourceforge.net/projects/pywin32/files/">Python Win32 module</a>?</p>
| 5 | 2009-07-11T02:44:44Z | [
"python",
"trac"
] |
List of installed fonts OS X / C | 1,113,040 | <p>I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?</p>
| 4 | 2009-07-11T05:45:38Z | 1,113,055 | <p>Do you want to <em>write</em> a program to do it, or do you want to <em>use</em> a program to do it? There are many programs that list fonts, xlsfonts comes to mind.</p>
| 1 | 2009-07-11T05:54:14Z | [
"python",
"c",
"osx",
"fonts"
] |
List of installed fonts OS X / C | 1,113,040 | <p>I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?</p>
| 4 | 2009-07-11T05:45:38Z | 1,113,072 | <p>Not exactly C, but in Objective-C, you can easily get a list of installed fonts via the Cocoa framework:</p>
<pre><code>// This returns an array of NSStrings that gives you each font installed on the system
NSArray *fonts = [[NSFontManager sharedFontManager] availableFontFamilies];
// Does the same as the above, b... | 3 | 2009-07-11T06:12:55Z | [
"python",
"c",
"osx",
"fonts"
] |
List of installed fonts OS X / C | 1,113,040 | <p>I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?</p>
| 4 | 2009-07-11T05:45:38Z | 1,113,078 | <p>You can get an array of available fonts using Objective-C and Cocoa. The method you are looking for is <a href="http://devworld.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFontManager%5FClass/Reference/Reference.html#//apple%5Fref/occ/instm/NSFontManager/availableFonts" rel="nofollow"><code>NSFo... | 0 | 2009-07-11T06:18:03Z | [
"python",
"c",
"osx",
"fonts"
] |
List of installed fonts OS X / C | 1,113,040 | <p>I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?</p>
| 4 | 2009-07-11T05:45:38Z | 1,113,084 | <p>Why not use the Terminal?</p>
<p><strong>System Fonts:</strong></p>
<pre><code>ls -R /System/Library/Fonts | grep ttf
</code></pre>
<p><strong>User Fonts:</strong></p>
<pre><code>ls -R ~/Library/Fonts | grep ttf
</code></pre>
<p><strong>Mac OS X Default fonts:</strong></p>
<pre><code>ls -R /Library/Fonts | gre... | 3 | 2009-07-11T06:25:30Z | [
"python",
"c",
"osx",
"fonts"
] |
List of installed fonts OS X / C | 1,113,040 | <p>I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?</p>
| 4 | 2009-07-11T05:45:38Z | 1,113,150 | <p>Python with PyObjC installed (which is the case for Mac OS X 10.5+, so this code will work without having to install anything):</p>
<pre><code>import Cocoa
manager = Cocoa.NSFontManager.sharedFontManager()
font_families = list(manager.availableFontFamilies())
</code></pre>
<p>(based on <a href="#1113072">htw's ans... | 10 | 2009-07-11T07:23:45Z | [
"python",
"c",
"osx",
"fonts"
] |
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron? | 1,113,066 | <ol>
<li>App Engine allows you 30 seconds to load your application</li>
<li>My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.</li>
<li>If the app is idle (does not receive a request for a while), it needs to be re-loaded. </li>
</ol>
<p>So, to avoid the app needing ... | 3 | 2009-07-11T06:02:43Z | 1,113,110 | <p>I think what you want is just:</p>
<pre><code>import httplib
hcon = httplib.HTTPConnection("foo.appspot.com")
hcon.request("GET", "/someURL")
hcon.close()
</code></pre>
| 1 | 2009-07-11T06:44:31Z | [
"java",
"python",
"google-app-engine",
"httpwebrequest",
"keep-alive"
] |
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron? | 1,113,066 | <ol>
<li>App Engine allows you 30 seconds to load your application</li>
<li>My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.</li>
<li>If the app is idle (does not receive a request for a while), it needs to be re-loaded. </li>
</ol>
<p>So, to avoid the app needing ... | 3 | 2009-07-11T06:02:43Z | 1,113,300 | <p>the simplest Java http pinger:</p>
<pre><code>URLConnection hcon = new URL("http://www.google.com").openConnection();
hcon.connect();
hcon.getInputStream().read();
</code></pre>
| 1 | 2009-07-11T09:12:07Z | [
"java",
"python",
"google-app-engine",
"httpwebrequest",
"keep-alive"
] |
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron? | 1,113,066 | <ol>
<li>App Engine allows you 30 seconds to load your application</li>
<li>My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.</li>
<li>If the app is idle (does not receive a request for a while), it needs to be re-loaded. </li>
</ol>
<p>So, to avoid the app needing ... | 3 | 2009-07-11T06:02:43Z | 1,113,400 | <p>It would probably be easier use the <a href="http://code.google.com/appengine/docs/java/config/cron.html" rel="nofollow">cron built in to App Engine</a> to keep your application alive.</p>
| 1 | 2009-07-11T10:15:49Z | [
"java",
"python",
"google-app-engine",
"httpwebrequest",
"keep-alive"
] |
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron? | 1,113,066 | <ol>
<li>App Engine allows you 30 seconds to load your application</li>
<li>My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this.</li>
<li>If the app is idle (does not receive a request for a while), it needs to be re-loaded. </li>
</ol>
<p>So, to avoid the app needing ... | 3 | 2009-07-11T06:02:43Z | 4,707,002 | <p>App engine also has a new PAY feature where you can have it "always-on". Costs about $0.30 USD cents a day. Just go into your billing settings and enable it if you don't mind paying for the feature. I believe it guarantees you at least 3 instances always running.</p>
<p>(I didn't realize hitting a /ping url whic... | 1 | 2011-01-16T17:52:55Z | [
"java",
"python",
"google-app-engine",
"httpwebrequest",
"keep-alive"
] |
Pure Python Tidy-like application/library | 1,113,421 | <p>I'm looking for a pure Python library which works like Tidy. Please kindly advise. Thank you.</p>
| 4 | 2009-07-11T10:27:46Z | 1,113,488 | <p>Use <a href="http://effbot.org/zone/element-tidylib.htm" rel="nofollow">ElementTree Tidy HTML Tree Builder</a>.</p>
| 1 | 2009-07-11T10:59:59Z | [
"python",
"html",
"xml",
"xhtml",
"tidy"
] |
How can I match two songs? | 1,113,449 | <p>What is the best way to match two songs? IE. Have a song stored in the database in whatever format is best and then play another song and match the two together?<br />
In Python ideally please.</p>
<p>Thanks!</p>
| 2 | 2009-07-11T10:40:33Z | 1,113,483 | <p>I think you might be looking for something called <a href="http://en.wikipedia.org/wiki/Acoustic%5Ffingerprint" rel="nofollow">Acoustic Fingerprinting</a>. It generates a brief description of a song which can be compared against other songs. This allows the matching of audio which is similiar but not exactly the sam... | 4 | 2009-07-11T10:58:59Z | [
"python",
"algorithm",
"music",
"matching"
] |
How can I match two songs? | 1,113,449 | <p>What is the best way to match two songs? IE. Have a song stored in the database in whatever format is best and then play another song and match the two together?<br />
In Python ideally please.</p>
<p>Thanks!</p>
| 2 | 2009-07-11T10:40:33Z | 1,113,486 | <p>You can download the tarball from </p>
<p><a href="http://rudd-o.com/new-projects/python-audioprocessing" rel="nofollow">http://rudd-o.com/new-projects/python-audioprocessing</a></p>
<p>They say their goal is to identify the same songs released in different albums. Basically to avoid storing two-copies considered... | 3 | 2009-07-11T10:59:49Z | [
"python",
"algorithm",
"music",
"matching"
] |
How can I match two songs? | 1,113,449 | <p>What is the best way to match two songs? IE. Have a song stored in the database in whatever format is best and then play another song and match the two together?<br />
In Python ideally please.</p>
<p>Thanks!</p>
| 2 | 2009-07-11T10:40:33Z | 1,114,109 | <p>By 'matching' do you mean finding tracks that are identical - or do you mean 'beat matching' - to dovetail two songs together so that the beats align to give you a seamless song transition. If you are talking about the latter then check out remix. A python library for automatic remixing: <a href="http://code.goog... | 1 | 2009-07-11T16:49:36Z | [
"python",
"algorithm",
"music",
"matching"
] |
Where to store secret keys and password in Python | 1,113,479 | <p>I have a small Python program, which uses a Google Maps API secret key. I'm getting ready to check-in my code, and I don't want to include the secret key in SVN. </p>
<p>In the canonical PHP app you put secret keys, database passwords, and other app specific config in LocalSettings.php. Is there a similar file/l... | 3 | 2009-07-11T10:57:06Z | 1,113,496 | <p>No, there's no standard location - on Windows, it's usually in the directory <code>os.path.join(os.environ['APPDATA'], 'appname')</code> and on Unix it's usually <code>os.path.join(os.environ['HOME'], '.appname')</code>.</p>
| 3 | 2009-07-11T11:04:23Z | [
"python",
"configuration",
"google-maps"
] |
Where to store secret keys and password in Python | 1,113,479 | <p>I have a small Python program, which uses a Google Maps API secret key. I'm getting ready to check-in my code, and I don't want to include the secret key in SVN. </p>
<p>In the canonical PHP app you put secret keys, database passwords, and other app specific config in LocalSettings.php. Is there a similar file/l... | 3 | 2009-07-11T10:57:06Z | 1,113,506 | <p>A user must configure their own secret key. A configuration file is the perfect place to keep this information.</p>
<p>You several choices for configuration files.</p>
<ol>
<li><p>Use <a href="http://docs.python.org/library/configparser.html" rel="nofollow"><code>ConfigParser</code></a> to parse a config file.</p... | 3 | 2009-07-11T11:08:06Z | [
"python",
"configuration",
"google-maps"
] |
Where to store secret keys and password in Python | 1,113,479 | <p>I have a small Python program, which uses a Google Maps API secret key. I'm getting ready to check-in my code, and I don't want to include the secret key in SVN. </p>
<p>In the canonical PHP app you put secret keys, database passwords, and other app specific config in LocalSettings.php. Is there a similar file/l... | 3 | 2009-07-11T10:57:06Z | 1,113,642 | <p>Any path can reference the user's home directory in a cross-platform way by expanding the common ~ (tilde) with <code>os.path.expanduser()</code>, like so:</p>
<pre><code>appdir = os.path.join(os.path.expanduser('~'), '.myapp')
</code></pre>
| 1 | 2009-07-11T12:43:17Z | [
"python",
"configuration",
"google-maps"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,613 | <p>You can have code in the class definition in both Ruby and Python. However, in Ruby you have a reference to the class (self). In Python you don't have a reference to the class, as the class isn't defined yet.</p>
<p>An example:</p>
<pre><code>class Kaka
puts self
end
</code></pre>
<p>self in this case is the cl... | 5 | 2009-07-11T12:26:09Z | [
"python",
"ruby"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,624 | <p>Ruby has the concepts of <em>blocks</em>, which are essentially syntactic sugar around a section of code; they are a way to create closures and pass them to another method which may or may not use the block. A block can be invoked later on through a <code>yield</code> statement.</p>
<p>For example, a simple definit... | 34 | 2009-07-11T12:32:48Z | [
"python",
"ruby"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,713 | <p>Python has docstrings and ruby doesn't... Or if it doesn't, they are not accessible as easily as in python. </p>
<p>Ps. If im wrong, pretty please, leave an example? I have a workaround that i could monkeypatch into classes quite easily but i'd like to have docstring kinda of a feature in "native way".</p>
| 5 | 2009-07-11T13:24:40Z | [
"python",
"ruby"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,741 | <p>What Ruby has over Python are its scripting language capabilities. Scripting language in this context meaning to be used for "glue code" in shell scripts and general text manipulation.</p>
<p>These are mostly shared with Perl. First-class built-in regular expressions, $-Variables, useful command line options like P... | 12 | 2009-07-11T13:41:54Z | [
"python",
"ruby"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,765 | <p>While the functionalty is to a great extent the same (especially in the <a href="http://en.wikipedia.org/wiki/Turing%5Fcompleteness" rel="nofollow">Turing</a> sense), malicious tongues claim that Ruby was created for Pythonistas that could not split up with the Perlish coding style.</p>
| -4 | 2009-07-11T13:56:01Z | [
"python",
"ruby"
] |
What does Ruby have that Python doesn't, and vice versa? | 1,113,611 | <p>There is a lot of discussions of Python vs Ruby, and I all find them completely unhelpful, because they all turn around why feature X sucks in language Y, or that claim language Y doesn't have X, although in fact it does. I also know exactly why I prefer Python, but that's also subjective, and wouldn't help anybody ... | 264 | 2009-07-11T12:24:26Z | 1,113,875 | <p>I don't think "Ruby has X and Python doesn't, while Python has Y and Ruby doesn't" is the most useful way to look at it. They're quite similar languages, with many shared abilities. </p>
<p>To a large degree, the difference is what the language makes elegant and readable. To use an example you brought up, both do t... | 12 | 2009-07-11T14:52:21Z | [
"python",
"ruby"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.