I’m following the pre-commit directions to install git pre-commit hooks for python code formatting from black to my flask repo. I’ve added pre-commit to my requirements.txt and my pre-commit-config.yaml file looks like After installing pre-commit using pip install pre-commit and installing the git hook scripts using pre-commit install, I get this error message related to a hatchling dependency package when
Tag: python
Python find if all values are equal in dict of dicts
Given a dictionary, Using Python, what is the most optimal way to check if all status values are 1? The way I am trying to do is to iterate through the dictionary and set a flag to 0 if at least one of the status values is 0. Answer You can use the all function and iterate over the values
center images and add padding according to screen resolution
I’m using pygame to show two images: I’ve maneged to resize the images according to the screen size of my user. But I’d like to standardized also the x and the y coordination position of my images. The images should always be in the middle according to the y axis and have the a little bit of pad to stay
How to scrape table with flight data, avoiding an empty result?
I’m trying to extract a table from a webpage and have tried a number of alternatives, but the table always seems to remain empty. Two of what I thought were the most promising sets of code are attached below. Any means of extracting the data from the webpage would be considered as helpful. I have also included a screenshot of
How to remove all Pandas rows of lists if they contain specific values?
I am looking for a way how to drop all the rows that contain any value from a list: Int: Out: I have come up with this solution: which only works with these simplified data, but not in other cases, therefore I am looking for some alternative way. Thank you. Answer Use boolean indexing with set.isdisjoint:
How can I get Html of a website as seen on browser?
A website loads a part of the site after the site is opened, when I use libraries such as request and urllib3, I cannot get the part that is loaded later, how can I get the html of this website as seen in the browser. I can’t open a browser using Selenium and get html because this process should not
Convert epoch to human-readable date python
I want to convert from epoch to date like that : 1575135888 ==> 3 years ago (https://i.stack.imgur.com/x2ZPW.png) I have this code : I got 2022-12-09 and 2019-11-30 18:44:48 I don’t know how to convert it to 3 years ago. Answer Well, you could use timedelta like this: Output: But I’m afraid that the meaning of “years ago” is ambiguous: Does
Concatenate text file lines with condition in python
I have a text file in this format: I want to check if the image name is the same and then concatenate those lines into one line with the following format: I have tried something like this but don’t know how to do the actual comparison and also don’t quite know what logic to apply since the first line_elements[0] will
Nested Dict to Table in Jinja2
I am scratching my head trying to correctly format a table from a nested dict in Jinja2, but having no luck. The dict is something like this: And I want the table to look like: The closest I have come is: But this doesn’t work. I am having trouble assigning the k1 variable without also having to extend the loop
Odoo Addon View for Sales custom dropdowns not showing properly
We are trying Odoo Repo on Ubuntu, we wanna make some custom addons. We read the documentation and we achieved to create some models and views. The main issue is that drop-down “many2one” fields show at first hiding. The only way to make it work its to click on the area of the form. We don’t know if we are