I want to understand functions and arguments better, I’ve read and this is my implementation of what I have read. I have 3 small functions to illustrate my point. User input collection, grading function and main. If I run the main function without its argument (1), it results in an error looking for the…
Python opencv/cvzone – UnboundLocalError
I am trying to make a ar mouse (camera vould detect your hand and than your finger vould be the mouse). But when checking which fingers are up I get an error. When making this program I followed this tutorial: https://www.youtube.com/watch?v=8gPONnGIPgw&t=332s. When doing that I made one thing different w…
How can show the singleton object’s attribution?
We can show instance’s attribution with dir function. Now create a class with metaclass method: Show Cls’s _instances attrubution: Why no string _instances in dir(Cls)? Answer Because it’s stored on the metaclass. To be clear, this has nothing to do with the singleton aspect.
Locust: How to use distributed mode programmatically
I’m using locust to load test a bunch of apps, the problem is that it’s using more than 90% of the CPU and so I want to switch to distributed mode with master and workers, I know how it’s done in command line but I’m using locust as a library and it seems the docs don’t cover thi…
Python-docx – check if text in table has hidden attribute applied
I am new to Python and I am trying to check docx file for texts in table that have hidden attribute applied to them. If True, then I want to ignore that hidden text and replace any other text that matches my regex. The thing is everything been good (replacement is working) until I added if i.font.hidden == Tr…
Find all shortest paths between all pairs of nodes in NetworkX
I am trying to get all shortest paths between all pairs of nodes in an undirected unweighted graph. I am currently using nx.all_pairs_shortest_path(), but I don’t understand why it only returns one shortest path for every pair of nodes. There are cycles in my graph so there should exist multiple shortes…
Bokeh Networkx graph slider not updating correctly
Here is a minimal working example for the problem I am facing: I am building a simple graph with Networkx and then displaying it with Bokeh, adding a slider to show only the edges whose weight is greater than the slider value. Unfortunately, this works perfectly when the value increases, i.e., the slider move…
Delete specific strings from pandas dataframe with operators chaining
I want to delete specific strings with regular expressions from the column Sorte which I don’t want to have in my dataframe file_df with the following code: But somehow when I execute this code these strings still are in the dataset and I can not figure out why. I wanted to chain this expression to not …
write filename when iterating through dataframes
I am passing to a function several pandas df: df here will be a pandas dataframe. How can I assign the diferent parameters of *args to a string like above ‘/transformed/’+str(df)+’.table’,sep=’t’ ?? I want to have three files written to disk with the following path: Answer …
Python – to put space after period; not for a decimal number
Using Python and regex, would you please help converting to i.e., space needs to be inserted when it is between two alphabets and either one of the characters on either side is an alphabet. Space need NOT be inserted if both sides of the period is a digit. Please help. Thanks in advance. Answer You can use ne…