Category "python"

Calling a function of a module by using its name (a string)

What is the best way to go call a function, given a string with the function's name in a Python program. For example, let's say that I have a module foo, and I

How to override js method in Odoo 15?

Can anyone give me minimal code so that any method I can override for JS method? changeMode(mode) { if (!this.hasPriceControlRights && mode ===

Why is "except: pass" a bad programming practice?

I often see comments on other Stack Overflow questions about how the use of except: pass is discouraged. Why is this bad? Sometimes I just don't care what the e

How can I ensure my Python packages are installed in Python 3.10 instead of /Library/Python 3.8?

I have successfully installed Python 3.10. I want to install packages. Pandas, BeautifulSoup4, and requests. I tried to import NumPy but IDE says it doesn't hav

Python - AWS Lambda Function - Could not satisfied requirement

I am just starting using AWS Lambda functions, and I come across this situation. I have the most basic python lambda function ( the Hello-World example ) genera

How to Export formatted CSV data to file?

I have a python script that parses/prints all the urls from an xml file to csv format. It does this, but it doesn't create an actual csv file. How do I turn thi

How to Export formatted CSV data to file?

I have a python script that parses/prints all the urls from an xml file to csv format. It does this, but it doesn't create an actual csv file. How do I turn thi

Python Package Import Design

I have a python package that works perfectly if it's installed with python setup.py install, however, i cannot run the package locally. Here is my package struc

Why is "except: pass" a bad programming practice?

I often see comments on other Stack Overflow questions about how the use of except: pass is discouraged. Why is this bad? Sometimes I just don't care what the e

reading behind from list

import numpy as np filename = 'input1.txt' output_file = 'output.txt' delimiters = ',.?!' with open(filename, 'r') as f: text = f.read() for delimiter in

python get new value in a class or method

i'am new to python and try to get the new value for my bool in a class . i try create a global, set in the init. How can i get the new value of the test bool in

Printing full path to all possible png files in directory

I need to display all png files in directory 'images'. The problem is there is subdirectory 'additional files' with one more png in it. import glob my_path = "

PyQt5: Pass a value into QWidget

how do you pass a value into a QWidget in PyQt5? Let's say everytime the user runs the GUI, the widget shows today's date for example. Appreciate the help!!

How to convert bytes represented as a string to the real bytes

Suppose we have a string that looks like this: fake_bytes = "b'This is a check - \xe2\x9c\x94\xef\xb8\x8f'" So this fake_bytes string is a text that is encoded

Tensorflow (Cummulative) Counting, how to call different labels?

I am very new to Python, but need to work with it during my study for a project. We are trying to make a camera scanning system. I have found an amazing code by

How to create and assign indexes for each group in a dataframe

[This is DataFrame loaded with data from an Excel file] STUDY Teacher UPDATE_DATE 0 math A 2022-02-25 1 math

Output not doing anything when using PyFPDF

I'm trying to put all the images in a directory into a single PDF. I'm writing in python 3 and using PyFPDF. This is my code: import os from fpdf import FPDF pd

Serving file asyncronously with Django and uvicorn

I have a Django view that serves the content of a file. The Django application was running with WSGI until recently. This worked fine. Then I adapted my applica

how would i integrate a progressbar into this code? ive actually got a progressbar in the code, i just need someone to show me how to make it work

how would i integrate a progressbar into this code? ive actually got a progressbar in the code, i just need someone to show me how to make it work.thanks. the w

Python - overcome the project path problem on importing

My project structure is: main.py ----gui/load_ui.py ----gui/resource.py in load_ui.py I am importing resouce.py. in main.py im importing load_ui.py since it's