From the course: Python Data Analytics: From Notebooks to Production
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Sub modules - Python Tutorial
From the course: Python Data Analytics: From Notebooks to Production
Sub modules
- [Instructor] When your code is small, putting everything in a single .py file is great. But when it gets bigger, sometimes makes sense to split the code to several files. So, here's what we can do. We can do rides, now it's a directory, and inside of it, we can put several submodels. Let's say we put a database work inside a file called db.py, and this one has only the load rides. The important thing is to place a file called dunder init, two underscore before and two underscore after. And this makes the directory a Python model that you can import. And here we have the clean rides and the bike with most rides, but the load rides, we import from the db. And we do a .db, which is a relative import, so we can input it from there. And now, our notebook, looks the same. So we import rides and then we do the load rides, we do the clean data, and we run the calculation. So the API didn't change, we just broke it into several files. People, of course, can import rides.db if they want to…