Friday, July 16, 2021

Python 101: Import

 Once you start to advance in python import would begin to appear in your codes a lot. If not for anything else, but to link different pages (modules).

Python has two types of modules:

Built in and User defined.

Built-in modules

This are the modules that come by default with the python software. 

User defined modules

This are basically created by the programmer


The main syntax is import <module name>

and it is placed at the top of the code




From........import
Sometimes when writing a code, you may just need a "section" from a module. Instead of importing the whole module, you introduce from...import.




you can also be a little extra and change the name of the function after importing it with the from...import...as




The dir() function
 dir() is used to list all the attributes included in a module. The syntax is:



No comments:

Post a Comment

HTML 101: Form

  I believe that everyone who has made use of the internet knows what a form is but in case you don't know, a form is a way of receiving...