Skip to content

How to replace characters and rename multiple files?

I have a bunch of pdf files which has the file name as follows: AuthorA_2014_ This is a good article BIsanotherAuthor_1994_ Gr8 artcle CIsFatherOfB_1994_Minor article but not bad And so on. I would like to change the name of the files to this format: AuthorA2014This is a good article BIsanotherAuthor1994Gr8 a…

List and use the variables defined inside my own function

Suppose that I have a function like this one: Now can I use the a, bvariables? Even if foo() is not returning them like this? I know this is easy to do if foo was a class, but it’s not. Answer Even though you are saying you have a function, not a class, python is able to transcend those differences

Easiest way to import a function from a file in a different folder

Can I import a python module from a distant folder? (Possible duplicate of How to import a Python module from a sibling folder?) Answer In general, the git repo should have a requirements.txt if it is for general use. If it has one then you can run pip install requirements.txt It is also fairly easy for the r…

Checking a dictionary key name, which is an instance of a class

I am using a module called jsondiff to compare changes between two json files. When a change is detected it returns a dictionary. The dictionary keys are instances of a class from the module. Depending on the type of change (something new added, deleted or changed), the dictionary keys are named differently b…

Get rid of default text

I am trying to parse a user’s event descriptions after obtaining access to their google calendar through the google calendar API. When I input the description into my program, I want to get rid of default (and useless) text such as Zoom meeting invitations. If the following below is the description stri…