text stringlengths 226 34.5k |
|---|
Subprocess module in Python to cmd.exe
Question: I have some code here trying to open up the `cmd.exe` from Python and input
some lines for the command to use.
Here it is:
PDF= "myPDF"
output= "my output TIF"
def my_subprocess(command,c='C:\here'):
process = subprocess.Popen(comman... |
Cache Proxy Server Returning 404 with www.google.com
Question: I have a homework assignment which involves implementing a proxy cache server
in Python for web pages. Here is my implementation of it
from socket import *
import sys
def main():
#Create a server socket, bind it to a port... |
Python header unicode to dict
Question: I have a MySQL database with a python request header saved in one of the
columns and it looks something like this:
{
'_': '/Users/user/.virtualenvs/squadraft/bin/python',
'wsgi.multiprocess': False, 'RUN_MAIN': 'true',
'rvm_version': '1.26.11 (latest... |
Background Timer in PyQt Python Applicatiion
Question: I am Building an application in python using PyQt4. I want to add a background
timer to my application so that when the timer runs out, the text editor in my
application stops receiving input and freezes up. I have tried the following
method so far:
... |
pyGame image scale does not work as expected
Question: I am new into Python and pyGame and i have a problem with scaling an image. I
want to zoom an image in pygame. The pygame documentation claims that
> pygame.transform.scale()
should scale to a new resolution. But in my example below it does not work -
it crops th... |
Distributed Programming on Google Cloud Engine using Python (mpi4py)
Question: I want to do distributed programming with python using the mpi4py package. For
testing reasons, I set up a 5-node cluster via Google container engine, and
changed my code accordingly. But now, what are my next steps? How do I get my
code run... |
UnicodeDecodeError from sound file
Question: I'm trying to make a speech recogniser in Python using Google speech API. I've
been using and adapting the code from
[here](http://stackoverflow.com/a/19828908/4961615) (converted to Python3).
I'm using an audio file on my computer that's been converted from mp3 to flac
1600... |
import numpy on python 3.5 on mac osx
Question: I tried to follow your advices about typing in `macport` :
cd /opt/local/bin
sudo ./port install py35-numpy
and apparently it worked, but Python still doesn't find any module named
`'numpy'`...
Thanks for help
Answer: If you're interested in p... |
django redirect no reverse match error
Question: Here is my main project timecapture/urls.py content:
from django.conf.urls import url,include
from django.contrib import admin
from django.core.urlresolvers import reverse_lazy
from . import views
urlpatterns = [
url(r'^a... |
Python Numpy Poisson Distribution
Question: So basically I am generating a gaussian, for the sake of completeness, that's
my implementation:
from numpy import *
x=linspace(0,1,1000)
y=exp(-(x-0.5)**2/(2.0*(0.1/(2*sqrt(2*log(2))))**2))
with peak at `0.5` and `fwhm=0.1`. So far so not interes... |
WSGI import app from python package yields 500
Question: I want to deploy my python app on apache so I made a hello world app
(contained in one python file) and imported the app object from there and it
worked. This was just to test out things.
Then I move my app file there and tried the same with it. I try to import ... |
Send email through smtp in superlance using crashmail
Question: I'm trying to set up the email sending when a process changes state in
[supervisord](http://supervisord.org/) by using
[crashmail](https://superlance.readthedocs.org/en/latest/crashmail.html).
Having no luck with the default `sendmail` program which requir... |
Django Shell image upload _io.BufferedReader no attribute size
Question: My problem is that when I try to save image to my model using Django shell I
get this error that I can't find solution anywere.
models.py
class AdImage(models.Model):
ad = models.ForeignKey(Ad)
full_photo = models.Ima... |
Python Parsing XML with a complex hierarchy - Nuke9.0v8
Question: I am working with NukeX9.0v8, Adobe Premiere Pro CC 2015 and nukes internal
python interrupter.
# Result: 2.7.3 (default, Jul 24 2013, 15:50:23)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
I am a vfx artist and I'm trying to wra... |
Why does my repository object return Nonetype with github3.py?
Question: Using github3.py version 0.9.5
[documentation](http://github3py.readthedocs.org/en/0.9.5/repos.html), I'm
trying to create a repository object but it keeps returning `Nonetype` and
therefore I am unable to access the contents of the repository. Th... |
Python random character string repeated 7/2000 records
Question: I am using the below to generate a random set of characters and numbers:
tag = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(36)])
I thought that this was a decent method. 36 character length, with each
... |
Jinja2 templating not working in in Django 1.9
Question: Per the instructions on the [Django 1.9
tutorial](https://docs.djangoproject.com/en/1.9/topics/templates/#django.template.backends.jinja2.Jinja2)
I've added another file in the project root with the Environment settings -
from __future__ import abs... |
Why is the ipython output of set different from the __repr__ or __str__ of the set?
Question: I am running the following code in ipython and am surprised at the print
outputs and the ipython cell outputs of the code:
print set(["A", "B", "C"])
print set(["A", "C", "B"])
print list(set(["A", "C", ... |
Finding Term Frequency and Inverse Document Frequency Utilizng NLTK (Python 3.5)
Question: I'm trying to utilize NLTK to perform term frequency (TF) and inverse document
frequency (IDF) analyses on a batch of files (they happen to be corporate
press releases from IBM). I know that the assertion of whether or not NLTK h... |
'str' object has not attribute 'subs'
Question: Here is my Python code written in Vim. Whenever I run it, I get the error
`'str' object has not attribute 'subs'`
from sympy import *
x,a_test,b_test,fa_test,fb_test=symbols('x a_test b_test fa_test fb_test')
expr=raw_input("enter the equation")
... |
Printing out a proper bill producing program in python
Question: relatively new to programming in python, thank you for all the fast help that
was provided on my last question I had on another python project. Anyways, Ive
written a new program for a project in python that produces a bill for a
catering venue. This is m... |
sha1 collision of less than 512 bit
Question: In Wikipedia [SHA-1 pseudocode](https://en.wikipedia.org/wiki/SHA-1), it's
said:
> Pre-processing: append the bit '1' to the message e.g. by adding 0x80 if
> message length is a multiple of 8 bits. append 0 ≤ k < 512 bits '0', such
> that the resulting message length in bi... |
Python - Unzip .gz files in parallel
Question: I have multiple .gz files that add up to 1TB in total. How can I utilize
Python 2.7 to unzip these files in parallel? looping on the files takes too
much time.
I tried this code as well:
filenames = [gz for gz in glob.glob(filesFolder + '*.gz')]
de... |
moving average of 3 elements by C or Python
Question: I want to calculate the moving average of 3 elements.
For example, I have a 25 elements of sales data. I need to calculate the
moving average taken from averaging these 25 elements of data.
When a real array is given as data, I want to write a program that will
de... |
How to remove an app from a django projects (and all its tables)
Question: I want to remove an app from a django project.
I want to remove
* the tables of the app
* the content-types
* foreign-key usages of these content-types
Running `manage.py migrate app_to_remove zero` does not work:
django.... |
Replace 4-5 lines of a large text file using python
Question: I have a text file in which i need to change
USER PROMPT [Program SIM GENTEST05]
<Description />
<MultiPartMessage>false</MultiPartMessage>
<NumberOfMultiParts>0</NumberOfMultiParts>
<Commented>false</Commented>
... |
Importing from a git sub-module (ImportError)
Question: I get an `ImportError` when I am importing from a sub-module in the way I
thought One Was Supposed To Do It.
I have the following package:
pkg/
__init__.py
cow.py
pizza.py
pkg.py
components/
components.py
... |
Amino acid sequences in pyplot (Same regions in both sequences)
Question: I'm beginner at python, and need your help :) I have to compare two sequences,
when amino acid is similar at both sequences (doesn't matter which position it
is) program should put in into graph as point.
For example: If we have two sequences
x... |
Find and rename files using a Python script
Question: I am new to Python coding so here a question. I want to find files that are
called "untitled" with any kind of extension, e.g. jpg, indd, psd. Then rename
them to the date of the current day.
I have tried the following:
import os
for file in... |
installing Theano with Enthought Canopy on Windows
Question: I'm trying to install Theano, here is my situation.
The system is Windows 10 (64-bit), with CUDA 7.5 installed with Visual Studio
2013. The Python distribution is Enthought Canopy (2.7.10, 32-bit) with pip,
numpy (1.9.2-3) and scipy (0.17.0-2).
The installa... |
WARNING:oauth2client.util:build() takes at most 2 positional arguments (3 given)
Question: I am doing the "Label Detection" tutorial for the Google Cloud Vision API.
When I pass an image to the command like so I expect to get back some json
telling me what is in the image.
However, I am getting this error instead.
... |
python 'TypeError: argument must be string or read-only character buffer, not tuple'
Question: I wrote this code using python 2.7:
class LoadBalancerHandler:
def __init__(self, file_name):
self.server_socket = socket.socket(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
f... |
How to reshape this array with numpy?
Question: My file looks like this
3.766204987418e+00 3.016098278453e+00 2.882128625608e+00 2.789447648712e+00 2.704276250639e+00
2.540138572067e+00 2.318587560199e+00 2.272640952350e+00 2.138794921589e+00
I have also code to read it
... |
Incompatible GraphDef versions in Extend
Question: I have some code which creates a graph to process some images and then
iterates `sess.run()` in a loop to fetch batches of image tensors of shape [*,
299, 299, 3]. I'd like to then feed these images into the inception model.
So, I added some code to load the inception... |
Executing R script with Python via subprocess.call
Question: I have a R script which works fine on its own but I need it to be a part of
python script. So, when I run the python script the R script be executed
automatically. I use the below command; there is no error but the R script
output files are not created.
... |
How to prevent a QDoubleSpinBox from changing values
Question: I've written a GUI for a script that does some geometrical calculations.
Certain ranges of values break the computation (e.g. find the intersection of
two shapes that don't intersect.) I raise exceptions in those cases. I'd like
to prevent the user from adj... |
Plotting to browser continuously using serve_figure
Question: I want to see plots in progress continuously driven by the plot program using
browser whenever it is connected. I searched and found serve_figure.py
examples that are similar to what I need. But I cant get the following test
code to work. Serve_figure.py hol... |
Django won't create a table for one model of many in an app
Question: _I'm using Django 1.9_
For whatever reason, I simply cannot get Django to create a table for any more
models in my `products` app. After I added the `store` model and registered it
on `admin.py` and running `manage.py makemigrations` & `manage.py mi... |
Alpine 3.3, Python 2.7.11, urllib2 causing SSL: CERTIFICATE_VERIFY_FAILED
Question: I have this small Dockerfile
FROM alpine:3.3
RUN apk --update add python
CMD ["python", "-c", "import urllib2; response = urllib2.urlopen('https://www.python.org')"]
Building it with `docker build -t alpine-... |
Problems using MySQL with AWS Lambda in Python
Question: I am trying to get up and running with AWS Lambda Python (beginner in Python
btw) but having some problems with including MySQL dependency. I am trying to
follow the instructions
[here](http://docs.aws.amazon.com/lambda/latest/dg/lambda-python-how-to-
create-depl... |
Python script for performance testing of server
Question: I dont want to use any testing tool.. I am writing python script which hits
rest api to server... I want to hit 500/any_number_of hits of login/any api to
server at a same time so that I can check performance of server.
def login():
... |
Substract current time to -GMT in python
Question: I have a time which is 13:11:06 and i want to -GMT (i.e -0530). I can minus it
by simply doing -5 by splitting the string taking the first digit (convert to
int) and then minus it and then re-join. But then i get it in a format which
is 8:11:06 which is not right as it... |
Extracting datetime info from yeardatescalendar in python
Question:
import calendar
calendar.Calendar().yeardatescalendar(2014)
>>> [[[[datetime.date(2013, 12, 30), datetime.date(2013, 12, 31),...
The above code returns datetimes for calendar year 2014. However, it also
includes the last 2 days ... |
How to run commands on same TCL shell using Python
Question: I am having all the libraries written in TCL. I want to create a GUI in Python
which will have few buttons and other options. In the start TCL shell will
open. When I will click the buttons, respective commands will be executed on
the TCL shell.
Is it possib... |
Splitting Regex response column on python
Question: I am receiving an object array after applying `re.findall` for link and
hashtags on Tweets data. My data looks like
b=['https://t.co/1u0dkzq2dV', 'https://t.co/3XIZ0SN05Q']
['https://t.co/CJZWjaBfJU']
['https://t.co/4GMhoXhBQO', 'https://t.c... |
Python: Open .doc file with antiword on windows
Question: I am trying to open a bunch of .doc files (not docx) in a folder using python.
I downloaded a modified "antiword" which was a precompiled execute file for
windows as the original antiword is only available for linux.
<http://www-stud.rbi.informatik.uni-frankfu... |
How to split file into chunks by string delimiter in Python
Question: I'm gonna need to upload a potentially large csv file into my application.
Each section of that file is indicated by a `#TYPE *`. How should I go about
splitting it into chunks and doing further processing on each chunk? Each
chunk is a list of heade... |
Choosing and iterating specific sub-arrays in multidimensional arrays in Python
Question: This is a question that comes from the post here [Iterating and selecting a
specific array from a multidimensional array in
Python](http://stackoverflow.com/questions/35769536/iterating-and-selecting-a-
specific-array-from-a-multi... |
Accessing Flask wsgi structured app from interpreter
Question: I have a Flask app structured for deployment as wsgi. An issue I have is when
I want to load files from the Python interpreter.
The structure is:
|----api
|---------api
|--------------static
|--------------templates
|--------... |
Python: Finding unknown repeated word(s) in a list of strings
Question: I have a list of strings, which are subjects from different email
conversations. I would like to see if there are words or word combinations
which are being used frequently.
An example list would be:
subjects = [
'... |
Python - OpenCV VideoCapture = False (Windows)
Question: I have a simple piece of code, written in Python (version 2.7.11) designed to
do things to a video file as follows:
import cv2
cap = cv2.VideoCapture('MyVideo.mov')
print(cap)
print(cap.isOpened())
while(cap.isOpened()):
... |
Sorting Issue in Python
Question: I am attempting to sort a list which I have imported from a file in Python,
however I am having no luck, does anyone know what I am doing wrong?
fr = open("database_results\Class_" + option + ".txt", 'r')
lines = [line for line in fr if line.strip()]
fr.close()
... |
Python and sqlite3 : insert matrix into table
Question: Let's say i have this matrix:
[[[u'artist1'], [u'song1']], [[u'artist2'], [u'song2']], [[u'artist3'], [u'song3']]]
I was wondering how can i insert it into a sql table so it will look like
this:
ID | ARTIST |SONG
-----------... |
CX_Oracle - import data from Oracle to Pandas dataframe
Question: Hy,
I'm new in python and I want import some data from a Oracle Database to python
(pandas dataframe) using this simple query
SELECT*
FROM TRANSACTION
WHERE DIA_DAT >=to_date('15.02.28 00:00:00', ... |
Faking a time stamp from time.time() in Nose
Question: I'm building a device object to poll data from connected devices in python and
I'm trying to test the inter workings of the object and all it's functions
using nose. I am running into a problem in general when writing a timestamp
using `time.time()` as each time th... |
Best way to partially deep copy a dictionary in Python?
Question: I have a graph that is represented as a `dict` where each key is an instance
of a (self-defined) `Node` class and the values are sets of instances of
`Nodes`. So, basically, the graph looks something like this, but way larger:
`g = { Node1 : {Node2, Nod... |
Click error "takes no arguments" in main()
Question: I am having issues which I believe are due to click. I am trying to run this
code and I keep running into the same traceback TypeError stating an argument
is being passed to main().
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
... |
Encrypting user input in Python with pyCrypto
Question: I am trying to do basic encryption in Python, in below program I encrypt
whatever user types in, and then I am displaying it back to the user after
decryption. I am using the pyCrypto library which I downloaded from here:
<http://www.voidspace.org.uk/python/module... |
Get Common OS name of Linux Python
Question: I am trying to get Linux distro name like centos, fedora, ubuntu, SuSE etc in
python.
I made use of platform module.
My code is
import platform
version = platform.platform(aliased=0)
version = version.split('-with-',1)[1].split('-',1)[0]
print ... |
logistic_sgd module, where to find it?
Question: doing a deep learning tutorial and my python cannot find that module.
from logistic_sgd import LogisticRegression, load_data
ImportError: No module named logistic_sgd
How can i install it ?
Answer: Download and Save logistic_sgd.py from the fol... |
How to sort a dictionary in Python?
Question: I would like to generate a report where my first column would contain the
duration of my SQL queries. That should be sorted by highest duration to the
lowest one.
Code:
import os
directory = "./"
results = {}
def isfloat(value):
t... |
Using py_compile.compile() from within a Python script
Question: I am trying to understand [the
docs](https://docs.python.org/2/library/py_compile.html).
MY Python script generates Python code which will be run much later, so I want
to check now if what I generated is valid.
The docs say `py_compile.compile(file[, cf... |
How to use Boost.Python
Question: I just recently discovered Boost.Python and I am trying to figure out how it
works. I tried to go through [the tutorial on the official
website](http://www.boost.org/doc/libs/1_60_0/libs/python/doc/html/tutorial/tutorial/hello.html).
However, I got
link.jam: No such file... |
How to validate the syntax of a Python script?
Question: I just want the simplest possible way for my Python script to ask "is the
Python code which I just generated syntactically valid Python?"
I tried:
try:
import py_compile
x = py_compile.compile(generatedScriptPath, doraise=True)... |
Python will not print to a text file
Question: For some reason, the following code is unable to print to `Cache.txt`
import random
import time
text_file = open("Cache.txt", "w")
text_file.write("Numbers Used \n")
print("Welcome to the Bingo number generator")
UserNumber = st... |
error using twilio.rest in python3
Question: I'm having an exception occur that I can't understand.
I'm using `twilio.rest` in python 3.4.2 and when I call the twilio api, I'm
receiving
> AttributeError: 'module' object has no attribute 'Http'
> (http2lib?)
I am using
from `twilio.rest import TwilioRestClient`
... |
Problems importing from python package (local vs on the python path)
Question: I am unable to get the following things to work simultaneously in Python2.7:
* import submodules from a local package
* import submodules from the package when it is on the PYTHONPATH
I have set up the sample directory structure as in... |
2D heat map using python and matplotlib
Question: I need to plot 2D "heat map" using python using data from my file. My file has
3 columns x,y, value. x goes from 1 to 199 and y from 1 to 49. I've managed to
use code from here: [Make a 2D pixel plot with
matplotlib](http://stackoverflow.com/questions/6323737/make-a-2d-... |
Python.net and DLLs
Question: I want to call a .Net dll using Python.net. Essentially what I want to do is
operate a hardware device that comes with some dlls and sample C# code for
operating it.
The sample of C# code I want to reimplement in python is:
string[] strDeviceKeys = null;
CmdLib8... |
Python 2.7: applying str to collections.Counter and collections.defaultdict
Question: collections.Counter and collections.defaultdict are both inherited from dict.
So what is the difference between them which causes non-similar output
('class' and 'type')?
import collections
print str(collection... |
Passing a list to a function in order to move objects in tkinter (python 3)
Question: I am making a rubiks slide game. The first functioning button I am doing is
the clockwise button (every other button does nothing). i have the four
positions of squares set, and put them in a list called board. I then call the
list to... |
How to get all forms on webpage using python selenium?
Question: I searched for answer before ask here but didn't get lucky enough. So here it
goes, I am doing web scraping using python selenium. before choosing selenium
I checked for mechanize, scrapy but I failed to execute some button clicks
with them then I checked... |
Multiple Matrix Multiplications with Numpy
Question: I have about 650 csv-based matrices. I plan on loading each one using Numpy as
in the following example:
m1 = numpy.loadtext(open("matrix1.txt", "rb"), delimiter=",", skiprows=1)
There are matrix2.txt, matrix3.txt, ..., matrix650.txt files that I... |
Django error: datetime.datetime
Question: When I execute `python manage.py migrate`, I get this error on the screen:
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 146, in column
sql
default_value = self.effective_default(field)
File "/usr/local/lib... |
python - web scraping BeautifulSoup and urllib
Question: I am using python 3.4 and my script looks like:
import urllib
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
from bs4 import BeautifulSoup
url = "http://www.embassy-worldwide.com/"
... |
Attribute error : RPi.GPIO.PWM has no attribute 'ChangeDutyCycle'
Question: So i'm making a little robot using a raspberry pi B+ , everything is going
fairly nicely, but I get this error message that I don't seem to be able to
solve ..
Attribute error : RPi.GPIO.PWM has no attribute 'ChangeDutyCycle'
Here's two thing... |
Unicode error ascii can't encode character
Question: I am trying to import a csv file in order to train my classifier but I keep
receiving this error
traceback (most recent call last):
File "updateClassif.py", line 17, in <module>
myClassif = NaiveBayesClassifier(fp, format="csv")
File "C:\... |
Cookies and render for an angular js app using Phantomjs and python
Question: I have an object that can call a web page fine, even with `add_cookie`.
However, I want to render a site that is making heavy use of angularjs. For
some reason I seem to be unable to set the correct cookies, which I have
pulled from a live se... |
normalizing JSON datestrings to UTC python
Question: I have an important test that says "Calculate users that logged in during the
month of April normalized to the UTC timezone."
Items look as such:
[ {u'email': u' ybartoletti@littel.biz',
u'login_date': u'2014-05-08T22:30:57-04:00'},
{u'emai... |
Concatenate audio files [Python 2.7]
Question: **Is** there any way to concatenate or merge two audio files into one?
**Requirements** : Must use built-in modules only [may use PyGame]
**Audio File format** : .wma OR .wav OR .mp3
I have looked at many questions now and found solutions that involved
downloading modul... |
Reading Twitter JSON result
Question: What is the correct way to read these twitter search results?
{u'contributors': None, u'truncated': False, u'text': u"Google's deep learning project can figure out where any photo was taken, without geotags https://t.co/8URtvHUgjx https://t.co/hTQobCpA4U", u'is_quote... |
How to remove first few characters from every 1st line of each json file
Question: I am relatively new to python. I am trying to merge all JSON files into a one
single JSON file from a folder. I could do my merge. However I would like to
remove the some characters of the 1st line in every file to make the entire
JSON v... |
python read csv file with row and column headers into dictionary with two keys
Question: I have csv file of the following format,
,col1,col2,col3
row1,23,42,77
row2,25,39,87
row3,48,67,53
row4,14,48,66
I need to read this into a dictionary of two keys such that
dict1[... |
Proxy to mock ec2.describe_regions() (AWS)
Question: I'm makeing a simple proxy with Flask to mock the call describe_regions() of
AWS.
The Flask server has de following code:
from __future__ import unicode_literals
from flask import Flask
from flask import Response
from flask import str... |
How can I improve the performance of the below python code
Question: I wrote this piece of code shown below. I am having severe performance issues
with it. Especially the loop where i loop 50 million times(for z in
range(total):) seems very slow. Could I modify it to be a bit more efficient?
- Maybe modify how it is st... |
how to remove headers/meta data of JSON using Python
Question: I'm learning Python-JSON. Ive been trying to pull data from Quandl API, I was
successful in loading the data, but when i've tried to convert it to a Python
Dict, Its throwing a ValueError !
ValueError Traceb... |
Drawing half a square with Python turtle
Question: Good day,
I'm trying to write this python code for this two part problem and here is
what I have so far. How somebody be able to help me finish it and or correct
it? 
Here is my attempt:
#Question 11a
... |
Module inside module error, python
Question: I created a File named StringPlay.py, and called it upon a file ScanTheFile.py
then called a function in ScanTheFile.py in another file named Controller.py.
But it raise an error that StringPlay.py does not exist
In ScanTheFile.py
import StringPlay as SP
... |
Functional start and stop button in a GUI using pyqt or pyside for real time data acquisition using pyqtgraph
Question: I am implementing my program using the scrollingplots example provided by
pyqtgraph here
<https://github.com/skycaptain/gazetrack/blob/master/gui/pyqtgraph/examples/scrollingPlots.py>
i... |
Python code to click on anchor tag
Question: I am writing a python code to automate a web page. I need to click on play
button to play the recording. But I am not able to do so through the code.
**Inspect element gives me this - outer HTML of 'play' :**
<div class="play">
<a id="sm_1855464769" class... |
My Python turtle doesn't work when ran in python shell
Question: I am using the Python turtle module and have created the code below:
import turtle
def draw_square(some_turtle) :
some_turtle.forward(100)
some_turtle.right(90)
some_turtle.forward(6)
some_turtle.rig... |
Tkinter error UnboundLocalError: local variable 'flag' referenced before assignment
Question: I am trying to build quiz using tkinter and python 2
I am having trouble with maintaining score. The validate button can be pressed
multiple times which increments global score counter. 1) I've one flag
variable which will al... |
Detect holes, ends and beginnings of a line using openCV?
Question: I'm trying to create a Python script that detects holes, ends and beginnings
of a line. I thought that openCV would be great to achieve this.
So for example everything starts with this image:
[ PowerPoint presentation, insert an image in slide number
4 (do nothing w... |
Creating a Pandas Series with a period in the name
Question: I ran the following Python code, which creates a Pandas DataFrame with two
Series (`a` and `b`), and then attempts to create two new Series (`c` and
`d`):
import pandas as pd
df = pd.DataFrame({'a':[1, 2, 3], 'b':[4, 5, 6]})
df['c'] = d... |
Get all contents between the result tags of a SOAP response in Python
Question: I have this SOAP response :
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/20... |
Why is pool.map slower than normal map?
Question: I'm trying the following code:
import multiprocessing
import time
import random
def square(x):
return x**2
pool = multiprocessing.Pool(4)
l = [random.random() for i in xrange(10**8)]
now = time.time()
... |
How to define a new function in pdb
Question: Why can't I define new functions when I run `pdb`?
For example take myscript.py:
#!/gpfs0/export/opt/anaconda-2.3.0/bin/python
print "Hello World"
print "I see you"
If I run `python -m pdb myscript.py` and try to interactively define a new
func... |
Python and Arduino issues
Question: I’m having some issues, trying to control a servo connected to a arduino board
from python. In the program I write a value 0 – 180 and send it to the
Arduino, the Arduino should than turn the servo to the selected place. The
problem is that it’s seams that the data sent from python i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.