text stringlengths 226 34.5k |
|---|
how do I run command line from python
Question: I have the following command I run in terminal:
mongoexport --db database_name --collection agents --type=csv --fieldFile agFieldsTest.txt --out file/path/agTestInfo.csv
I tried to run it using:
>>> import subprocess
>>> subprocess.... |
Sqlite using Python3 error?
Question: I am trying to insert some data into a sqlite database by following : -
param = '("593863695396044801","Ivan F. Siahaan","307783731","None","65","83","Thu Apr 30 19:45:13 +0000 2015","xyz")'
>>> conn.execute("INSERT INTO data "+param) Traceback (most recent ... |
search regex line by line and print multiple lines after match
Question: just started writing scripts.
I am trying to write 4 lines after matching a regex in the first line and do
this through a very large file with thousands of lines.
#!/usr/local/bin/python
import sys
import string
import ... |
Python draw rectangle and color in range
Question:
import brewer2mpl
import numpy as np
a = np.random.rand(3) # a[0] represents value of rect1, a[1] of rect[2]....
def get_colors():
"""
Get colorbrewer colors, which are nicer
"""
bmap = brewer... |
Python script that launches MPV
Question: I wrote a python script to make the use of mpv easier (cim is the title).
Here's the script:
from sh import mpv
cim=input("Cím: ")
a=int(input("with start(1) | without start (2) "))
b=int(input("with sub (1) | without sub(2) "))
if a == 1:
... |
python how to store a list in a file and get it back
Question: I have a list with a lot of things in. At the end of my script I would like to
store it in a file.
And when I start another script another day, I would like to extract my list
from my file and then use it.
I don't know if it's the best way to do this. ... |
Python 3.x - toggling fullscreen in tkinter
Question: So far, I have a command that makes my window fullscreen. Now, predictably, I
want to be able to exit fullscreen also.
This is the code I have:
def toggFullscreen(self, win):
def exitFullscreen(event=None):
win.withdraw()
... |
How to Prepare Data for DecisionTreeClassifier Scikit
Question: I have the following Data in csv , the top row indicate column headers and
data is indexed, all the data is dicretized. I need to make a decision tree
classifier Model . Could some one guide me with this.
,age,workclass,fnlwgt,education,... |
Equation solver webapp in Python
Question: I am making an equation solver webapp in Python (Flask framework). App takes
user input [a, b, c] and sent to server by calling a server side python
function and get the results displayed using AJAX.
Part of Client JavaScript:
$.getJSON($SCRIPT_ROOT + '/_server... |
python querying a json objectpath
Question: I've a nested json structure, I'm using objectpath (python API version), but I
don't understand how to select and filter some information (more precisely the
nested information in the structure).
EG. I want to select the "description" of the action "reading" for the user
"Jo... |
"struct.error: unpack requires a string argument of length 4" when slicing [:3]
Question: I have a problem with a little server-client assignment in python 2.7.
The client can send 5 types of requests to the server:
1. get the server's IP
2. get contents of a directory on the server
3. run cmd command on the se... |
Call Rails 4 param in Python script
Question: I am trying to use a form input from a rails controller in a Python script. I
have a form on my rails (version 4.2.1) app that take in a url, then I want to
use that url in a Python script. I'm new to rails and have no idea how to do
this. My app has gotten as far as taking... |
'Communicate' in Python does not work
Question: I'm trying to write a python program to test a java program that takes input
from stdin using Scanner.
All other posts point to using communicate with popen, but for me it
absolutely does not work. When i run my python program, it just calls popen
and then stops while th... |
Ipython notebook widgets not showing values
Question: For some reason my Ipython notebook widgets stopped working after I upgraded
to pandas 0.16 (seems unrelated but thought I'd mention it). I'd love to post
a screenshot but StackOverflow won't let me because I'm new and don't have
enough "reputation" apparently. I'm ... |
How do I best parse a date string in the Python C API?
Question: Unfortunately there seems to be no `PyDateTime_FromString()` (equivalent to
e.g. `PyFloat_FromString()`) in the Python C API. Has anybody figured out what
would be the ideal workaround if I have to parse a date string into a
`datetime.datetime` type?
An... |
How to print pandas dataframe values in a sentence
Question: I have created a database using sqlite within python 2.7, and loaded the data
into the pandas dataframe as below. What I'm trying to do is I would like to
print the result as "The cities that are warmest in July are: Istanbul,
Ankara, Izmir, Bursa". The code ... |
python soaplib ImportError: No module named core.service
Question: I'm developing python application and using soaplib for use in .net but when I
run the code , I ran into this error
Traceback (most recent call last):
File "soap.py", line 2, in <module>
from soaplib.core.service import rpc,... |
match a specific string in excel and print those rows using python
Question: i am trying to print values from 4 columns in a excel. i need to match on a
particular string in the 4th column and then print only those rows which have
that string. (eg: if my 4th column in the 2nd row contains 'Sweet' i will
print the entir... |
How to delete certain words from a variable or a list python
Question:
common_words = set(['je', 'tek', 'u', 'još', 'a', 'i', 'bi',
's', 'sa', 'za', 'o', 'kojeg', 'koju', 'kojom', 'kojoj',
'kojega', 'kojemu', 'će', 'što', 'li', 'da', 'od', 'do',
'su', 'ali', 'nego', ... |
Python Doubly Linked List Node Removal
Question: I created a basic doubly linked list class in Python, and it has three
methods: append, remove, and show. I fully understand the append method, and I
fully understand the show method. However, I am mildly confused about the way
my remove method works.
These are my two c... |
python http requests; browser not detected
Question: I want to login to my account with the following structure:
import requests
session=requests.Session()
resp=session.get('https://mywebsite.com/login')
cont=resp.content
post_data={'user':'username', 'pass':'password'}
post_response=... |
Flask Application - How to link a javascript file to website
Question: I am having some trouble getting started with using javascript files on my
website (A Flask application). I start the website by running run.py which
looks like this:
#!flask/bin/python
from app import app
app.run(debug=True)
... |
*Efficiently* moving dataframes from Pandas to R with RPy (or other means)
Question: I have a dataframe in Pandas, and I want to do some statistics on it using R
functions. No problem! RPy makes it easy to send a dataframe from Pandas into
R:
import pandas as pd
df = pd.DataFrame(index=range(100000),... |
Why doesn't my Python script recognize a class from an imported module?
Question: **collection.py**
import sys
import os
import pymongo
from pymongo import MongoClient
class Collection():
"""returns a collection curser from mongodb"""
client = MongoClient()
... |
Sympy failed to render matrix
Question: I'm using IPython's Qtconsole and use default setting of printing setting. It
works well for polynomial, but do not work for Matrix
from sympy import init_printing, Matrix
init_printing()
a=Matrix([1,2])
a
the error is
ValueError:
... |
Abaqus Python Scripting - Create ODB without submitting Job
Question: I'm looking to create a simple ODB file using my model in session so that I
can display an orientation tensor in a custom field. I'm able to create an ODB
for a 2d part (made of s4 elements), but my system crashes whenever I load the
ODB for my 3d pa... |
I want to sort a list in a method with respect to the method's argument
Question: I have a method and as an argument I enter x and y coordinates of a point and
then I calculate the power reached to that [x,y] coordinate from other points
and sort them in order of highest power reached to lowest:
def powe... |
Node add-on with C++ on Windows 8
Question: I am trying to run basic code of "Hello World", while node Addon C++ way. None
of the stuff is different from wats the official standards of node addon
mentioned in the url <https://nodejs.org/api/addons.html>
I first created the **hello.cc** file which below mentioned code:... |
TypeError: Collection(Database(MongoClient("localhost", 27017), u'demo_database'), u'entries) is not JSON serializable
Question: Good afternoon.
I'm trying to combine Python, MongoDB (via pymongo) and Flask to create
client-server application. I want to use one of methods to return all the
entire collection, like here... |
parsing string with specific name in python
Question: i have string like this
<name:john student male age=23 subject=\computer\sience_{20092973}>
i am confused ":","="
i want to parsing this string!
so i want to split to list like this
name:john
job:student
sex:male
age... |
Python: Aaccess a function within another class
Question: I'm trying to access a function within another class, and doing that going
through a "master" class. I have successfully accessed the "master" class
through the Column 4 button, I'm trying to access the master class through the
column 5 function, and then make t... |
How to make a python program open itself as text in safari?
Question: I was trying to make a program in Python that would use os.system to open a
file in Safari. In this case, I was trying to have it open a text copy of
itself. The files name is foo.py.
import os, socket
os.system("python -m SimpleHT... |
Python: Tkinter: Multi line scrolling entry box
Question: I would like to make a Tkinter window able to ask for a multi line entry (so
the user will add one or more lines of text) And then when we clic on the
button be able to retrieve the values entered by user for further use.
Until now I have this script:
... |
TypeError: get_params() missing 1 required positional argument: 'self'
Question: I was trying to use `scikit-learn` package with python-3.4 to do a grid
search,
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.linear_model.logistic import LogisticRegression
from sklearn.pi... |
incrementing list values Python 3
Question:
infile = open('numbers.txt','r')
c = 0
for i in infile:
if int(i) > c:
c = int(i)
hist = [0]*c
for i in infile: #checking
ii = int (i)-1
hist[ii] += 1 # problem area seemingly
for i in range(c):
... |
Accessing URLs from a list in Python
Question: I'm trying to search a HTML document for links to articles, store them into a
list and then use that list to search each one individually for their titles.
Answer: It's possibly not direct answer for OP, but should not considered as off-
topic: **You should not parse web... |
How to print c_type byte array as set of hexadecimal values in python?
Question: I have data structure defined as follows:
class Factory_Params_Get_Command(Structure):
_pack_ = 1
_fields_ = [("SN",c_byte * 32),
("Voltage",c_byte),
("Reserved",c_byte * 30)]
# Pr... |
Python TypeError: unorderable types: builtin_function_or_method() < int()
Question: I keep getting this error while trying to do a Python program. The point of
the program is to keep on rolling a set of die, until the user enters a number
less than 0.
import random
num_sixes = 0
num_sevens =... |
How to copy a folder (divide into sub folders) using Python?
Question: i try to copy a directory (divided into folders and subfolders) to a new
folder that will be created.i work with python 2.7.
* dir_src = an exist folder
* dir_dst = a new folder (not exist) that all the folders will be copied to
I read <https... |
Twitter Stream not working for Tweepy
Question: Using the code below, I'm trying to get a hash tag. It works fine for larger
searches like #StarWars, but when i ask for smaller ones it doesn't seem to
return anything.
Ideas?
_'code' is used instead of the actual strings for authentication_
from tweepy.... |
Subtract List B from List A, but keeping the List A index and using difflib string similarity
Question: I need some help with Python. This is not the classic subtract List B from
List A to make List C. Instead I would like to look at the indexes of the
items in List A (city names in a single word) that are not in List ... |
Using Django/python to JSON posts
Question: I'm new to using Django so please forgive my ignorance with such a general
question. How would you go about displaying JSON posts from a python script? I
have a python script which updates an sqlite3 database and creates a JSON
object. I want to display this data on a Django ... |
Use with..open to read a list of xls files to copy into a single workbook with multiple sheets
Question: First timer here. My overall goal is to copy exactly, the data in 3 different
xls files into one xls workbook with a sheet for each original xls file. In a
non-programmatic sense, I want to copy and paste the data f... |
How to check if a word is more common in its plural form rather than in it's singular form in an array of words (with Python/NLTK)?
Question: I'm trying to do the NLTK exercices but I can't do this one. "Which nouns are
more common in their plural form, rather than their singular form? (Only
consider regular plurals, f... |
Parsing text event file in Python
Question: I have a large text file with Event data that I am trying to parse to a csv.
The structure looks like this:
START
USER: a
TIME: 1000
CLICKS: 1
COMMAND A: 2
COMMAND B: 1
END
START
USER: b
TIME: 00
CLICKS: 1
COMMAND A: 2
COMMAND B: 1
COMMAND C: 1
EN... |
Echoing messages received through UDP back through a different TCP port
Question: I use Python 2.7.x (2.7.8) and am trying to write a program using twisted
python to function like this:
* Program waits for a messaged received through TCP 7001 or UDP 7000.
* Messages received through UDP 7000 are bridged over to TC... |
PYTHON 3: Read a file and map the coordinates to the turtle screen
Question: So I have to write a program that reads a `csv` file which contains earthquake
data, it then takes only the latitude and longitude from the file and map it
to the turtle screen in Python 3.
This is the [CSV file](http://textuploader.com/gayg)... |
Is there any function in Python similar to 'which' and 'open' in matlab?
Question: In matlab, it's easy to find the path to a '.m' file by 'which XX.m' and also
convenient to view the code by 'open XXX.m'.
In Python, is there any similar command?
Answer: If you've already imported the module (or can do so without an... |
How to check if linux host is up-to-date with python yum module
Question: The yum commandline tool has an option to check if a host is up-to-date or if
there are any (security-) updates available.
$ yum check-update
Python has a "yum" Module - it offers functions like:
import yum
... |
With python multiprocessing how can child process terminate another child process?
Question: I have two child processes created by my main application process.
A = Process(target=a, args=(aaa,))
B = Process(target=b,args=())
For the sake of argument they are called A and B; How could proce... |
Python error when executing shell script
Question: I'm executing a line of shell script using python. It isn't working with
`which` to test of the existence of homebrew
#!/usr/bin/python
import sys, subprocess
subprocess.call(["which python"])
throws the long error
Traceback ... |
Batch Gradient Descent for Logistic Regression
Question: I've been following Andrew Ng CSC229 machine learning course, and am now
covering logistic regression. The goal is to maximize the log likelihood
function and find the optimal values of theta to do so. The link to the
lecture notes is: [<http://cs229.stanford.edu... |
How to get the authenticated user name under apache while in python code?
Question: Basically I just need to get the authenticated username from apache2, (for
basic / similar authentication schemes) but while in python.
In php, this is simple, and looks like this:
$username = $_SERVER['PHP_AUTH_USER'];
... |
Extracting data with Headless Selenium browser with Python
Question: I'm trying to find a way to extract the GA datalayer object from a website
with a headless browser via Python so therefore; I've follow the instructions
from [here](https://realpython.com/blog/python/headless-selenium-testing-with-
python-and-phantomj... |
Modifying html files in terms of tags?
Question: I have several html files, whose contents are like this:
<html>
<header>
<title>A test</title>
</header>
<body>
<table>
<tr>
<td id="MenuTD" style="vertical-align: top;">
... |
What's the difference between jython-standalone-2.7.0.jar and jython-2.7.0.jar
Question: I wrote a Java example, the code is:
import org.python.core.PyObject;
import org.python.util.PythonInterpreter;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import j... |
Python client write to Java's writeUTF method
Question: I have the following code snippet for a **Java** server that can't be changed:
....
while(true){
try {
System.out.println("Will listen . . .");
instruction = this.dis.readUTF(); // Socket's dataInputStream... |
Why default JSONEncoder in python cannot serialize abc.Sequence and abc.Mappings?
Question: So, if we create some class, implementing `collections.abc.MutableSequence`,
and `list` is such an example,
class Woof(collections.MutableSequence):
def __init__(self, data=[]):
self.s = list(d... |
Import scip to python
Question: I've tried unsuccessfully to get scip running with python. I'm using Yosemite
(10.10.3), python 2.7 and have installed scip optimization suit
(<http://scip.zib.de/download.php?fname=scipoptsuite-3.1.1.tgz>) with make.
I can start scip after the installation via the terminal.
... |
How to upgrade Django app from 1.6.11 to 1.8 when makemigrations crashes?
Question: I'm following the instructions to upgrade a Django app from Django 1.6.11 to
1.8.1. I've deleted all the migrations save for the **init**.py. I then run:
manage.py makemigrations
and it crashes with the following tr... |
Basic Auth for CherryPy webapp
Question: I'm trying to create a very basic cherrypy webapp that will ask the user for a
username and password before the first (and only) page loads. I used the
example set forth in CherryPy docs here:
<http://cherrypy.readthedocs.org/en/latest/basics.html#authentication>
Here's my spec... |
Why wouldn't Selenium be able to load a firefox profile?
Question: The following code:
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import ... |
file parsing using hive query issue
Question: I have a complex text file to parse and load for analysis.
I started off with a simple Hive query to parse a text file and load as a
table in HDFS.
I am using beeswax to run this query.
## name_area.txt
arun:salem anand:vnr Cheeli:guntur
Hive Query
CREATE TABLE test( ... |
How to Bind two different EVENT to one ListCtrl in wxpython without confliction?
Question: **I want to bind two event to one ListCtrl weight in wxpython.**
**Such as, left click and right click.** The former will refresh the content
of somewhere, and the later will create a PopupMenu, which contains something
about re... |
Python: My csv.reader imports csv file as text
Question: After importing `CSV` file, the output appears like `[['1', '2', '3']]`. How
can I make sure it is imported as a number?
Answer: With the csv module `reader` function a row read from the csv file is returned
as a list of strings. If you want unquoted numbers no... |
How to split dates from weather data file
Question: I am new in python and i would greatly appreciate some help. I have data
generated from a weather station(`rawdate`) in the format `2015-04-26
00:00:48` like this
Date,Ambient Temperature (C),Wind Speed (m/s)
2015-04-26 00:00:48,10.75,0.00
2015-... |
Import problems with Python namespace packages
Question: I am trying to use Python [namespace packages
concept](https://www.python.org/dev/peps/pep-0382/) to split my library across
multiple directories. In general, it works, but I have a problem regarding
importing names to projects package level.
My project structur... |
Image Gradient Vector Field in Python
Question: I am trying to get the [Gradient Vector
Field](http://upload.wikimedia.org/wikipedia/commons/thumb/0/0f/Gradient2.svg/566px-
Gradient2.svg.png) of an image using Python (similar to [this matlab
question](http://stackoverflow.com/questions/10416918/compute-gradient-vector-... |
TransportError(503, u'') when tying to use a recently created elasticsearch index
Question: I'm creating an Elasticseach index using Python API like this:
from elasticsearch import Elasticsearch
es = Elasticsearch()
index_body = {"mappings": {".percolator": {"properties": {"message": {"... |
Accessing a file path saved in a .txt file. (Python)
Question: I have a text file that contains file paths of files that I wish to open.
The text file looks like this:
28.2 -1.0 46 14 10 .\temp_109.17621\voltage_28.200\power_-1.txt
28.2 -2.0 46 16 10 .\temp_109.17621\voltage_28.200\power_-2.txt
... |
How to check whether a connection for a specific port is open using python
Question: I need to check whether a connection with some port is running on windows. I
can do it using netstat, but how can I check it using python?
Answer: Try like this:
import socket;
s = socket.socket(socket.AF_INET, soc... |
series object not callable with linear regression in python
Question: I am new to Python and I am trying to build a simple linear regression model.
I am able to build the model and see the results, but when I try to look at
the parameters I get an error and I am not sure where I am going wrong.
Code:
im... |
Python FFT & Magnitude Spectrum of two similar signals have different frequencies
Question: My goal is to compare the FFT of similar signals. For some reason, when I take
the magnitude spectrum of two signals of the same length, the frequencies are
different... I can't do a simple side by side comparison of two signals... |
how to load python script in interactive shell
Question: I am trying `sudo python get_gps.py -c` and expecting it to load the script
and then present the interactive shell to debug the script live as opposed to
typing it in manually.
Answer: From the docs:
$ python --help
usage: /usr/bin/python2.7 ... |
Pillow is not working
Question: I just started a new Django project and when I try to makemigratons I get an
error saying that I have to install Pillow and I have already installed
Pillow.
ERRORS:
shop.ProductImages.product_img: (fields.E210) Cannot use ImageField because Pillow is not installed.
... |
Traceback (most recent call last) error:
Question: Please help me n this i am not able to run getting error:
Error: File "C:/Python34/pyt.py", line 6, in <module> class Animal1: File "C:/Python34/pyt.py", line 30, in Animal1 cat = Animal1("cat",7) NameError: name 'Animal1' is not defined
Code:... |
Iterating through file multiple times (Python)
Question: I have a file that looks like this:
1,var1
2,var2
3,var3
4,var1_val1
5,var2_val2
6,var1_val2
7,var3_val1
8,var2_val1
9,var3_val2
Output file should look like:
var1 1 4 6
var2 2 8 5
var3 ... |
How to declare a module deprecated in python
Question: How to declare a module deprecated in python?
I want a warning to be printed whenever a particular module is imported or any
of its functions are called.
Answer: You want to
[`warn`](https://docs.python.org/2/library/warnings.html#warnings.warn) with a
[`Depreca... |
How to get system information in Go?
Question: Can anyone recommend a module which can be used to get system information,
like Python's `psutil`?
When I tried `>go get github.com/golang/sys get 'sys'`, I received the
following:
Report Error:
package github.com/golang/sys
imports github.c... |
Python loop in the directory inside directory
Question: I currently have the python code which loops in the directory, if it finds
another directory inside the directory, then it goes inside it & loops it
again to get all the files inside it. The directory traverse only one level.
Here is the code :
impo... |
Python multiple domain crawler InvalidSchema exception
Question: This is my code. My goal is crawl multiple domain. I set domains in url array
but I can't crawl.
The code can find urls but don't parse or crawl.
This is the results: my code run ('Total Link Number : ', 387) ('Links for
News: ', 146)
# -... |
Segmentation fault while using a C module in a .so file
Question: I got a segmentation fault – probably caused by the long loop – while running
my python script at the command line under Linux. I know exactly _where_ the
problem is, but I don't know _why_. I've tried some of the method I searched
online, including this... |
Warning "InsecurePlatformWarning" while connecting to Rally with python (using pyral)
Question: When I connect to Rally via the python REST API (pyral), I get the following
warning.
`C:\PYTHON27\lib\site-
packages\requests-2.6.0-py2.7.egg\requests\packages\urllib3\util\ssl_.py:79:
InsecurePlatformWarning: A true SSLCo... |
Tox and django_toolbar: ImportError
Question: When trying to use Tox to better streamline testing across multiple
environments, I'm runing into the following error when testing for Python 3.4:
`ImportError: No module named 'debug_toolbar'`
However, `django-debug-toolbar==1.3.0` is listed in my `requirements.txt`
file... |
Flask register_blueprint error (Python)
Question: Sorry for my English, but.. I need help.
I have a project on Flask. And when I include Blueprint on my Flask app I have
errors. The code is from a book, Miguel Grinberg about Flask.
Project tree:
.
├── app
│ ├── __init__.py
│ ├── main
... |
How does str(list) work?
Question: **Why does`str(list)` returns how we see list on the console? How does
`str(list)` work? (any reference to the CPython code for `str(list)`)?**
>>> x = ['abc', 'def', 'ghi']
>>> str(x)
"['abc', 'def', 'ghi']"
To get the original list back from the `str(lis... |
Parallel processing a large number of tasks
Question: I have 10,000 csv files for which I have to open in Pandas and
manipulate/transform using some of Pandas's function and save the new output
to csv. Could I use a parallel process (for Windows) to make the work faster?
I tried the following but no luck:
... |
Python2.7 - pip install pymssql fails on CentOS 6.3
Question: I am trying to install pymssql for Python on a CentOS machine however it keeps
failing on me.
I have already installed the following:
> freetds-devel
>
> python-devel
Which seems to be the fix I keep coming across in searches, however I have
already insta... |
Python utility for parsing blocks?
Question: I have a file that starts something like:
databaseCons = {
main = {
database = "readable_name",
hostname = "hostdb1.serv.com",
instances= {
slaves = {
conns = "8"
}... |
How many connections will open in mongodb in python?
Question: I am working with mongodb and python, for accessing the database I am doing
this:
#pymongo connection settings
from pymongo import Connection
connection = Connection('localhost', 27017)
db = connection['MyDB']
I am inserting... |
Python, I want to make list json.dumped But, error 'dict' object has no attribute 'dumps'
Question: below is my python code
r = requests.get("https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=50&channelId="+CHANNELID+"&order=date&key="+DEVELOPER_KEY)
json = r.json() ... |
Replicating request to Chef with Python RSA
Question: Goal: I need a Python 3 wrapper for Chef's REST API. Because its Python-3,
PyChef is out of the question.
Problem: I am trying to replicate the Chef request with Python RSA. But the
wrapper results in an error message: _"Invalid signature for user or client
'XXX'"_... |
Get all pixels of an Image [Wand]
Question: I am using the [Wand Python
Library](https://wand.readthedocs.org/en/0.4.0/index.html), and trying to
solve the [Python Challenge](http://pythonchallenge.com), and my current
problem asks me to get all even/odd pixels.
This is, obviously, a very simple task. However, I found... |
Python requests session keeps creating connection without reusing the connection
Question: I have the following code:
protocol = "http"
if self.protocol == PROTOCOL_HTTPS:
protocol = "https"
if self.session is None:
self.session = Session()
self.session.get(protocol+'://'+self.i... |
python just import fails but works with from
Question: Why does this not work:
import matplotlib.pyplot as plt
import os
import skimage
camera = skimage.io.imread(os.path.join(skimage.data_dir, 'camera.png'))
#plt.show(io.imshow(camera))
But using `from skimage import io` does. So t... |
Web application with python
Question: I have a Python program that takes one input (string) and prints out several
lines as an output. I was hoping to get it online, so that the web page only
has a text-area and a button. Inserting a string and pressing the button
should send the string to python and make the original ... |
How should I handle an error in Python 2.7 in the initialization method for a C extension?
Question: In Python 2.7 (which we need to support), the initialization function for a
C/C++ extension should be declared with the PyMODINIT_FUNC macro, which
effectively makes the function void. However, I'm not sure how we shoul... |
PyQT4 and Threading: Closing MainWidget after QThread finished and ListWidget updated
Question: I'm trying to understand how threading works in Python. Therefore I wrote an
application that is installing some packages in a separate QThread.
Once the worker is finished (finished Signal emitted), I'd like to wait a few
... |
Reading an image in python - experimenting with images
Question: I'm experimenting a little bit working with images in Python for a project I'm
working on.
This is the first time ever for me programming in Python and I haven't found a
tutorial that deals with the issues I'm facing.
I'm experimenting with different im... |
python multiprocessing/threading cleanup
Question: I have a python tool, that has basically this kind of setup:
main process (P1) -> spawns a process (P2) that starts a tcp connection
-> spawns a thread (T1) that starts a loop to receive
messages that are s... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.