Im creating a discord bot in python and i have few problems i would like to get a help with. 1. I would like to know how to add cooldown on a command. So for example someone will use a command and everyone will not be able to use the same command for some amount of time. Here is one
Can not force stop python script using ctrl + C
Normally to force stop python script that are running, we normal just press Ctrl + C (in Interactive console). In this case, it does not stop, when I press Ctrl + C. Here is my code for this situation: I want it to force it to stop before the 20seconds is reached. Please help explain why this happened and hel…
Can’t get tags when scraping data
I am trying to scrape all tr tags using BeautifulSoup, but it returns none. Code: Even though there are tr tags in this url, it returns none and throws an IndexError. Why is this happening? Answer In page source table is located inside comment. You need to extract comment content and then parse it as HTML:
TKinter labels not moving further than a certain point on my window
I am new to tkinter and I am trying to make a tabbed page however I am struggling to move the labels around. They dont seem to be listening to the rows and columns I enter completely. They move to a certain extent but for example, the premium paper label doesnt move any further than about a third across the
Running an executable in a child directory from parent directory windows
I have the current file structure in a folder with nothing else in it: (folder) crypt (file) run.bat I’m on Windows and I’m trying to execute a python.exe with run.bat that is in the crypt folder. How do I do this? Answer I figured it out! I just had to add a “./crypt/python.exe” argum…
Delete text from Canvas, after some time (tkinter)
I need to remove text from canvas after some time. I tried this: Result: It does not even appear the text. And this: Not working too. Please help, I looked almost everywhere and I didn’t find how to do that. Answer You have to give after a reference to a function. The way you’re doing it is immedi…
Python Pandas Extract word from column that contains String with Regex
I have this data frame (columns are strings): I need to get ‘ORF’ values for rows with ‘ORFDesc’ that contains a word with “hydro” but only with 13 characters. I explain, word length must be 13 characters, not the whole description. I’m using In order to match the row…
How to use a specific stop-character for shlex.split?
How to tell to shlex that if the character ; is found, then, don’t split anything anymore? Example: should give instead of [“hello”, “column number 2”, “foo”, “;”, “bar”, “baz”]. More generally, is there a way to define “comme…
Change the output of an array
I am currently working with the Node_Coords_Section of the berlin52.tsp file This gives the following output: In order to be able to use satsp, I need to change the latter in this format: What should I do to get it in this format? Answer Use lst = [[x,*y] for x, y in dic.items()] Here is the full code: OP: [[…
Clone a python virtualenv to an offline server
Hi I want to clone a python virtualenv to a server that’s not connected to the internet, I searched different forums but didn’t find a clear answer. Here are the methods I found and the problems I have with each : Methode 1 : (safest but most time consuming) Save all the libraries via a pip freeze…