Sideway
output.to from Sideway
Draft for Information Only

Content

Python Language
 Python Rule Notation
  Example
 Python Language Grammar
  Identifiers
  Keywords
   Reserved Keywords
   Reserved Classed of Identifiers
  Literals
  Operators
  Delimiters
 Source and Reference

Python Language

Python language is similar to visual basic. Python script is also interpretered by an interpreter line by line, but there are many differences between the languages.

Python Rule Notation

The rule notation used in Python:
  • A rule begins with a name and ::=, and end with details.
  • A vertical bar | is used to separate alternatives.
  • A star* means zero or more repetitions of the preceding item item.
  • A plus + means one or more repetitions.
  • A optional phrase enclosed by square brackets [] means zero or one occurrences.
  • The grouped phrase enclosed by parentheses () means grouping.
  • The literal string enclosed by quotes "" means literal strings
  • White space   is only meaningful to separate tokens.
  • Three dots ... mean a choice of any single character in the given inclusive range of ASCII characters
  • A phrase between angular brackets <...> gives an informal description of the symbol defined.

Example

name::=lc_letter (lc_letter | "_") lc_letter::="a"..."z"

Python Language Grammar

The typical elements of Python Language of version 3.8.x.

Identifiers

Identifiers or names are the name of a Python thing. Identifiers are unlimited in length but case is significant. The valid characters within the ASCII range U+0001...U+007F for identifiers are same as Python 2.x, the uppercase and lowercase letters A through Z, the underscore _, and except for the first character, the digits 0 through 9. Other chararcters outside the ASCII range are also supported by Python 3.0.
identifier::=xid_start xid_continue*
    id_start::=<all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
    id_continue::=<all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
    xid_start::=<all characters in id_start whose NFKC normalization is in "id_start xid_continue*">
    xid_continue::=<all characters in id_continue whose NFKC normalization is in "id_continue*">
The Unicode category codes mentioned above stand for:
  • Lu - uppercase letters
  • Ll - lowercase letters
  • Lt - titlecase letters
  • Lm - modifier letters
  • Lo - other letters
  • Nl - letter numbers
  • Mn - nonspacing marks
  • Mc - spacing combining marks
  • Nd - decimal numbers
  • Pc - connector punctuations
  • Other_ID_Start - explicit list of characters in PropList.txt to support backwards compatibility
  • Other_ID_Continue - likewise

Keywords

Some words are used as reserved words or keywords of the Python language that have special meaning and cannot be used as ordinary identifiers.

Reserved Keywords

keyword::="and" | "as" | "assert" | "async" | "await" | "break" | "class" | "continue" | "def" | "del" | "elif" | "else" | "except" | "False" | "finally" | "for" | "from" | "global" | "if" | "import" | "in" | "is" | "lambda" | "None" | "nonlocal" | "not" | "or" | "pass" | "raise" | "return" | "True" | "try" | "while" | "with" | "yield" |
"print" | "exec" 

Reserved Classed of Identifiers

Some classes of identifiers with the patterns of leading and trailing underscore characters having special meanings are also reserved. _*Not import by from module import *. The sepcial identifier _ is used in the interactive interpreter to store the result of the last evaluation. When not in interactive mode, _ has no special meaning and is not defined. The name _ is often used in conjunction with internationalization __*__System-defined names, informally known as “dunder” names. These names are defined by the interpreter and its implementation (including the standard library). __*Class-private names. Names in this category, when used within the context of a class definition, are re-written to use a mangled form to help avoid name clashes between “private” attributes of base and derived classes.

Literals

Literals are notations for constant values of some built-in types. Some typical literals are string literalsCharacter string bytes literalsImmutable sequence of single byte bytearray literalsMutable sequence of bytes numeric literalsNumeric Value integer literalsInteger Value floating point literalsFloating point number imaginary literalsImaginary boolean literalsBoolean value list literalsMutable sequence of objects tuple literalsImmutable sequence of objects dictionary literalsMutable associative mapping (aka dictionary) set literalsMutable unordered set of distinct objects frozenset literalsImmutable form of set class

Operators

An operator is a symbol that performs an operation on one or more operands.
Operators::="+" | "-" | "*" | "**" | "/" | "//" | "%" | "@" | "<<" | ">>" | "&" | "|" | "^" | "~" | ":=" | "<" | ">" | "<=" | ">=" | "==" | "!=" 

Delimiters

A delimiter is a sequence of one or more characters used to specify the boundary between independent regions or elements.
Operators::="(" | ")" | "[" | "]" | "{" | "}" | "," | ":" | "." | ";" | "@" | "=" | "->" | "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "@=" | "&=" | "|=" | "^=" | "<<=" | ">>=" | "**=" 
The period can also occur in floating-point and imaginary literals. A sequence of three periods has a special meaning as an ellipsis literal. The second half of the list, the augmented assignment operators, serve lexically as delimiters, but also perform an operation. The printing ASCII characters, ', ", #, and \, have special meaning as part of other tokens or are otherwise significant to the lexical analyzer. The printing ASCII characters, $ and ?, are not used as operators in Python, but can be used in string literals and comments.

Source and Reference


©sideway

ID: 200501002 Last Updated: 5/10/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

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