finishing up pylibrary (for now)
Hey.
Recently I’ve been working on this project called ‘PyLibrary’, to work on my python skills generally and improve. The projects don’t really link and some are wildly different to one another, but it’s been interesting to learn about how I can apply python skills in a variety of different ways.
Main goals
The main goals for PyLibrary at the end, was to have a vareity of programs in the same folder, with a single file externally controlling them all. I wanted to try stuff like working with an inputted file, data analysis, user interface (which i’m still working on) & image manipulation. I’ve done some of these and I’m still working on others but for the most I think I’ve fulfilled the main goals I was aiming for.
File Controller
While I’m not gonna talk about making every single file individually, I figured I’d just discuss how I made and structured the project to get the external file controller working.
The code for it is as follows:
1 | # pylibrary.py |
So, taking a look at it we obviously have the function that allows us to pick the module that we want to use, and most of the code is self explanatory. This is probably still not the final version as I will continue adding changes as I see fit but as of now this is what I’ve got.
The project is structured as follows:
project
│ README.md
│ pylibrary.py
│
└───PyLibrary
│ │ __init__.py
│ │ # all of the modules in pylibrary
The init file means that the folder PyLibrary is recognised as a module, and can be imported as such. In the init file, it just imports all the files, so __all__
is just all of the modules within. Then, in the pylibrary file it iterates through all of the modules and appends them to a list, which is used to support picking the module.
Conclusion
Overall, I’ve had fun working on this project and may continue working on it a bit because it’s a good way to sharpen my skills. You can check out the project here.
Until next time.