Category "python-3.x"

Python and vs or in while loop

choice = input('Enjoying the course? (y/n)') while choice != "y" or choice != "n": choice = input("Sorry, I didn't catch that. Enter again: ") im trying to

bool() vs is not None [duplicate]

I have two functions that return a bool. The first is using bool() and the second is using is not None. def func_1(x) -> bool: return b

Syntax error when trying to insert record into posgtresql using pg8000 driver

When I am trying to insert a record into Postgresql I am getting below error. pg8000.exceptions.DatabaseError: {'S': 'ERROR', 'V': 'ERROR', 'C': '42601', 'M':

Problem with exception handling using Python requests module

The following part of my code is supposed to do exception handling during HTTP requests. app.py class Get: def __init__(self, url): self.url = url

Boto 3 filter_log_events returns null but describe_log_streams gives correct values

I am trying to retrieve cloud watch logs from log group /frontend/lambda/FEservice. The logs are stored in multiple stream with pattern YYYY/MM/DD/[$LATEST]* Ex

Can you explain me the RLE algorithm code in python

I I've finally found how to make a RLE algorithm by watching a tutorial but This tutorial didn' t explain something in that code I didn't get why we write j = i

Setting log file for a cron job with the log file name as date

I am trying to set log file for a cron job and the name of the log file should be date. The cron job is set like this. 55 09 * * * /home/program/my_folder/main.

How to prevent python from automatically escaping backslash with dubble backslash

I'm looking for a method to forward a string so for example ip 1.1.1.1 becomes ^1\.1\.1\.1$. I tried a couple of thing but all of them results in the following

headless chrome downloading file without being asked to

I have a selenium test that requires a file download. I am achieving it by retrieving a url for the download from a page web-element and then doing driver.get(&

DiscordPy Bot abnormally long shutdown times

So here's the crux of the problem. I'm using the Discord Py API (1.7.3). I have 2 bots I run that use it, Red Bot and the one I made myself. I've come to notice

OSError: [Errno 63] File name too long while calling python subprocess

While running the following code I'm getting file name too long import subprocess import json data = [{ "id": 1, "first_name": "Janet", "last_name": "Til

Forbidden (403) CSRF verification failed. Request aborted. Reason given for failure: Origin checking failed does not match any trusted origins

Help Reason given for failure: Origin checking failed - https://praktikum6.jhoncena.repl.co does not match any trusted origins. In general, this can occur when

How to run FastAPI server as multiple instances

I have developed a FastAPI Web Application. If I run the server and it is down or crashed for some reason. I need multiple instances of server to be running. I

Jinja2 template evaluate variable as attribute

I have a Jinja2 Template I'm working on for a database editing app, and I'm trying to make it 'extendible' - rather than hard-coding the editing page, I'm passi

Cannot run a While Loop in AWS Python Lambda

import asyncio from aiogram import Bot, Dispatcher, types # Handlers async def echo_hello(message: types.Message): while True: await message.reply(

How do I (efficiently) update the text of a tkinter label that was procedurally generated?

I am making a restaurant menu program that pulls items and their attributes from a .json file, and then allows users to add them to a cart and export an order (

remove commas , and [ ] from a list python 3

I have a this funtion n=5 nums=5 1 4 2 3 def LIS(nums, n): dp = [] dp_list = [] for i in range(n): dp.append(1) dp_list.append([n

How Do You Add A Replay Button To A Game?

Im trying to make a replay button for my game where when you die the game pauses until you press the space bar which resets the game so you can play again. I'm

Is there any way to limit json request items?

Is there any way to limit how many items I want to get from a JSON request? the code I use: import json import requests url = 'https://api.github.com/users' re

How do I keep grabbing bytes and encrypting them in Python?

cipher = Cipher(algorithms.AES(key), modes.CTR(iv)) decryptor = cipher.decryptor() plaintext = decryptor.update(data[0:4]) paramEntry1 = int.from_bytes(plainte