I’m using Peewee as ORM and connect to a Postgres database (psycopg2) using the Playhouse extension db_url.connect. My URL is a vanilla postgresql://username:pass@host:port/dbname?options=… so not using pooling or anything advanced at the moment. Some times when I call connect it hangs for a long …
Tag: python
How to unittest a datetime function
file.py test.py I get an Error: TypeError: ‘>’ not supported between instances of ‘MagicMock’ and ‘int’ Is there anyway to test this function? Probably the problem is with this part of the last line: (utc_date – namespace_created_date).days Answer I could reproduce…
How to turn on shell hints in python? [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 months ago. Improve this question Is there something like hints in python’s shell? For example I type…
Compare two audio files with persons speaking and compute the similarity score
Big picture: Trying to identify proxy frauds in video interviews. I have video clips of interviews. Each person has 2 or more interviews. As a first step I am trying to extract the audio from the interviews and trying to match them and identify if audio is from the same person. I used python library librosa t…
Creating Bricks with Turtle Python
i’m very new to programming and in here i’m supposed to create a pyramid shape of bricks where the edge of the pyramid is filled with one color and the inside of it is filled with random colors, but i can’t seem to figure it out how to move the bricks to create a new row, column and the rand…
I’ve followed all the instructions in a tutorial for a bot, and why doesn’t it work?
This code i’m using to try to make a discord bot that will change people’s nicknames in my server for them, won’t work. Here’s what my terminal and member list look like Answer client.run is not a variable, as you have treated it in your question, but instead more similar to a function…
Error “Message: element not interactable” is displayed when I try upload a file with selenium python
When I executing the test case in console an error is displayed -> I add the location of the file but script be broken My code Any solution? Answer As the error message says, the element you’re locating isn’t interactable. That means that Selenium is looking at the element and has decided it…
Change value every nth iteration python
How can I change a value inside a loop every 10th iteration? Say I have a list with 30 properties I would like to change the value of x by a factor of 10 every 10th time. Desired outcome ** Answer Modulo is a nice way of doing that: Edit: you should probably initialize x outside the loop.
Connection timeouts as a protection from site scraping?
I am new to Python and Web scraping but it’s been two weeks that I periodically scrape one website and successfully download images from it. I use different proxies and sometimes change them. But starting yesterday all my proxies suddenly stopped working with a timeout error. I’ve tried a whole li…
how to use fromiter and ndnumerate together
I’m currently trying to manually implement a function to represent the KNN graph of a set of points as an incidence matrix, and my idea was to take the rows of an affinity matrix(n x n matrix representing the distance between the n points), enumerate and sort them, then return indices for the first K el…