Creating and using your own libraries

--Originally published at Quirino´s Projects

Sure you know how to import libraries, if you don’t , just check my post about that

Somewhat you want to do something many times in different programs, and of course you would like to use a function but taking a function from another program then copy/pasting it to your current can get tedious, thats why you should be creating your own libraries, its simple, you create a python program as normal that contains the functions that your are going to use, in my case i created a quirinoStuff.py that contained 3 functions useful for opening files, just doing open() is easy you might say but this one ensures that the file you are trying to open exists so there won’t be crashes because of the user not typing correctly, so we import as it was a built in one like:

from quirinoStuff import openFile

And know we can use openFile in our program without the need to write the function again

You can check an example in my GitHub https://github.com/QuirinoC/46Exercises
In the simpleIO37.py