Category "python-3.x"

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

FastAPI: How to use POST data as variable to trigger another script?

I have written an API on FastAPI with filename api.py: from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Username(BaseMode

Generate multiple new pandas dataframes using lists and for loops

I have the following dataframe: import pandas as pd import numpy as np from numpy import rec, nan df1=pd.DataFrame.from_records(rec.array([(202001L, 2020L, 'app

How to check if all lowercase 'g' in a string has another 'g' adjacent to it?

I need to write a program that returns True/False based on the following conditions: A lowercase 'g' in a string is "happy" if there is another 'g' adjacent to

How to use python to create and modify windows shortcuts

Based on most of the postings I have read, I need to import winshell in order to create a Windows shortcut using python. But I am running Anaconda python and wh

Web based code editor with auto completion

guys I'm building the web based code editor for my personal project.I want to make it work like VS code but facing some issues. I'm using ACE editor. This is wh

Python defaultdict returns None on get, despite being initialized with a default value

I am trying to code a variant of Dijkstra's shortest path algorithm. In doing that, I want to initialize the shortest path distances to math.inf, and have this