6 Answers
+ 26
Because You Can Custom Your Own Stuff Not Like Building TLS Package again for some objects 😒 It's also better than ELF Executables like trying to write a code imports some binary file noooo just import a module up to 400kb and that's it except if you're talking about something like paramiko that takes an hour to be imported that library is very heavy also the modules can provide something by the developers so they made it to make it easier to use system calls or some other stuff like tell me do you want to write some 52kb of code to do this:
parser.add_argument('-h','--hello',help='print hello')
+ 7
Yes, several. It means that there is less to compile and run by default. Your program will load faster, because it only knows about the parts of Python that it actually needs.
It keeps the global namespace clean, and allows functionality to be grouped logically into modules. Different modules can have identically-named functions without clashes (a file and socket class would probably both have open and close functions, for example).
For more details:
https://stackoverflow.com/questions/20306373/why-do-you-have-to-import-python-standard-library-functions
+ 5
I've given the link with title " For more details",try to understand brother 🤔
+ 5
Python is a dynamically typed language. Unlike statically typed languages like C++ and Java calls to methods aren't bound until they are actually executed, thus why importing the module were that method is defined is not necessary. This has several implications:
1. Methods (and data members) can be added to and removed from an instance at runtime, so two instances of class Foo can actually have different methods even though they are of the same type.
2. Methods (and data members) can be added to and removed from a class at runtime, which will impact all current instances as well as new instances.
3. Bases classes can be added and removed to a class at runtime.
+ 2
@ A Z M Mushfiqur Rahman,
Thanks for the link. Now I'm getting it.👍
But you should indicate that you only copied the answer from Stackoverflow.
+ 2
ok.