text stringlengths 226 34.5k |
|---|
Python + Apache web pages not updating
Question: I have apache server with WSGI module for python pages.
I have index.wsgi file with str(datetime.datetime.now()) which print the
current timestamp.
The issue is when I am refreshing the page I cannot see it updates, it jumps
between seconds or something, looks like it... |
How to get data out of websocket autobahnpython
Question: Hi I'm using autobahnpython which connects to a websocket and retrieves the
data but I'm struggling to get the data out. Basically I want to use Queues to
send the data out to another consumer thread that works on the data itself.
The examples I found, only prin... |
python code to generate password list
Question: I am researching wireless security and trying to write a python script to
generate passwords, not random, but a dictionary of hex numbers. The letters
need to be capital, and it has to go from 12 characters to 20 characters. I
went from 11 f's to 20 f's, this seems like i... |
Python/Cassandra: insert vs. CSV import
Question: I am generating load test data in a Python script for Cassandra.
Is it better to insert directly into Cassandra from the script, or to write a
CSV file and then load that via Cassandra?
This is for a couple million rows.
Answer: For a few million, I'd say just use C... |
Python, How to use part of function outside function
Question: How can I use `today` and `returntime` in `return_fee` function?
import datetime
class Movie(object):
def __init__(self,title):
self.title = title
def time_of_return(self):
self.today = today
se... |
How to handle ssl connections in raw Python socket?
Question: I'm writing a program to download a given webpage. I need to only use raw
python sockets for all the connection due to some restriction. So I make a
socket connection to a given domain (the Host field in the response header of
an object) and then send the GE... |
how to make a recursive loop in python
Question: I'm trying to make a web scraper that can cycle though pages using
BeautifulSoup
To do this I am trying to write a function that makes a call to the page I'm
looking for, finds the Href of the next button prints the result, then assigns
it to the request and repeats the... |
installing mayavi with pip - Building TVTK classes...Assertion failed
Question: I've been trying to install mayavi in Yosemite. I've already installed the
Numpy, VTK, wxPython, and configobj. When I run `sudo pip install mayavi`, it
shows the following error msg:
Running setup.py install for mayavi
... |
Extracting only words from html pages
Question: I am using python 2.7 and I have a folder with a list of html pages from which
i would like to extract only the words from. Currently, the process that I am
using is open the html file, run it through beautiful soup library, get the
text and write it to a new file. But th... |
Issue while importing LoginManager from flask.ext.login
Question: I am trying get hands-on with flask-login extension. I am using virtualenv for
flask.
I could able to import LoginManager from flask.ext.login in the python
interpreter window, but not in the script. Below the import calls in the
script.
... |
Python: Have an iterator iterate over log messages on a different thread
Question: I have 2 threads running:
# Thread 1: In model
logging.getLogger('ui').info("Sit still, I'm computing...")
more_stuff = compute_stuff(stuff)
logging.info("Ok, I'm done.")
...
# Thread 2: In vi... |
mysql.connector.errors.ProgrammingError: Not all parameters were used in the SQL statement
Question: Following is my python script:
#!/usr/bin/env python
import mysql.connector
cnx = mysql.connector.connect(user='qdb1', password='qdb1', host='170.19.17.9', database='qdb1')
cursor = cnx... |
Cartopy: Can't add features to geo axes (no errors or warnings)
Question: I can't add features to cartopy geo axes. Here is an example from the
[gallery](http://scitools.org.uk/cartopy/docs/latest/examples/features.html):
import cartopy
import matplotlib.pyplot as plt
def main():
... |
using split() to split values in an entire column in a python dataframe
Question: I am trying to clean a list of url's that has garbage as shown.
1. /gradoffice/index.aspx(
2. /gradoffice/index.aspx-
3. /gradoffice/index.aspxjavascript$
4. /gradoffice/index.aspx~
I have a csv file with over 190k records of d... |
How do I update PyQt5?
Question: I have an apparently older version of PyQt5 installed on my Xubuntu (Voyager).
When I print the `PYQT_VERSION_STR`, it displays: `'5.2.1'`. I downloaded the
latest PyQt5 release form here:
<http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.4/> I configured it,
make and make instal... |
Scrapy blank AssertionError?
Question: The below code is throwing the following error for each request sent to the
parse method (Scrapy v0.24.4):
2014-12-30 01:20:06+0000 [yelp_spider] DEBUG: Crawled (200) <GET http://www.yelp.com/biz/lookout-tavern-oak-bluffs> (referer: http://www.yelp.com/search?find_d... |
Marking off checkboxes in a table that match a specific text
Question: I have a table (screenshot below) where I want to mark off the checkboxes that
have the text "Xatu Auto Test" in the same row using selenium python.
<http://i.imgur.com/31eDDkl.png>
I've tried following these two posts:
* [Iterating Through a T... |
wb = xlwings.Workbook() fails on mac
Question: I'm just tinkering with xlwings on a mac to write values to cells. However,
when I initialize a new workbook, I get this:
import xlwings as xl
wb = xl.Workbook()
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
F... |
Loading regular expression patterns from external source?
Question: I have a series of regular expression patterns defined for automated
processing of text. Due to the design of the program, it's better to have
these patterns separate in a text file, namely a JSON file. The pattern in
Python is of `r''` type, but all I... |
Interactive pixel information of an image in Python?
Question: **Short version:** is there a Python method for displaying an image which
shows, in real time, the pixel indices and intensities? So that as I move the
cursor over the image, I have a continually updated display such as
`pixel[103,214] = 198` (for grayscale... |
how to control the import paths in Python?
Question: I am new to Python. I am at a company where they built a large system in
Python. They use a proprietary system to manage the paths when the system is
running, but now I have been asked to build a standalone script that interacts
with some of the code in their system.... |
Python parse empty string
Question: I'm using the [`parse`](https://pypi.python.org/pypi/parse) library and ran
into surprising (to me) functionality: it does not match empty strings:
>>> from parse import parse
>>> parse('hi "{}"', 'hi "everybody"')
<Result ('everybody',) {}>
>>> parse('hi "... |
Pandas DataFrame Assignment Issue - Possible Bug?
Question: I am trying to write Python Pandas code to merge the data in two DataFrames,
with the new DataFrame's data replacing the old DataFrame's data if the index
and columns are identical. There seems to be a bug in Pandas that sometimes
causes the column names to be... |
Recording multiple videos to differing file names with Raspberry Pi Camera triggered by IR Sensor
Question: I am currently working on setting up my Raspberry Pi to (when triggered by an
IR sensor) record twenty second videos, each to a new file.
Currently it is returning this error when movement is detected:
"_Traceb... |
Python : "print" doesn't work
Question: I've recently got a bug in my pokemon battling bot program i've been writing
for some time, which i cannot explain at all.
The code is too long to fit well in a stack overflow question, so here's the
entire code in a pastebin.
<http://pastebin.com/h4V2DnXh>
In short, the code ... |
How to deal with globals in modules?
Question: I try to make a non blocking api calls for
[OpenWeatherMap](http://www.openweathermap.com/api), but my problem is:
When i was doing tests on the file, and run it, the `global api` was taking
effect, but when importing the function, `global` dont work anymore, and `api`
di... |
Python dictionary: set value as the key string
Question: I have a python dictionary and want to set one of the values as the key itself
whilst initializing the dict. That is:
dummy = dict(
Key1 = ["SomeValue1", "Key1"],
Key2 = ["SomeValue2", "Key2"],
)
Can this be done programmabl... |
Class inheritance from different modules python
Question: I'm new to python and I have a hard time trying to figuring out how can I
inherit from a class in an other module.
module: ~/foo.py
import bar
class foo:
def test(self)
print("this is a test")
module: ~/bar.py
... |
Cannot communicate with websocket. Autobahn: received HELLO message, and session is not yet established
Question: I am trying to build a WebSocket session using Python 3.4, Django, Autobahn
and JS. I have successfully run the websocket server on the python side, but i
cannot subscribe or receive any data published by t... |
Read data with NAs into python and calculate mean row-wise
Question: I am reading in data from a csvfile and attempt to calculate the mean
columnwise. While the number of columns is fixed, the number of rows isn't.
Therefore I first read in the rows I need, make them a list and then form a
numpy array of the list. But ... |
Same Python code returns different results for same input string
Question: Below code is supposed to return the most common letter in the TEXT string in
the format:
* always lowercase
* ignoring punctuation and spaces
* in the case of words such as "One" - where there is no 2 letters the same - return the first ... |
How to fix an encoding migrating Python subprocess to unicode_literals?
Question: We're preparing to move to Python 3.4 and added unicode_literals. Our code
relies extensively on piping to/from external utilities using subprocess
module. The following code snippet works fine on Python 2.7 to pipe UTF-8
strings to a sub... |
Python socket works over LAN but not over Wifi
Question: I have a simple UDP server implemented in python:
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("",10005))
while True:
data = sock.recv(1024)
I run this code on computer A. I se... |
splinter - strange ElementNotVisible exception for link that is indeed visible in dumped html/screenshot
Question: I am running some browser tests with splinter and, at one point, come across a
page with a link I want to follow. This call succeeds and returns the link:
my_browser.find_link_by_partial_hre... |
Python subprocess: capture output of ffmpeg and run regular expression against it
Question: I have the following code
import subprocess
import re
from itertools import *
command = ['ffprobe', '-i', '/media/some_file.mp4']
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=s... |
Search and Find through a list Python
Question: I have a main text file that looks like this:
STATUS| CRN| SUBJECT| SECT| COURSE| CREDIT| INSTR.| BLDG/RM| DAY/TIME| FROM / TO|
OPEN| 43565| ACA6202| 10| Acting II| 3.00| Logan, G| SEE DEPT| | 01/12/15 - 04/27/15|
OPEN| 43566| ACA6206| 10| Topic... |
Add buttons to ActionBar app on KIVY. Python
Question: This a code I copied from the KIVY example directory that comes with the
software, I' am trying to modify it, and add other widgets.
.KV File
#:kivy 1.0
<ActionBar>:
height: '48dp'
size_hint_y: None
spacing: '4dp'
... |
openerp change fields in a record by wizard
Question: I have installed openeducat module. In there I was trying to update timetable
record with update status to postponed which I created and Start-End Days by
wizard view.. & here is my python code in wizard. (postponed_op_timetable.py)
from osv import os... |
binarize a sparse matrix in python in a different way
Question: Assume I have a matrix like:
4 0 3 5
0 2 6 0
7 0 1 0
I want it binarized as:
0 0 0 0
0 1 0 0
0 0 1 0
That is set threshold equal to 2, any element greater than the threshold is
set to 0, any element... |
Odd Behaviour of Loop in Python
Question: I am writing a script to report statistics from a text file in Markdown. The
file contains book titles and dates. Each date belongs to the titles that
follow, until a new date appears. Here is a sample:
#### 8/23/05
Defining the World (Hitchings)
#### 8... |
Combine two lists in a pythonic way
Question: I have no clue how to search for this, however, I cannot find an obvious
solution for my pythonic problem. I would like to combine two lists (one is a
manipulated one of the other) and permute them by keeping the length of the
lists constant.
An example:
a =... |
Scrapy ImportError: No module named project.settings when using subprocess.Popen
Question: I have scrapy crawler scraping thru sites. On some occasions scrapy kills
itself due to RAM issues. I rewrote the spider such that it can be split and
run for a site.
After the initial run, I use subprocess.Popen to submit the s... |
How to test Django Form ChoiceField
Question: I've been stuck trying to test a Form `ChoiceField` in Django.
I have a `Form` with a single `ChoiceField`:
class PickPlanForm(forms.Form):
"Set the `plan` session cookie for choice here."
plan_choices = Plan.objects.get_choices()
... |
What is this issue of variable affectation in python?
Question: I have this problem in python. I have a function which take the following
inputs
import numpy;
from numpy import *;
def GetInf(G, X, m, n):
g = G[m - 1, :].T;
Y = X;
Y[m - 1, :] = 0;
... |
Move a flask server to production with mod_wsgi
Question: I followed this
[tutorial](http://flask.pocoo.org/docs/0.10/deploying/mod_wsgi/). Here is my
server:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name... |
Import function from other file in python
Question: In `otsu.py` I have:
def Hello(n):
print "Hello",n
print "abc"
exit()
In `another.py`
from otsu import Hello
Hello(5)
When I run `python another.py`, the output is `abc`, not `Hello, 5`.
What am I doing... |
improving speed on strings with math operators in python
Question: I am working with a set of strings that could contain math operators, either
'+' or '-' for now. Initially i used eval which was pretty straightforward. I
am trying to move away from eval due to its known issues but mostly am trying
to improve the speed... |
how to get a Python timing object to retain appropriate information within function and decorator scopes
Question: I'm writing a module for quick and easy timing in a Python program. The idea
is that little instances of clocks can be created throughout the code. These
clocks are available as objects that can be started... |
How to find 500 most frequent words in 500 text files in python?
Question: I have 500 text files in one directory.I have to find 500 most frequent words
in all of the text files combined.How can I achieve that?
PS: I have searched a lot but could not find a solution.
Answer: Use
[`collections.Counter`](https://docs.... |
Stanford pos tagger not displaying the output elements in Python (MAC)
Question:
#-*- coding:Utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import os
java_path = "/usr/libexec/java_home" # replace this
os.environ['JAVAHOME'] = java_path
from nltk.tag.stanford impor... |
Recursively move files from subdirectory to folders in parent directory
Question: In the following directory,
/Drive/Company/images/full_res/
there exists over 900 .jpg files, like so:
Skywalker.jpg
Pineapple.jpg
Purple.jpg
White.jpg
One level up from 'full_res' ('i... |
Python: Using oswalk in first function to find files, pass name, then trying to open in second function
Question: I am trying to use two functions to find files and process them, the output of
which, ultimately, will be sent to a SQlite3 database. I have the second part
working when NOT a function, but for this, need t... |
Python : Inserting multiple values into a table from excel
Question: I have to read data from Excel and insert it into Table...
For this I am using Python 2.7, pymssql and xlrd modules...
My sql connection is working fine and I am also able to read data from Excel
properly.
My table structure :
CREATE... |
python database query using two scripts
Question: I have two scripts main.py and testscript.py. On main.py is the function to
connect to my database and on testscript.py I will use as my query request and
call this query to my database by using main.py. Adding to main.py
if __name__ == '__main__':
... |
put 3D world coordinates in 2D array
Question: I'm working with 3D image processing using OpenCV and Python.
I can make from two points in two images (left and right) a world coordinate
(X, Y, Z).
For my remainder of the program: It’s important to have a 2D array that
corresponds to the left (or right) image pixels.
... |
Python Requests Code 141 Error
Question: I'm trying to use requests in python to post a json dictionary to a url. I
need to get a string back from the url but I keep getting a code 141 error
-{"code":141,"error":"Missing a github repository link"}. I'm using this
website(<http://docs.python-requests.org/en/latest/user/... |
Efficient way to find the average of the rank of added scores to a list. Possibly a more efficient way of sorting or a math way?
Question: I am trying to solve a problem where I need to find the average of the ranks
of a bunch of scores added to a list.
For example if the input is: 5 100 200 150 170 50
Then the progr... |
Python: UUID in a list
Question: I have a list with a uuid4 in it. I also have a string. For example:
list = [UUID('79d8f4b7-06a0-41d1-99d6-dd8c5308875f'), 'example1', 'example2']
string = 79d8f4b7-06a0-41d1-99d6-dd8c5308875f
But when I try:
if string in list:
print("It's... |
BTC-E ticker time format
Question: Im using python to pull the Bitcoin ticker into a pandas DF and put into my
SQL Database, however I have no idea what format the dam servertime and
updated times are in. I would like to convert the the time in my pandas DF
first then put into my SQL DB.
import pandas as... |
Aquamacs error code 127; LaTeX: problems after [0] pages error
Question: I have a new `macbook pro (OSX 10.10)` and I installed `Aquamacs 3.2 GNU Emacs
24.4.51.2` I have used aquamacs on an old machine for over a year with few
problems.
The installation seemed simple and straightforward, basically double click the
dmg... |
How to read file names and word count in respective files in Hadoop?
Question: I am trying to fetch file names from sequence file from hadoop with the help
of dumbo package of python. But it provides me some kind of identifier. How
can i map this to file name?
Below is my steps on hadoop system for getting filenames :... |
how to get dynamically created method's name
Question: I have a method which return its own name. The method looks like this:
import inspect
class example(object):
def getvalue(self):
return inspect.stack()[0][3] #returns current method's name
Now I am creating a method dy... |
Loop interrupt with an import module "interrupringcow" import error
Question: I have a problem with a downloaded module named interruptingcow It is supposed
to allow me to interrupt a loop after a set amount of time. I have the latest
version that i found installed with pip.
import time
from random i... |
Converting a memory address to a function object
Question: A light in Maya has an attribute `Use Color Temperature`, which is a checkbox,
when I toggle it, a function is called inside Maya to actually do the work
behind the scene. Unfortunately the function address `<function callback at
0x0000000051CD7DD8>` is printed... |
How to find the combinations (probability) for a,b,c,d,e
Question: How to find the combinations (probability) for a,b,c,d,e using
python/algorithm ?
Given that the length of string is 5 that is minimum 1 & maximum 5. All the
characters can be once .
Example :
a
b
c
d
e
ab
ac
... |
In python how can I use/manipulate an object defined in a script from a function defined in an imported module?
Question: This might be a terribly simple one, but I don't know what's the "right"
answer. Assume that I have a script
import utils
bar = 1
utils.foo()
print bar
Furthermore, ... |
Can't import the cx_Oracle module unless I'm using an interactive shell
Question: When using Python on an interactive shell I'm able to import the cx_Oracle
file with no problem. Ex:
me@server~/ $ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyrig... |
Unittest implementation Python property
Question: I have a class with the following property `clusters`:
import numpy as np
class ClustererKmeans(object):
def __init__(self):
self.clustering = np.array([0, 0, 1, 1, 3, 3, 3, 4, 5, 5])
@property
def cl... |
Cryptography hex,binaries and ascii python
Question: I am new to cryptography and when it comes to xor I get really confused. Given
a text in ascii and a cipher in hex how can I get them to be both in the same
format? My current code is:
import binascii
string = b'09e1c5f70a65ac519458e7e53f36'
bi... |
Keeping a string without over writing it throughout the program in python
Question: I'm trying to make a program that stores a user's recipe, using a tkinter gui
to do so. I need to make a way to keep track of what is inputted, and store it
in a text file. I have tried using lists to no avail, and think that using a
st... |
python on windows 10
Question: I have python 2.7.2 on windows 10. When I load win32api and wmi it fails to
load. The python install on the windows 10 is same as on another windows 7 PC.
I don't have this issue on win 7. Below are the errors I get when I try to
import the above modules on windows 10.
>>> ... |
kartograph unknown shape type(25)
Question: I am trying to generate a svg map using kartograph py as below:
from kartograph import Kartograph
K = Kartograph()
config ={"layers": {"mylayer": {"src": "42MEE250GC_SIR.shp"}} }
K.generate(config, outfile='mymap.svg')
And I'm getting this err... |
Selenium Python_Using JetBrain_FileNotFoundError: [Errno 2] No such file or directory: 'C://Python34//Scripts//pythondata.xlsx'
Question: I trying to perform the data driven testing for `selenium python` but each
time i'm trying to execute i'm facing **Error** 2
No such file found
can some one tel... |
Python compare dict with csr_matrices as values
Question: I have two variables `r` and `e` which both are dictionaries, with strings as
keys and csr_matrices as values. Now I want to assert that they are equal. How
do I do this?
**Try 1:**
from scipy.sparse.csr import csr_matrix
import numpy as np
... |
Flask extensions IN PyCharm
Question: I'm actually having trouble using the `flask.ext` with PyCharm ide. I
installed the flask-script and flask-bootstrap but the Pycharm is unable to
recognize them. I'm getting the following error.
Traceback (most recent call last):
File "/home/brucewilson/PycharmPr... |
How to separate data acquisition, processing, and visualization properly in Python?
Question: I am working on a project, where I want to perform data acquisition, data
processing and GUI visualization (using pyqt with pyqtgraph) all in Python.
Each of the parts is in principle implemented, but the different parts are n... |
Logging Nginx and uWSGI web server errors to Sentry
Question: I am currently using Sentry to log application level errors from Django web
application. Could it be possible to expand the scope of the Sentry to include
logging of web server errors (HTTP 408 timeouts and such)?
These requests never hit the application, s... |
Is there a way to call python with xlwings without reopening the Excel file?
Question: I am calling python from Excel using xlwings. I find that when running my
macro, Excel closes and reopens in order to run the code. It functions
correctly but it slows things down. In addition, if the Excel file is unsaved
a dialog w... |
Ipython console in Spyder stuck on "connecting to kernel"
Question: I am new to python and coming from Matlab and I have installed the latest
version of Python(x,y) (2.7.9.0) on my Win 8 64 bit PC.
The problem that I have is that, each time I start Spyder, the default IPython
console gets stuck on "connecting to kerne... |
Python Urllib2 SSL error
Question: Python 2.7.9 is now much more strict about SSL certificate verification.
Awesome!
I'm not surprised that programs that were working before are now getting
CERTIFICATE_VERIFY_FAILED errors. But I can't seem to get them working
(without disabling certificate verification entirely).
On... |
Performance of inline Python function definitions
Question: A general question for someone that knows function definition internals better
than I do.
In general, is there a performance trade off to doing something like this:
def my_function():
def other_function():
pass
... |
Understanding argument parsing with argparse in Python
Question: I am now starting exploring Python, and was testing how arguments can be
passed to a script with "argparse". The way I wrote a sample script was as
following, where arguments passed through flags -i and -o are compulsory and
flag -u is optional:
... |
Filter on/Order by Postgres range type in SQLAlchemy
Question: SQLAlchemy supports Postgres range types, as described
[here](http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#range-
types). It uses the `postgresql+psycopg2` dialect for Postgres communication.
[These
testcases](https://bitbucket.org/zzzeek/s... |
Uninstalling Python - Do I loose my installed packages and code?
Question: I have been having problems importing Tkinter. I have done research here and
found that it's because I have had both 64 bit and 32 bit python on my
machine. I currently use 32 bit but Tkinter is pointing to the 64 bit version.
I think the easies... |
how to use python to do a series of commands in terminal
Question: I put the following in my `python_go.py`
import os
os.system("cd some_dir") # This is the directory storing an existing virtual environment
os.system(". activate") #because I want to activate the virtual environment
os.system(... |
SQLAlchemy inheritance not working
Question: I'm using Flask and SQLAlchemy. I have used my own abstract base class and
inheritance. When I try to use my models in the python shell I get the
following error:
>>> from schedule.models import Task
Traceback (most recent call last):
File "<console>... |
parsing and saving csv file in python and csv module
Question: This script is meant to parse and sort a list from a csv file and save to a
newly created csv file, including headers.
I triyng to include the write function to save the output of this parser to a
new csv file with the following. This code create a csv but... |
Use of scipy.optimize.minimize in Neural Network
Question: Trying to use Backpropagation Neural Network for multiclass classification. I
have found [this code](http://danielfrg.com/blog/2013/07/03/basic-neural-
network-python/#disqus_thread) and try to adapt it. It is based on the
lections of [Machine Learning in Cours... |
What does cmdclass do in Pythons setuptools?
Question: I've recently got a pull request which added
class build_ext(_build_ext):
'to install numpy'
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup ... |
Error in printing scraped webpage through bs4
Question: **Code:**
import requests
import urllib
from bs4 import BeautifulSoup
page1 = urllib.request.urlopen("http://en.wikipedia.org/wiki/List_of_human_stampedes")
soup = BeautifulSoup(page1)
print(soup.get_text())
print(soup.p... |
Can I defragment the heap in a Python script?
Question: I'm running a malware analysis experiment in Python and I need to create a big
object (512 MB, I think). While testing locally (64-bit system), there is no
problem, but when I try to run it on a remote 32-bit system (so the process
has a stack of max 4 GB), I get ... |
Use a timeout to prevent deadlock when opening a file in Python?
Question: I need to open a file which is NFS mounted to my server. Sometimes, the NFS
mount fails in a manner that causes all file operations to deadlock. In order
to prevent this, I need a way to let the `open` function in python time out
after a set per... |
Rotating Large Arrays, Fastest Possible
Question: I am relatively new to Python and looking for best optimized code for rotating
large multi-dimensional arrays. In the following code I have a 16X600000 32bit
floating point multi-dimensional array and according to the timer it takes
about 30ms to rotate the contents on ... |
uWSGI module found when invoked on the command line but not when invoked using emperor
Question: I have a python wsgi application which I am running under uWSGI.
When I try to run the same application using emperor I get an error -
ImportError: No module named app_thing
unable to load app 0 (mountpo... |
Monte Carlo simulation Python
Question: Question: You have a bucket with 3 red balls and 3 green balls. Assume that
once you draw a ball out of the bucket, you don't replace it. What is the
probability of drawing 3 balls of the same color?
Problem: My code always gives 0.0
import random
def noReplac... |
mongodb import xml into mongodb
Question: I have problem with importing big xml file (1.3 gb) into mongodb in order to
search for most frequent words in map & reduce manner.
<http://dumps.wikimedia.org/plwiki/20141228/plwiki-20141228-pages-articles-
multistream.xml.bz2>
Here I enclose xml cut (first 10 000 lines) out... |
Converting C into Python
Question: I am trying to convert a C module that parses the output from the Linux
library rtl_fm. It is used for catching energy usage from an Efergy meter
throuh a DVB-T dongle
The C module works fine but I want it written in python to interact with other
python modules i have
I have put the... |
NameError: name 'BillPayer' is not defined
Question: I am getting the above error when trying to run my code. I believe it suffers
from being a broad error, as all my googling has not brought me to anything
that relates to my actual situation. I have organized the directory like this:
Project (BillPay)
... |
Should I call connect() and close() for every Sqlite3 transaction?
Question: I want to write a Python module to abstract away database transactions for my
application. My question is whether I need to call `connect()` and `close()`
for every transaction? In code:
import sqlite3
# Can I put conne... |
How to pass Django mock instance to class method?
Question: The Mock testing library is the one Django topic I just can't seem to wrap my
head around. For example, in the following code, why don't the mock User
instances that I create in my unit test appear in the User object that I query
in the 'get_user_ids' method? ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.