Skip to content
Advertisement

Tag: python-3.x

Which method is the best for starting the bot in discord.py? login() and connect() vs start() vs run()

So, to connect the bot to discord.py, there are several methods: discord.Client().login() + discord.Client().connect() discord.Client().start() discord.Client().run() What is the difference between them and which one is the best for running the bot? Answer I believe the official documentation is very clear: start() is shorthand coroutine for login() + connect(). run() is a blocking call which means that This function must

Count input length without spaces, periods, or commas

How do you count the length of a string (example “Hello, Mr. John. Have a good day.” taking out the commas, periods and white spaces? The count should be 23. I’m coming up with 33 with the commas, periods and white spaces. Answer The @yixizhou answer is simple and accurately a good one but if you want to avoid the

Python Split and calculate

I use an API for the license overview, there I can see when and for how long I have used a program. The usage time is displayed in a table as 10 min or as 1 h 10 min. Now I would like to have an printout under this table with the total used usage time. It Prints: How can

Tkinter button color flashing for no reason

I’m making a refresh function to change the color of a button in tkinter, the problem is that this color must come from another function that returns a string and everytime I update everything flashes for a moment. I’ve tried using StringVar() and only update the color without updating the whole layout but it would just get stuck in the

How do I run a py file inside a virtual environment on Windows 7?

I need help understanding venv and project management on a Windows 7 system. I have installed Python 3.7.4. Running the command ‘pip list’ results in the following: Under the path C:ProjectsNeuralNetworks I have the following files/folders: When activating my virtual environment ‘project_envScriptsactivate.bat’ the command ‘pip list’ results in: When I go to run main.py I get the error “NameError: name

How to add() runtime input in a set in python?

Problem I am trying to add() elements in a set at run time using a for loop: Surprisingly, l1 is a set but, when I go on add() -ing elements to my set l2 in a loop I get : TypeError: unhashable type: ‘list’ Research Effort: Here are other ways I have tried to add() elements to set l2 and

Advertisement