Category "python-3.x"

Input() function works inconsistently, python 3.8.10, spyder 5.3.0, IPython 7.32.0

The code print("Some text") integer=int(input("Enter an integer: ")) is expected to print "Some text\nEnter an integer: " and read the users input, but some of

Crop colour image according to OTSU threshold

I have a colour image which I have sucessfully applied the OTSU thresholding method on its greyscale form to obtain the outline of the biscuit: Original Colour

Instruct WebApp using Django to run the code locally and return results

I am a newbie to web development and python scripts. I am learning to host python scripts using Django. I would like to know how to instruct Django to run the s

comment SQL query with variables in python

I'm working with Cloud Function. I have the following query working correctly: # this is working q = """ SELECT col1, col2 FROM `my_table` WHER

How to import other Python files

I have this file, abc.py: def asb(): print("Hello, ") def xyz(): print("World!") In my main.py file, from abc import asb from abc import xyz I want

Standard Deviation coming NaN in Pyspark rolling window

I have a dataset with 4 sensor values, 'volt', 'pressure', 'rotate' and 'vibration'. For these sensor values I am calculating rolling mean and rolling standard

How to get rid of Django security vulnerabilities warning signs in terminal

I have a simple Django project with a PostgreSQL backend and I can't seem to get rid of the Django security vulnerabilities warning signs on my terminal. Settin

How do you print accented characters?

I want to write a program that takes text from a file and prints the selected lines. When printing a word containing an accented character like "ó", I ge

Python Plotly image how to save image to a iobuffer and read it back

Python Matplotlib image is saved like : img = io.BytesIO() plt.savefig(img, format='png') img.seek(0) encoded = base64.b64encode(img.getvalue()) but for plotly

How to convert a cupy.ndarray to a scalar?

I'm working with CuPy at the moment. I've noticed something that seems to be a bug, but I'm not sure. I've noticed that if I use certain math functions, they re

Datashader integration for polygons in plotly mapbox

I'm using plotly's Scattermapbox to overlay a map with a shaded image of polygons created by datashader's shade function (based on https://plotly.com/python/dat

Run a UNIX script to use different versions of python

I have a UNIX script which is used to initialize the environment and properties of the project. It uses python. I had to refer the path. This will be used as a

MIME type ('text/html') not a supported stylesheet MIME type, and strict MIME checking is enabled in Django Web Application

I am hosting a Django web application on a cPanel web hosting server. I have the application up and running however it is not applying the CSS stylesheets to my

I want to end the while loop in python when both the conditions are false but it stops when only one condition is false

Here's my code, the purpose is to generate an array with 10 randomly generated 0's and 10 randomly generated 1's. While loops stops working when 'a' is equal to

How to typehint the return value of a function that takes other functions

I have a function that accepts other functions, and would like to type-hint the return value of this "wrapper" function. The function is similar to this below,

How to typehint the return value of a function that takes other functions

I have a function that accepts other functions, and would like to type-hint the return value of this "wrapper" function. The function is similar to this below,

Zipping a list of folders with Python

everyone. I'm really new to Python, so I need some help here. I have a list of folders names inside a .CSV file. All these folders are inside the same path. I n

Why isn't Django Sitemap showing the URLs

I've been trying to make my django sitemaps work for a small blog application. After checking out multiple tutorials, I still can't get the sitemaps work proper

How to replace the icon in a Tkinter app?

I am using Python 3.5.0 on Windows 10 and want to replace this:

Bigcommerce API connection disconnects with no response

We've been using a Python script to pull orders from our BigCommerce store and reformat them into a .csv for use by our warehouse. This method has been working