text stringlengths 226 34.5k |
|---|
wxPython: Dynamically Flow Buttons to Next Row on Window-Resize
Question: The following wxPython sample code is meant to create some buttons and then
add them to a horizontal panel in such a way that the buttons should flow to a
new row when they no longer fit in the panel.
In addition, the buttons should change posit... |
Type Error when I try to make a 3D graph in python
Question: I know how to make 3D-graph in Python but for this one I have an error I've
never seen. I want to have the graph of :
$$f(x,y)=\frac{8\cos(\sqrt{x^2+y^2}}{\sqrt{1+x^2+y^2}}$$ (LaTeX doesn't work
here... ???)
My code :
import math
... |
Rpy2 can't find my R libraries on install
Question: R built from source, installed locally. R is at `~/bin/R` (which is in my
PATH) and its libraries are in `~/lib64/R/`. Installing rpy2 should be simple.
It finds the correct R just fine (as it's in the path). Then it can't find the
libraries.
$python se... |
Python lazy evaluation numpy ndarray
Question: I have a large 2D array that I would like to declare once, and change
occasionnaly only _some_ values depending on a parameter, without traversing
the whole array.
To build this array, I have subclassed the numpy ndarray class with
`dtype=object` and assign to the element... |
Append to File Using Subprocess in Python
Question: How do I append to a file without opening it using Linux echo command? I've
tried all sort of possibilities but unable to achieve the result. I'm not sure
what I'm missing.
Documentation said to type out the exact command when shell is set to 'True'
_(Yes with securi... |
mongodb group and combine
Question: I have a doc that has a schema like `{'year-month-day','others'}` and I want
to convert `'year-month-day` to an ISODate time so I can use
`$match:{'$gte:targetDate'}`
I have several problems:
1. I am using pymongo, which dones support javaciprt, so I can not use `new Date()` in p... |
Linux command line instructions from python
Question: Is there a method for issuing command line instructions directly from the
python shell?
Answer: You can use `os.system` -
import os
os.system('<command line instruction>')
|
Python CSV read file and select columns and write to new CSV file
Question: I have a CSV file which has certain columns which I need to extract. One of
those columns is a text string from which I need to extract the first and last
items. I have a print statement in a for loop which get exactly what I need
but cannot fi... |
How are images actually saved with skimage (Python)
Question: I am currently applying the [Zhang-Suen thinning
algorithm](https://github.com/linbojin/Skeletonization-by-Zhang-Suen-Thinning-
Algorithm/blob/master/thinning.py) to hone down on some filaments I would like
to later track. This requires me to output a graysc... |
Flask-Security user_registered Signal Not Received in Python 3.3, but works in 2.7
Question: I'm trying to use the user_registered signal in order to set up default roles
for users when they register using flask-security as in the following link:
[Setting Default Role in Flask
Security](http://stackoverflow.com/questio... |
Formatting Flask app logs in json
Question: I'm working with a Python/Flask application and trying to get the logs to be
formatted (by line) in json.
Using the python-json-logger package, I've modified the formatter for the
app.logger as follows:
from pythonjsonlogger import jsonlogger
formatter = j... |
How to mock.patch a class imported in another module
Question: I have a python class with such a module:
**xy.py**
from a.b import ClassA
class ClassB:
def method_1():
a = ClassA()
a.method2()
then I have ClassA defined as:
**b.py**
from c import Clas... |
using requests to login to a website that has javascript login form
Question: Let me preface by saying I have very little programming experience. I've
learned a bunch in the last few days trying to write this program. I am
running Python 2.7 on Windows 7 using PyCharm, requests, Beautiful Soup, and
lxml.
I am trying t... |
Is there a way to catch 500 errors in django python?
Question: I would like to catch 500 exception and return a http 4XX exception instead.
Using "except Exception" will catch all exceptions which is not desired. I was
wondering is there a way to catch only 500 errors
try:
<code>
except <Excep... |
How to decode ascii from stream for analysis
Question: I am trying to run text from twitter api through sentiment analysis from
textblob library, When I run my code, the code prints one or two sentiment
values and then errors out, to the following error:
UnicodeDecodeError: 'ascii' codec can't decode byt... |
HTTP POST REQUEST using python
Question: I've a web server setup in a separate location and I wanted to access it
remotely using HTTP POST request. Can someone please guide me how to proceed
with it. I need to use Python which runs the HTTP Post request and modifies
the contents of the WEB page
Answer: Although proba... |
Python equivalent of C++ member pointer
Question: What would be the equivalent of a C++ member pointer in Python? Basically, I
would like to be able to replicate similar behavior in Python:
// Pointer to a member of MyClass
int (MyClass::*ptMember)(int) = &MyClass::member;
// Call member on... |
Python Convert set to list, keep getting TypeError: 'list' object is not callable
Question: I am trying to write a program that adds items to a list based on a random
number. Part of the program is potentially rolling additional items, but all
duplicate items should be rerolled. My issue is that when I try to do this
u... |
Mock import of ctypes fails with unsupported operand on Read The Docs
Question: I have small Windows module that relies on the **ctypes** core module. On the
project RTD site the page for the module comes up empty. Looking at the latest
almost successful build log <https://readthedocs.org/builds/apt/2900858/>
there is ... |
How to reject or accept an incoming call to my GSM modem using AT commands in Python?
Question: I've wrote the below Python program to wait for incoming calls and accept or
reject them. Based on [this](http://www.zeeman.de/wp-
content/uploads/2007/09/ubinetics-at-command-set.pdf) document and
[this](https://www.sparkfu... |
Flask + Celery: working outside of request context
Question: today i started using Celery but am having an issue that am not able to
resolve. more specifically,
my Flask configuration is :
from celery import Celery
def make_celery(app):
celery = Celery(__name__, broker=app.config['CELERY_BRO... |
Matching two vector paths
Question: I have several vector paths and a query path and now I am trying to get the
path which is most similar to the query path. I can access length(perimeter)
of each path, and width and height of their bounding boxes. I am using python
and using pyx library for rendering SVG paths and cal... |
how can i count how many time program has been executed in python
Question:
from itertools import permutations
import random
import pprint
import timeit
start_time = timeit.default_timer()
count = 0
def gird(board_size):
print ("\n".join('# ' * inrange + 'Q ' + '# ' * (8-i... |
Why is multiprocessing copying my data if I don't touch it?
Question: I was tracking down an out of memory bug, and was horrified to find that
python's multiprocessing appears to copy large arrays, even if I have no
intention of using them.
Why is python (on Linux) doing this, I thought copy-on-write would protect me
... |
Python Regex Search and Count with Symbol Character
Question: i try to make some script with python to find and count a word in string. A
word is "@sosiora", i have find some example but it's not find "@sosiora" but
"sosiora". Here is my script
#!/usr/bin/python
import re
words = ["@sosiora"]
... |
Python - Passing character to C library
Question: I've got quite the trouble running a program on Linux i wrote. Since it's
quite a large program i won't post the whole code but only the part that gets
me confused. I've got a library, written in C++ and compiled on Linux Ubuntu,
which does some work and prints an incom... |
Regex expression after quotation on python
Question: I am trying to develop a program on Python that would get the name of the
artists from a twit from Pandora. Like for example if I have this twitter:
> I'm listening to "I Can Make It Better" by Luther Vandross on Pandora
> #pandora <http://t.co/ieDbLC393F>.
I would... |
Add object to start of dictionary
Question: I am making a group chatting app and I have images associated with the users,
so whenever they say something, their image is displayed next to it. I wrote
the server in python and the client will be an iOS app. I use a dictionary to
store all of the message/image pairs. Whene... |
How can I correct my code to produce a nested dictionary?
Question: I am trying to create a nested dictionary. I have a list of tuples (called
'kinetic_parameters') which looks like this:
('New Model','v7','k1',0.1)
('New Model','v8','k2',0.2)
('New Model','v8','k3',0.3)
I need the second c... |
Calling on a class
Question: I'm using geopy and have a question on why an error is coming up.
This code sample is from the one provided at
[github](https://github.com/geopy/geopy#geocoding). It works as mentioned
from geopy.geocoders import Nominatim
geolocator = Nominatim()
location ... |
Importing Python file from PostgreSQL stored procedure
Question: It is possible to have Python code in a PostgreSQL stored procedure. For
example:
CREATE FUNCTION someProc()
RETURNS void AS $$
# Some Python3 code...
$$ LANGUAGE plpython3u;
But how can I include a python file from th... |
Calculate number of positive and negative string for each word in a list
Question: I am new in python and hope you could help me solve this problem and I am
using python 3.4.
I have a list that contain word,either positive or negative, and it's
frequency
This is the original list:
`finalSentiment = [('... |
Python for Maya: "Object's name is not unique." when calling object from class to build UI
Question: # The Problem:
I don't get any syntax errors when i run the script up until i try to build
the UI. Everything seems fine until i run the last 2 lines of code.
I get the following error : **Error: RuntimeError: file li... |
openssl hmac differ from python hmac
Question: with:
KEY='7vgd39eyxald9sucClM7'
DATA='POST\nmultipart/form-data\nWed, 10 Jun 2015 07:27:43 GMT\n/1/classes/item\nx-wbs-uid:f886a495220975d724ff3679a5cc9cef04343076'
in command line
HASH_BIN=`echo -n "$DATA" | openssl dgst -sha256 -m... |
Using counter on array for one value while keeping index of other values
Question: After reading the answers on this question [How to count the frequency of the
elements in a list?](http://stackoverflow.com/questions/2161752/how-to-count-
the-frequency-of-the-elements-in-a-list) I was wondering how to count the
frequen... |
sys.argv in a windows environment
Question: I'm attempting to learn python using the book 'a byte of python'. The code:
import sys
print('the command line arguments are:')
for i in sys.argv:
print(i)
print('\n\nThe PYTHONPATH is', sys.path, '\n')
outputs:
... |
Python: can't access newly defined environment variables
Question: I can't access my env var:
import subprocess, os
print os.environ.get('PATH') # Works well
print os.environ.get('BONSAI') # doesn't work
But the env var is well added in my `/home/me/.bashrc`:
BONSAI=/home/me/... |
Pixel movement and loops Python
Question: We are using JES in my intro programming class and I have run into roadblock
for my lab. The program is supposed to allow a user to select a picture and
then a moth(bug) will start at the center of the picture and make random
movements and change pixels to white if they are not... |
return a variable value from a subprocess in python
Question: I have a code workflow in which from a main script(level 0) I call another
script through `subprocess`. This `subprocess script` (level 1) in turn calls
another script as a `subprocess`. Now from this level 2 subprocess script I
want to return the value of a... |
ctypes error AttributeError symbol not found, OS X 10.7.5
Question: I have a simple test function on C++:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
#include <wchar.h>
char fun() {
printf( "%i", 12 );
return 'y';
}
... |
What is the Big-O of this function that reverses words in a string
Question: I have a simple function, reverseWords(), that reveses the words in a string.
eg. an input of a S = "this is a string" gives an output of "siht si a gnirts"
I was wondering what the big O of this function is. Is it O(N), O(N^2), or
O(N* M)?
... |
run python code in c++
Question: I was making an app that needs to run python code in c++. But when I run this
code it gives an segmentation fault in Linux. Does somebody have a clue what
it could be?
Py_SetProgramName("programName");
Py_SetPythonHome("/usr/lib/python2.7");
Py_Init... |
How to update HTML block in IPython
Question: This is related to [another
question](http://stackoverflow.com/questions/30989509/automaticaly-update-
image-in-ipython-notebook) I posted, but is more specific (and hopefully gets
more specific answers).
I am trying to display `png` images on an IPython notebook, and upda... |
Open CV 3.0.0 video not processing windows winpython 2.7.9
Question: I wrote the following code to open a video file and the file is in the same
directory as the script, moreover the code to write a video feed from the
camera to the file is not working!
import numpy as np
import cv2
cap = cv2.Vid... |
cannot import my util module
Question: I'm using `sklearn.externals.joblib` to persist a classifier model to the disk
which in reality uses `pickle` module at lower level.
I create a custom `CountVectorizer` class named `StemmedCountVectorizer` and
saved it in `util.py`, then used it in the script for persisting the m... |
Python not sending HTTP POST request to correct URL
Question: I was lately making this ask.fm "spam" bot (no ask.fm doesn't have neither an
IP limit nor a captcha to stop bots). So anyway, I made sure the url was
correct, but every time I send the POST request to ask.fm/usernamehere it
sends the request to ask.fm, I'm ... |
How can I add a comment to a YAML file in Python
Question: I am writing a YAML file using <https://pypi.python.org/pypi/ruamel.yaml>
The code is like this:
import ruamel.yaml
from ruamel.yaml.comments import CommentedSeq
d = {}
for m in ['B1', 'B2', 'B3']:
d2 = {}
for f ... |
Python: ipaddress AttributeError: 'str' object has no attribute
Question: Following the advice given
[here](http://stackoverflow.com/questions/30994223/regex-for-range-of-
ipv4-addresses), I'm using the check the `ipaddress` module to perform checks
of type:
In [25]: IPv4Address(u'100.64.1.1') in IPv4Net... |
EVE REST- Issue with AuthToken in python Eve framework error 401
Question: I am currently working on python-eve library to create a restful API but I'm
experiencing some issues when I follow this tutorial to implement a "Token
Authentication" I get error 401 saying "please provide proper credential".
Here is my user s... |
Passing OSGi bundles for Jython Interpreter on-the-fly
Question: we would like to integrate the Jython interpreter into our Eclipse RCP based
solution and we need to access the OSGi bundles (e.g. everything from
`Activator.getContext().getBundles()` ) from there.
How could I pass these bundles to a Jython `PythonInter... |
How to reference a html template from a different directory in python flask
Question:
@app.route('/view', methods=['GET', 'POST'])
def view_notifications():
posts = get_notifications()
return render_template("frontend/src/view_notifications.html", posts=posts)
So in my `project/backen... |
Is there method like python popitem for associative arrays in dlang?
Question: I want to get any key/value pair from associative array and remove it. In
python it's:
key, value = assoc.popitem()
In D I do:
auto key = assoc.byKey.front;
auto value = assoc[key];
assoc.remove(ke... |
getting time zone offset in seconds in Python
Question: I need to discover the timezone offset in seconds from UTC. Here's what I am
trying now:
timeZoneSecondsOffset = calendar.timegm(time.gmtime()) - calendar.timegm(time.localtime())
This works - kind of. It gives a value that is off by one hour.... |
Angularjs won't work with my google app engine configuration
Question: I include google's angularjs scripts but they don't seem to work with the app.
If I open the html webpage directly with an internet browser it works fine.
The page is just a simple test with ng-model to see what you are typing and it
doesn't print {... |
matplotlib RuntimeError in cron job before actual import
Question: I have a module I'm writing that uses matplotlib. However, I need it to work
with a display(e.g. command-line execution), or when theres no display (
SGE/qsub cluster job, or a cron job).
I found this answer ( [Automatic detection of display availabili... |
How to shadow git's built-in commands?
Question: I'd like to have the following script run when "git status" is ran with no
parameters:
#!/usr/bin/env python
import subprocess
o = subprocess.check_output("git -c color.status=always status", shell=True)
started = False
done = Fal... |
Python Agglomerative Clustering
Question: I am new on clustering ( using sklearn in Python). I am trying to import
Agglomerative Clustering using:
from sklearn.cluster import AgglomerativeClustering
but I get the following error:
from sklearn.cluster import AgglomerativeClustering
... |
PYTHON - Zip each file in directory independently
Question: I've been looking through and have tried a few different codes without
results. What I'm trying to do is zip each file in a subdirectory/folder
independently.
Ex:
> FileName.prj
>
> FileName.dwg
>
> FileName.mp3
Each as it's own .zip
Thanks!
Answer: Try ... |
Unwanted random iterator in For-Loop
Question: I tried to create a function for generating a set number (numbersToChoose) of
values between two other values (startFrom and stopAt) but for some reason the
iterator (?) in the second for-loop (line 7), in this case a seems to be
randomly generated even though I don't see ... |
Python writing to a new file each new loop
Question: I'm trying to use a while loop to write to a series of new files. Each
iteration of the loop should write to a new file, and close it before the next
loop begins. I'm using Python 2.7, and I'd like to resolve this without having
to install any additional libraries if... |
Python Tkinter Radiobutton narrowing user input
Question: I'm new to programming, python, and Tkinter and I wanted a nice solution
(maybe using state=DISABLED?) to limit the user's options based on the buttons
they select. My present code:
from Tkinter import *
master = Tk()
def ok():
... |
Python - Grab Random Names
Question: Alright, so I have a question. I am working on creating a script that grabs a
random name from a list of provided names, and generates them in a list of 5.
I know that you can use the command
items = ['names','go','here']
rand_item = items[random.randrange(le... |
Python os.walk topdown true with regular expression
Question: I am confused as to why the following ONLY works with `topdown=False` and
returns nothing when set to `True` ?
The reason I want to use `topdown=True` is because it is taking a very long
time to traverse through the directories. I believe that going topdown... |
find urls in string in Python duplicate
Question: Can someone help. As an example the following text output there more than pne
hyper link. I’m looking for the first output: **JournalEntries.dox?method=view
&number=JE-00000725**
Here are my output source and i look for these ones **https://www.zuora.com/... |
ImportError: No module named kivy
Question: I am new to Ubuntu and Python. Basically I installed kivy just as the website
told me to do.First I built the repo
$ sudo add-apt-repository ppa:kivy-team/kivy
Then I do the apt
sudo apt-get install python3-kivy
Ok now I fir... |
Send Mail with python using gmail smtp
Question: I am using following code
import smtplib
import mimetypes
from email.mime.multipart import MIMEMultipart
from email import encoders
from email.message import Message
from email.mime.audio import MIMEAudio
from email.mime.base import... |
Disable global variable lookup in Python
Question: In short, the question: **Is there a way to prevent Python from looking up
variables outside the current scope?**
Details:
Python looks for variable definitions in outer scopes if they are not defined
in the current scope. Thus, code like this is liable to break when... |
Should yield be used in list comprehension in Scrapy
Question: I'm writing a spider. And in that spider I need to yield requests, with
different params. It is something like,
for i in xrange(0, len(products), k):
some_ids = ','.join([a_product['id'] for a_product in products[i: i + k]])
f... |
Load R data frame into Python and convert to Pandas data frame
Question: I am trying to run the following code in an R data frame using Python.
from fuzzywuzzy import fuzz
from fuzzywuzzy import process
import os
import pandas as pd
import timeit
from rpy2.robjects import r
from r... |
Python decrypt signatures with only a public key
Question: A company wants to send me a **digital signature** i.e this
[method](https://en.wikipedia.org/?title=Digital_signature). I only have the
**public key**. This signature is used to authenticate who it came from
**AND** contains details of the user, which I need.
... |
xpath matching wrong node
Question: The xpath
`//*[h1]`
shows different results when tried on python and Firebug. My code:
import requests
from lxml import html
url = "http://machinelearningmastery.com/naive-bayes-classifier-scratch-python/"
resp = requests.get(url)
page = html.fro... |
Fitting two non-linear models to data
Question: Following the example is given in
[`lmfit`](http://cars9.uchicago.edu/software/python/lmfit/parameters.html), I
am trying to set up an example which is similar to my problem. My problem
originally is that in my data I can fit two or three models, while my model is
highly ... |
"pip freeze" gives different modules from "help('modules')"
Question: I tried multiple solutions from [this
answer](https://stackoverflow.com/questions/739993/how-can-i-get-a-list-of-
locally-installed-python-modules) and they seemed to give be different
results. I am using `virtualenv` and I was wondering if it has so... |
How to adjust scaled scikit-learn Logicistic Regression coeffs to score a non-scaled dataset?
Question: I am currently using Scikit-Learn's LogisticRegression to build a model. I
have used
from sklearn import preprocessing
scaler=preprocessing.StandardScaler().fit(build)
build_scaled = scaler.tra... |
Kivy and android sharedpreferences
Question: I am looking for a method to store settings persistently on android device,
from Kivy framework.
I found Kivy documentation, overall informative, vague in this particular
area. It mentions three methods (_sorry, dont have enough reputation to
provide clicable links, relativ... |
Capture Webcam image using CV2 and Pyglet in Python
Question: I'm using CV2 (OpenCV) for Python, and the Pyglet Python libraries to create a
small application which will display live video from a webcam and have some
text or static images overlayed. I've already made an application with CV2
that just displays the webca... |
How do get summation of return values in different time python
Question:
from vaderSentiment.vaderSentiment import sentiment as vaderSentiment
count=0;
f1 = open('testData.txt')#input file
sentence= f1.readline()
while sentence:
count += 1
print (sente... |
python not properly reading in text file
Question: I'm trying to read in a text file that looks something like this:
Date, StartTime, EndTime
6/8/14, 1832, 1903
6/8/14, 1912, 1918
6/9/14, 1703, 1708
6/9/14, 1713, 1750
and this is what I have:
g = open('Observed_closu... |
Statsmodels mosaic plot ValueError: cannot convert float NaN to integer
Question: I have a simple pandas DataFrame, for which I would like to create a mosaic
plot. Here is my code:
import pandas as pd
from statsmodels.graphics.mosaicplot import mosaic
mydata = pd.DataFrame({'id2': {64: 'Ang... |
Python Flask Export and Download CSV Error
Question: I am using Python Flask, and I need to export session data to a CSV file and
then prompt to download it
My code is
from StringIO import StringIO
import csv
import web
@app.route('/exportcsv')
def export_csv():
data = ... |
Flask-Login:Where user_loader callback should be defined?
Question: I am new to python coding but straightaway started experimenting with flask. I
am having trouble with flask-login extension Here I am making a simple
application which is a blog. This blog is going to be used by one person only.
I cannot understand wh... |
Run python script from django
Question: I added some python file in my django project but that python file did not
execute. How can i run that python scrip in django.
Answer: OK it seems you want to run a script outside of the HTTP request/response
cycle, I'd recommend you make a Django admin command, because a scrip... |
Assigning names to large objects appears to increase memory usage considerably
Question: Usually, when I need to invoke a complicated formula, I break it down into two
or more lines to make the code more comprehensible. However, when profiling
some code that calculates [RMSE](https://en.wikipedia.org/wiki/Root-mean-
sq... |
Python Requests POST error: __init__() takes 2 arguments (1 given)
Question: So I have a Flask application which uses the Flask-Restless and Flask-
SQLAlchemy modules to create an API. My GET requests are working fine, but
POST requests are not.
From models.py:
from application import db
class ... |
Errno 32: Broken pipe
Question: Below is the code for which I am getting Broken Pipe error. I am not getting
this error for small data sets. This arises only when the data set is large. I
am not able to handle it through exceptions also.
## reading the data from CSV file
import csv
csv_file='Two_... |
Python Add Key to Dict conditionally
Question: I'm trying to generate a dict from a list of headers that "associates" columns
of data to the same experiment. For example, I want to turn:
headers = ["A_1","A_2","A_3","B_1","B_2","B_3"]
into
cols = { 1 : {'A' : 0, 'B' : 3}, 2: {'A' : 1... |
Hit "enter" automatically every n seconds in python
Question: I am calling an external program one a loop using a python script and in
general everything works well. However, occasionally the program gets stuck
performing a certain process. If I hit 'enter' then the program continues to
run as desired.
Would it be pos... |
Value difference comparison within a list in python
Question: I have a nested list that contains different variables in it. I am trying to
check the difference value between two consecutive items, where if a condition
match, group these items together.
i.e.
Item 1 happened on 1-6-2012 1 pm
Item 2 ha... |
Identifying Arithmetic progressions in a list of numbers
Question: M arithmetic progressions each having N terms (with the terms differing by
d1,d2,...dm) are passed as input with the terms shuffled. The program must
print the terms in M arithmetic progressions in sequential order with the
smallest starting term first.... |
Give sudo access to celery workers
Question: I have a python program that needs to executed like this;
$ sudo python my_awesome_program.py
Now I want to run thousands of instances of this program using celery, of
course with different parameters. The Problem is that while celery tries to
execute my... |
Pandas str.extract: AttributeError: 'str' object has no attribute 'str'
Question: I'm trying to repurpose this function from using `split` to using
`str.extract` (regex) instead.
def bull_lev(x):
spl = x.rsplit(None, 2)[-2].strip("Xx")
if spl.str.isdigit():
return "+" + spl + ... |
subtract two columns of different Dataframe with python
Question: I have two DataFrames, df1:
Lat1 Lon1 tp1
0 34.475000 349.835000 1
1 34.476920 349.862065 0.5
2 34.478833 349.889131 0
3 34.480739 349.916199 3
4 34.482639 349.943268 0
5 ... |
how to run a C code with argc argv from python?
Question: I need to run my c code from python, usually as adviced
[here](http://stackoverflow.com/questions/4376397/executing-a-c-script-in-
python) I do this and works perfectly:
from subprocess import call
call(["./code", "args", "to", "code"])
... |
Correct python code to insert NULL value into MySQL
Question: I'm attempting to insert some variables into a MySQL database using python.
Sometimes the variables will be strings and sometimes they will be None.
A hugely simplified version of what I am attempting is below:
import MySQLdb as mdb
f = "... |
Is it a Python bug that the main thread of a process created in a daemon thread is a daemon itself?
Question: When I call `os.fork()` inside a daemon thread, the main thread in the child
process has the `daemon` property set to `True`. This is very confusing, since
the program keeps running while the only thread is a d... |
Python matplotlib animation of a constantly updated data feed
Question: I'm trying to make a satellite visualization tool using an animation in
matplotlib. I want to plot a 5-image animation and then constantly update this
animation every time a new image appears.
I could animate the last 5 images like this:
... |
Python 3.4 login on aspx
Question: I'm trying to login to an aspx page then get the contents of another page as a
logged in user.
import requests
from bs4 import BeautifulSoup
URL="https://example.com/Login.aspx"
durl="https://example.com/Daily.aspx"
user_agent = 'Mozilla/5.0 (W... |
enumerate column headers in CSV that belong to the same tag (key) in python
Question: I am using the following sets of generators to parse XML in to CSV:
import xml.etree.cElementTree as ElementTree
from xml.etree.ElementTree import XMLParser
import csv
def flatten_list(aList, prefix=''... |
Averaging a list in Python, "Type Error: Cannot perform reduce with flexible type"
Question: The code below is supposed to do as follows:
1. Fill an empty list with a specific column of numbers from a csv file.
2. The average of the list values is then calculated and the resulting value is plotted.
Problems: I... |
if __name__ == '__main__' not working ipython
Question: I'm having trouble getting the `if __name == '__main__'` trick to work in an
IPython, Spyder environment. I've tried every approach given in this thread:
[if __name__ == '__main__' in
IPython](http://stackoverflow.com/questions/22923002/if-name-main-in-ipython)
H... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.