I created a program for my little sister to learn math and now want to add sound. So looked up on how to add sound to my program and found the winsound module. I wrote this code: But for some reason it only plays the default windows sound. (Bliiiiiingg) The file victory.wav is located in the same folder as th…
Tag: python
Can’t handle two modelforms in a single submit/view flow with a FK relation?
I have the below two models In my template I render all fields except for start (which I don’t render at all) in the same <form></form> wrapper. Now in my view I want to create new instances for each of the modelforms but only if both are valid. This is what I have which throws NOT NULL cons…
Is it possible to use the Python requests library to send Gmail only using the Google Gmail API
Is it possible to use the Python requests library to send Gmail only using the Google Gmail API? I am trying to send Gmail with a python request library. But it ends up with an error 401. I want to know what is the proper way to send Gmail with Google Gmail API. Answer There is an example on in
Python – Add time zone to timestamp
I use chrome timestamp and convert it do readable date but time isn’t right Seems to be timezone need to be added example for last_visit_time : 13292010189305268 Answer Assuming that Chrome timestamps denote microseconds since 1601 UTC, you’ll want to make your datetime aware: If you want to forma…
Copy and split row by if cell condition it met – Pandas Python
I am trying to overcome the issue when I have a cell with specific char(‘;’) which I would like to copy the same line with the amount if splitters that specific cell in specific col got. For example: Index Name Age Car 1 David 45 Honda;Subaru 2 Oshir 32 BMW The result that I am trying to get is th…
Shorten Selenium-Wire Option
I would like to improve the following case by shorting it. I’ve come this far You could say that I should just remove the n decision, but I can’t because I need seleniumwire_options later. Answer You can shorten it by factoring out common parts, like this:
Output of split is not what I was expecting
I’m just learning python, and I’m having some problems reading a .txt file that I created. My objective: I have a txt file with a list of strings. I’m trying to read, process it and save every letter into a new list. example2.txt file: [one, two, THREE, one, two, ten, eight,cat, dog, bird, f…
Part specification along different axes of numpy array
Why is arr[0:5][0:10] the same as arr[0:10][0:5] and what should I write if I want to get the array with shape (10,5)? In the process of trying to crop a 2D numpy array I end up with the wrong dimensions. Ok, I figure, I just got my axes switched up, so I switch the order of the part specification.. and
Simple Discord bot not functioning as its supposed to be |Python
I have recently started coding with python and ended up coding a discord bot. This is the code i ran: I think this should make the bot say:Commands:!hello, !help, when a user writes !help but in the end nothing happens. Anyone got an idea how i can improve the code so it works?Id love to know Answer The event…
“TypeError: ___ object is not subscriptable” in Python and how can I fix it?
I have been tasked on building a code using queues and a class in which you get three options: Generates a new number Calls on the first number of the queue and takes it out of the main queue(there is an auxiliary queue for that) Shows the already called numbers This is the class created: And this is the code