Tagged Questions
Python is a dynamic and strongly typed programming language designed to emphasize usability. Two similar but mostly incompatible versions of Python are in widespread use (2 and 3). If you have a version-specific Python question consider using the [python-2.7] or [python-3.x] tags in addition to the [...
0
votes
0answers
2 views
Django 1.10 TemplateSyntaxError. Did you forget to register or load this tag?
I'm trying to load a css file from my static folder, and the "TemplateSyntaxError" is showing in this line:
Here is the code that I'm using to load a template
<!DOCTYPE html>
<link ...
0
votes
0answers
2 views
Python SDK list_shares does not return all shares
This code:
action = smartsheet.Sheets.list_shares(org_sheet.id,
include_all=True)
shares = action.result
for item in shares:
...
0
votes
0answers
7 views
Bypassing KeyError: ' ' when the word is not in the dic (word2vec)?
I'm using word2vec/similarity with two inputs in a loop, I'm getting KeyError when the words is not in dictionary. how to able to keep the loop running and put the unseen word value to zero.
My ...
-1
votes
0answers
20 views
Python performance testing on Windows and python3 [on hold]
I am looking for a way to monitor my python code base for performance regressions. Are there any solution that work on Windows and python3?
I was looking at vbench but could never get it to work on ...
0
votes
0answers
3 views
plotting multiple columns value in x-axis in python
I have a dataframe of size (3,100) that is filled with some random float values.
Here is a sample of how the data frame looks like
A B C
4.394966 0.580573 2.293824
3....
0
votes
0answers
3 views
Read H264 streaming from Elp H264 with OpenCV + Pyhton
I'm trying to read an udp streaming of a H264 encoded image. The software structure is like follows:
On a BeagleBoneBlack (Ubuntu 16.04) I've an Elp H264 cam (see here: https://www.amazon.com/ELP-...
1
vote
2answers
14 views
BeautifulSoup Extract striped Text without Tags
I'm trying to parse content from site (from table) and print only text from node, i'm using .text.strip() but it's doesn't works correct.
My code:
import requests
from bs4 import BeautifulSoup
r = ...
0
votes
0answers
5 views
Reading/Writing Binady Plist Files Using Python and PlistBuddy via AppleScript (macOS/Mac OS X)
all.
I'm endeavoring to write a Python script that will read and write to binary Plist files on macOS/Mac OS X. I'd like to do this using a command line tool that comes with the OS called PlistBuddy....
-2
votes
1answer
29 views
the system of quadratic equations python [on hold]
I got the system of quadratic equations:
y1 = 0.098*x^2 - 0.29*x
y2 = 0.041*x^2 - 0.126*x
y3 = 0.00071*x^2 - 0.085*x
I would like to find x that fulfill requirement that solutions for y1, y2 and y3 ...
0
votes
0answers
10 views
Fill web form without name and ID using python
I searched the methods to fill a form using python and found that almost all answers suggest to use "mechanize". But to use mechanize to fill a form, I need to select the form name before filling it.
...
2
votes
0answers
7 views
Can Omnicomplete in Vim for python/3 complete function names or just methods?
To illustrate my question, here is a simple example of how Omnicomplete is acting on my machine:
name = "Bob"
na<C-x><C-o> gives-----> name
name.<C-x><C-o> gives-----...
0
votes
1answer
14 views
Python: slowness on iterating over namedtuple and dicts for defined pairs
this code runs quickly on the sample data, but when iterating over a large file, it seems to run slowly, perhaps because of the nested for loops? Is there any other reason why iterating over items in ...
-1
votes
2answers
13 views
I'm trying to put these inputs into a text file, [duplicate]
In class we are working on functions that calculate the area of a square or rectangle. The program asks for a person's name, what shape they want and what the length and width are. It then prints the ...
-3
votes
1answer
31 views
Print Python Dictionary
I'm trying to print a Python3 dictionary using:
b_result_page = []
b_result_list = []
b_result_page_and_list = {}
#b_result page contains urls like: somesite.com?first=11
for brp ...
2
votes
0answers
19 views
Python - IndexError: tuple index out of range when using p2exe
I'm currently trying to make an executable using py2exe. I use Python 3.6. The script I'm using imports openpyxl and pptx and runs fine when I use Pycharm or run the script using the command window. ...
0
votes
0answers
6 views
AttributeError: Ui_MainWindow instance has no attribute
I have an issue with my class instance. In a function I try to call an object, which is actually defined above. But I always run into the same mistake. Namely AttributeError: Ui_MainWindow instance ...
-1
votes
1answer
38 views
I have two lists, I want to know if a date in one list is between two dates in another. How should I do this?
I have a list A that looks like this:
[((5.8, datetime.datetime(2016, 3, 5, 2, 8, 47))]
I have another list B that looks like this:
[((date1, datetime.datetime(2016, 2, 8, 1, 34)),
(date2, datetime....
0
votes
1answer
22 views
Pattern matching with REGEX returns None while it should not
I am learning REGEX and Beautiful Soup and I am doing the Google Tutorial on Regex. I am using the html files provided in the Google Tutorial website (exercise set in the set up section of the ...
2
votes
0answers
5 views
How to manually set exposure on a Facetime HD camera in Python opencv 3.2.0 OSX El Capitan
I am trying to figure out how to manually set the exposure for my Facetime HD camera in the opencv program I am writing in Python. I am using opencv version 3.2.0, python 2.7, and running on OSX El ...
0
votes
0answers
7 views
Managing HDF5 Object Reference
I am trying to load a mat file for the Street View House Numbers (SVHN) Dataset http://ufldl.stanford.edu/housenumbers/ in Python with the following code
import h5py
labels_file = './sv/train/...
0
votes
0answers
10 views
Intellisense not working for python.
Intellisense and Snippets for Python are not working after installing python by donjayamanne's extension (ext install python) on vscode 1.8.1. Even pressing ctr+space, it just keeps "Loading..." and ...
0
votes
0answers
13 views
Load last one pickled object from file
I am creating simple PyQt app that is using ListView widget to manipulate list of files (this is not important). I've got the list with dictionaries that contain info about files. Now, I want to ...
0
votes
0answers
8 views
How to calculate average color of a superpixel in scikit-image
I have segmented my image using the quickshift method found in the scikit image libary. How can I calculate the average color and the area of a superpixel? How can I interpret the return value of the ...
0
votes
0answers
5 views
Display Lengths of Line in Matplotlib 3D Scatter
Here's a tetrahedron I've created with correct geometry in matplotlib.
PLEASE DISREGARD BOTTOM, MIDDLE ATOM:::
The problem is, my middle (central)point doesn't seem to be equidistant to all points. ...
0
votes
0answers
15 views
DJango Persist session across 2 forms
I am trying to pass data (eventually dictionary, for testing I am passing a dummy variable) from one form to another. Its a multi step form.
For this I am using request.session object. However when ...
0
votes
0answers
7 views
How do you keep table rows together in python-docx?
As an example, I have a generic script that outputs the default table styles using python-docx (this code runs fine):
import docx
d=docx.Document()
type_of_table=docx.enum.style.WD_STYLE_TYPE.TABLE
...
0
votes
0answers
5 views
bokeh number formatter in a DataTable with scientific format
I am trying to use Bokeh to display a table with p-values (number between 0 and 1). The numbers can be extremely small (e.g. 3.24e-122). The default formatting shows many digits and is not well ...
0
votes
0answers
7 views
How to compare WordNet Python NLTK similarity scores?
I'm writing a program which compares similarity scores of some synsets. I'm using path_similarity to calculate the similarity score, and I have the following synsets:
dog = wordnet.synsets('dog')
cat ...
0
votes
0answers
12 views
pytest command line argument failing
I have added conftest.py at the same directory level as my test file . The content of my conftest.py :
import pytest
def pytest_addoption(parser):
parser.addoption("--l", action="store"...
0
votes
0answers
10 views
Finding Semantic Coherence between sentences in a text
I need some help writing a program based on the code from these links link1 and link2 that will automatically calculate the semantic similarity between a. Consecutive sentences and b. Sentences ...
1
vote
0answers
27 views
Listen for incoming emails in python [on hold]
I remember hearing about a Python library that provides a way to call a function every time an email is received but I can't remember for the life of me. Does anybody know of any way to do that. ...
0
votes
0answers
15 views
SQLite Multiple Insert with Query Syntax Error
I'm attempting to insert multiple rows into an SQLite DB with python. I've got three tables:
UniversityA:
id
course_name
course_code
course_prefix
UniversityB:
id
course_name
course_code
...
0
votes
2answers
35 views
My function for some reason auto-converts a string into a tuple?
I'm very confused here. I'm trying to pass an optional string parameter to my function, but once the parameter is added, it converts the string to a tuple? How can I stop it from doing that or convert ...
0
votes
2answers
37 views
Am I doing this right? Removing items from python list - is there room for optimization?
I have 2 lists. I want to remove all items from list which contain strings from second list. Now, I am using classical 2 loop approach, 1st I loop over copy of main list and then for every item i ...
0
votes
1answer
8 views
Python-Behave, running features in mutliple subdirectories
How can I run behave tests with this kind of file structure:
+-- features/
+-- user_page/
| +-- user_crud.feature
| +-- user_search.feature
+-- customer_page/
| ...
0
votes
2answers
23 views
logical error in Python Lottery Programme
I am writing a code in which the user enters 6 'lottery' numbers between 1 and 59 - that bit works fine.
Then the computer picks 6 random numbers between 1 and 59-that bit also works well.
However ...
0
votes
1answer
18 views
Python / Excel : Turn off Office Excel Compatibility Checker Programmatically
A file which has data I need to access is being generated in xlsx format yet I need it to be in xls format for my purpose.
I'm able to use win32com.client to open the file however the save cannot ...
0
votes
1answer
15 views
XLRD: Start reading a column from a specific cell / range (Python)
I am trying to read all values within the first sheet of an excel file via xlrd, but I need it to start reading values from row 3 of the excel sheet, until the end of values in the column
Current ...
0
votes
0answers
34 views
TypeError: argument should be string, bytes or integer, not tuple
TypeError: argument should be string, bytes or integer, not tuple
I'm very new to coding and I am working on a script that should read data from two .csv files. file_one skipping the first three rows ...
0
votes
0answers
6 views
GOOGLE_APPLICATION_CREDENTIALS error in Python web service
I am writing a web service in Python using Flask framework that queries Google Big Query and provides the result. I dockerise the application and run the docker container. These are the
files I have ...
0
votes
3answers
33 views
How to group files by their paths in a list
Is some way to make from this list of strings:
['/User/someuser/file.py', '/tmp/download/file.zip', '/tmp/download/file2.zip', '/', '/usr/local/bin', '/tmp/file.txt']
make this list
[('/tmp/...
0
votes
1answer
18 views
A general way to scrape link titles from any site in Python?
Is there a "general" way to scrape link titles from any website in Python? For example, if I use the following code:
from urllib.request import url open
from bs4 import BeautifulSoup
site = "https://...
2
votes
2answers
31 views
python (Pandas) output value from column 0 based on criteria different columns meet
I have two pandas dataframes, dfA and dfB.
dfA has an unknown, say x, number of columns. dfB is a numpy array with x – 1 number of values. So, if dfA has 50 columns (0 to 49), then dfB will have 49 ...
-2
votes
0answers
18 views
from google import search ImportError: cannot import name search
I'm trying to run a script in python, but I find the following problem:
File "myscript.py", line 16, in <module>
from google import search
ImportError: cannot import name search
I do not ...
0
votes
2answers
38 views
Counting arguments in lists and printing lists
I want users to enter random words/numbers/phrases. If they have entered more then 5 then they get an error message and if the enter 5 or less then I print out the list vertically. I don't know what ...
0
votes
1answer
17 views
Python urllib2 unable to open url
I have a URL in this format:
https://aLongStringWithNumbers:[email protected]/admin/someAPICall.json
which looks like not something that Python's urllib2 can understand, ...
0
votes
1answer
21 views
Django - make admin fields invisible to some users
TL;DR I'd like to be able to disable certain models per-user in /admin view.
Specifically: I'm looking to make admin models invisible to some staff users, so that they can have a sort of customized ...
0
votes
1answer
11 views
ElasticSearch Mapping Non Searchable Field
Im new to elastic search.
In my users type in profiles index i have fields
properties : {
name : {type : string},
picture : {
url_small : {}
url_big : {} ...
0
votes
0answers
7 views
how does 2d kernel density estimation in python (sklearn) work?
I am sorry for the probably stupid question but I am trying now for hours to estimate a density from a set of 2d data. Let's assume my data is given by the array: sample = np.random.uniform(0,1,size=(...
0
votes
1answer
27 views
Rename files in a folder?
I'm learning how to code on Python 2.7.13 and I'm loving it! However, I'm stuck and wanted to seek your help.
I'm following off this video: https://www.youtube.com/watch?v=TMw5EzdIucE
The task is ...