In the Python Next Level course on Udemy, section 3 talks about setting up a web application stack. The chapter describes a way to simulate all of the components using python modules. As I now know, python modules are simply a way to import code from external sources, and leverage their function in your code (a la packages in Java, or libraries in C++). I’d used them before, but learned the following during this portion of the chapter:
The difference between ‘import foobar’ and ‘from foobar import baz’ => The first is simple- using import simply imports everything from the module. The second is simple also- using from import imports only the features of the module that you want to import as opposed to importing EVERYTHING. Though previously, I’d seen something like this:
WTF? Why would you import foo twice? You already have the foo module imported at the beginning of your import statements, why would you import it again using the from keyword? Now I know the answer- namespaces. The bar module also has a method/class in it called baz. By using the from statement, you’re stating that you want the version of baz in the foo module, and not the one in the bar module. Brilliant. I know- ‘noobs’ getting excited about something the ‘leets’ have known forever…yes, I did.
As far as the code I wrote, I basically did all the setup work for the homework assignment:
Tomorrow, I’ll complete the work and report.