Python I'm also basic

Writing notes reading smart Python programming

Shebang

#!/usr/bin/env python

By specifying the python interpreter via / usr / bin / env, you can call the default python interpreter in that environment without depending on a specific path. * However, it depends on the environment, so it is good or bad.

Encoding declaration

# -*- coding: utf-8 -*-

Specify which character code to interpret the source code.

Special attribute name

if __name__ == '__main__':
  main()

Variables and methods with names that have two consecutive underscores before and after indicate that they behave specially in Python. The name of the module is stored as a character string in __name__. When a module is executed as a script, the value " __main__ "is entered, and when it is called from another module, its own module name is entered, so it is not executed.

module

In Python, the Python file (.py) itself is a module.

package

A package is a module that can have multiple modules under it, and is a directory containing the files __init__.py. __init__.py is a module that represents the package itself. To add a module, just put the Python file under the directory.

print version compatible

print('Hello')

It is a minute in Python2 system, but since it is a function in Python3, it can be interpreted as both a sentence and a function by enclosing it in parentheses.

Coding style

Follow PEP8.

Recommended Posts

Python I'm also basic
RF Python Basic_01
Basic Python writing
Python3 basic grammar
RF Python Basic_02
Python basic course (12 functions)
Python basic grammar / algorithm
Python Basic Course (7 Dictionary)
Python basic course (2 Python installation)
Basic sorting in Python
Python basic course (9 iterations)
[python] class basic methods
Python Basic Course (11 exceptions)
Python basic course (6 sets)
Python3 cheat sheet (basic)
Python basic grammar (miscellaneous)
Python Basic Course (Introduction)
Python basic memorandum part 2
python basic on windows ②
Python basic memo --Part 2
Python basic course (13 classes)
Basic Python command memo
Python basic grammar note (4)
Python basic grammar note (3)
Basic knowledge of Python
Python basic grammar memo
OpenCV basic code (python)
Python basic memo --Part 1
python memorandum super basic
Python basic course (8 branches)
Python basic if statement
Python Basic Course (3 Python Execution)
Python Basic --Pandas, Numpy-
Basic Python 3 grammar (some Python iterations)
Python application: Pandas Part 1: Basic
Refactoring Learned in Python (Basic)
BASIC authentication with Python bottle
Python basic dict sort order
[Python] Using OpenCV with Python (Basic)
Python basic course (10 inclusion notation)
Python installation and basic grammar
Python Basic Grammar Memo (Part 1)
Python Basic Course (5 List Tuples)
Python basic grammar (miscellaneous) Memo (3)
Python basic grammar (miscellaneous) Memo (2)
Basic Python grammar for beginners
[Python] [SQLite3] Operate SQLite with Python (Basic)
Basic usage of Python f-string
I learned Python basic grammar
Python basic grammar (miscellaneous) Memo (4)
Python (Python 3.7.7) installation and basic grammar
I'm thinking of studying Python
Python Basic Course (1 What is Python)
Java and Python basic grammar comparison
Python
Scraping with Selenium in Python (Basic)
[Python] Basic knowledge used in AtCoder
Python Basic Course (14 Modules and Packages)
1. Statistics learned with Python 1-1. Basic statistics (Pandas)
Basic grammar of Python3 system (dictionary)
Basic Python operation 2nd: Function (argument)