Sideway
output.to from Sideway
Draft for Information Only

Content

Python
 Python Integrated Development Environment
 Python Features
  Python Scripts Execution
  Python Indentation
  Python Variables
  Python Comment
  Encoding Declarations
 Source and Reference

Python

Python is an interpretered general purpose scripting language created by Guido van Rossum. The offical web site of python is www.python.org .

Python Integrated Development Environment

Python has a built-in integrated development environment called Integrated Development and Learning Environment (IDLE). IDLE has two main window types, the shell window and the editor window. It is possible to have multiple editor windows simultaneously.
The most common python shell window can be opened by entering the Python command in Windows Commond Prompt image The python IDLE shell window can be opened by running the python ".\Lib\idlelib\idle.py" program. in Windows Commond Prompt. image The IDLE shell window will then be activated. image The IDLE editor window can then be opened by clicking File>New File in the IDLE shell window. image The IDLE editor window will then be activated. image

Python Features

The typical features of Python are Python scripts execution, Python indentation, Python variable, and Python comment.

Python Scripts Execution

Python scripts can be executed in an interactive mode by entering in the shell window directly, or in script mode by saving Python script in a python file with .py extension and then running the python file in the command line accordingly, python file.py.

Python Indentation

Indentation refers to the leading whitespaces at the beginning of a script line. Although code indentation used in other programming languages is for readability only, code indentation play an important role in Python scripting because Python uses code indentation to indicate a block of code. There is no limitation on the number of indentation spaces, but code lines of the same block must have the same number of indentation spaces.

Python Variables

A Python variable is created by assigning a value to a variable name. Besides standard python variable, there are two special variable syntaxes used in python.
  • *args: * is the syntax symbol to indicate a variable-length variable list. args is the variable name of the variable list. *args is used to represent a variable-length of non-keyworded argument list. *args can also be used to pass a variable number of arguments to a function.
  • **kwargs: ** is the syntax symbol to indicate a variable-length keyword variable list. kwargs is the variable name of the keyword variable list. **kwargs is used to represent a variable-length of keyworded argument list. **kwargs can also be used to pass a variable number of keyworded arguments to a function.

Python Comment

Python use a # symbol to indicate the beginning of a comment and the rest of the code line is render as comments. Besides,the triple quotes used to deal with multi-line strings in Python can also be used as a mult-line python comment by coding only a regular strings with no other references.

Encoding Declarations

If a comment in the first or second line of the Python script matches the regular expression coding[=:]\s*([-\w.]+) this comment is processed as an encoding declaration; the first group of this expression names the encoding of the source code file. The encoding declaration must appear on a line of its own. If it is the second line, the first line must also be a comment-only line. The recommended forms of an encoding expression are
# -*- coding: <encoding-name> -*-
which is recongnized also by GNU Emacs, and
# vim:fileencoding=<encoding-name>
which is recognized by Bram Moolenaar's VIM. If no encoding declaration is found, the default encoding is UTF-8. In addition, if the first bytes of the file are the UTF-8 byte-order mark (b'\xef\xbb\xbf'), the declared file encoding is UTF-8, this is supported, among others, by Microsoft's notepad. if an encoding is declared, the encoding name must be recognized by Python. The encoding is used for all lexical analysis, including string literals comments and identifiers.

Source and Reference


©sideway

ID: 200400702 Last Updated: 4/7/2020 Revision: 0


Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Set 1

Logic 1

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019