Different from the import type of python. from A import B meaning

[Note] Different from the import type of python. How to use from, as.

There are multiple ways to call a module in python.

Check the difference between them.

type

  1. import A
  2. import A as B
  3. from A import C

Differences between

  1. import A

Load module A. Load all classes and functions defined in A.

Example


import datetime
(Load the datetime module)
* What is a module in the first place?

--A "file" that contains python definitions and sentences. --Various functions (tools) are described in the file. --You can enter function definitions and execution statements. --You can import other modules within a module

Official site


2. import A as B Load module A as name B (optional). Abbreviations are often set to make code writing easier.

Example


import pandas as pd
(Import pandas as pd)

■ For import pandas only df = pandas.DataFrame()

■ For import pandas ** as pd ** df = pd.DataFrame()


3. from A import B Load the function / class B of module A. (Function / Class = Tool)

Example


from selenium import webdriver
(selenium webdriver)

Load a tool called webdriver in the selenium file.

Definition of words

Differences between modules, packages and libraries

(1) Module: A .py file. ② Package: This is also a .py file. A collection of multiple modules ③ Library: Modules and packages. The definition is ambiguous. └ A file with many useful functions such as jQuery library

Reference site (Difference in language, how to make a package)

Recommended Posts

Different from the import type of python. from A import B meaning
[python] [meta] Is the type of python a type?
Python points from the perspective of a C programmer
[Python] The stumbling block of import
Existence from the viewpoint of Python
[Note] Import of a file in the parent directory in Python
[Python] Get the update date of a news article from HTML
Learning notes from the beginning of Python 1
The story of blackjack A processing (python)
Learning notes from the beginning of Python 2
[AtCoder explanation] Control the A, B, C problems of ABC182 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC186 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC185 with Python!
[AtCoder explanation] Control the A, B, C problems of ABC187 with Python!
From a book that makes the programmer's way of thinking interesting (Python)
[AtCoder explanation] Control the A, B, C problems of ABC184 with Python!
Get the contents of git diff from python
The answer of "1/2" is different between python2 and 3
A memorandum of calling Python from Common Lisp
Make a copy of the list in Python
A note about the python version of python virtualenv
[Python] A rough understanding of the logging module
Output in the form of a python array
Let's use different versions of SQLite3 from Python3!
A discussion of the strengths and weaknesses of Python
[Python] Determine the type of iris with SVM
[AtCoder explanation] Control the A, B, (C), D problems of ABC165 with Python!
[AtCoder explanation] Control the A, B, C, D problems of ABC183 with Python!
[Python] I tried to get the type name as a string from the type function
[AtCoder explanation] Control the A, B, C, D problems of ABC181 with Python!
The meaning of self
Python from or import
the zen of Python
Python3> round (a --b, 7)
The story of launching a Minecraft server from Discord
The wall of changing the Django service from Python 2.7 to Python 3
[Python] A program that counts the number of valleys
Calculate volume from the two-dimensional structure of a compound
Learn Nim with Python (from the beginning of the year).
Make a copy of a Google Drive file from Python
[Python] Get the text of the law from the e-GOV Law API
Cut a part of the string using a Python slice
Study from the beginning of Python Hour1: Hello World
How to write a list / dictionary type of Python3
A python implementation of the Bayesian linear regression class
Get the return code of the Python script from bat
Tasks at the start of a new python project
Study from the beginning of Python Hour8: Using packages
A reminder about the implementation of recommendations in Python
[Python] A program that compares the positions of kangaroos.
A little bit from Python using the Jenkins API
Python Note: The mystery of assigning a variable to a variable
A python script that gets the number of jobs for a specified condition from indeed.com
[Python] Representing the number of complaints from life insurance companies in a bar graph
Find out the apparent width of a string in python
A simple Python implementation of the k-nearest neighbor method (k-NN)
Towards the retirement of Python2
I just changed the sample source of Python a little.
A library that monitors the life and death of other machines by pinging from Python
Python --Check type of values
About the ease of Python