Skip to content
Advertisement

Tag: function

read and return text file with def function

i want to input the file name in this case books.txt and get the lines but i cant get it work, i have the files in the same directory but when i run this nothing happens, any way to fix this? or to call that function in another .py file but this return nothing and i dont know what to

@lru_cache decorator excessive cache misses

How can you configure lru_cache to key its cache based on actual values received, rather than how the function was called? In other words, only the first call above should be a cache miss, the other two should be cache hits. Answer To do that, you would have to go through the process of binding arguments to formal parameters. The

Finding intersections between two lists

Edit: I was using Jupyter notebook, I had two different scripts in a row while working, The script shown here is one, and the error shown here is from the other script. (mistake) Thanks for your time! I intentionally learned more though. I’m trying to find an intersection between 10000 randomly generated lists of 6 elements numbers between 1 to

Call Python function using dynamic string variables

I am trying to create a dynamic method executor, where I have a list that will always contain two elements. The first element is the name of the file, the second element is the name of the method to execute. How can I achieve this? My below code unfortunately doesn’t work, but it will give you an good indication of

Advertisement