Identifiers -
Python is a case sensitive programming language. The words man and Man are two
different identifies in python.
An Identifier is a name used to
identify a variable, function, class, module or other object. An identifier
starts with a letter A to Z or a to z or an underscore (_) followed by zero or
more letters, underscores and digits (0 to 9)
Python does not allow
punctuation characters such as @, $, and % within identifiers.
Here are the naming Conventions
in Python
- Class Names start with an Upper
Case Letter
- All other Identifiers start with a
Lower Case Letter
- Starting an Identifier with a
Under-Score indicates that identifier is Private
- Starting an Identifier with 2
Under-Scores indicates a strongly private Identifier
- We all see a Identifier with 2
tailing under-Scores which means they are language defined special names
Indentation – Python
does not use a semi-colon of closing braces for statement end. Blocks of
statements or class and function definitions are identified by using
indentation.
The Indentation is rigidly
enforced. The
number of spaces in the indentation is variable, but all statements within the
block must be indented the same amount.
So all the continuous lines
indented with same number of spaces would form a block.
Comments - A hash
sign (#) that is not inside a string literal begins a comment.
Quotation -
Python accepts single ('), double (") and triple (''' or
""") quotes to denote string literals, as long as the same type
of quote starts and ends the string.
Reserved Words - Python
does contain reserved words for internal language structure. These reserved
works cannot be used with an constant or variable or any identifier names. Here
are the lists of the reserved words available in Python
And
|
exec
|
Not
|
Assert
|
finally
|
or
|
Break
|
for
|
pass
|
Class
|
from
|
print
|
Continue
|
global
|
raise
|
def
|
if
|
return
|
del
|
import
|
try
|
elif
|
in
|
while
|
else
|
is
|
with
|
except
|
lambda
|
yield
|
Suites – A group
of individual statement which makes a single code block are called suites.
Normally compound statements like if, else, while etc requires a header line
and a Suite like
if expression :
suite
elif expression :
suite
else :
suite
No comments :
Post a Comment