Python Programming - Identifiers and Keywords
Identifiers
Identifiers are the set of valid strings/words/names which are allowed in a programming language.
Keywords
There are few specific words are used as identifiers for programming construct, these are called reserved words or keywords. These can not be used for any other purpose.
Python also has additional set of identifiers know as built-ins, which can not be used for other purpose even though they are not reserved words.
Valid Identifiers or Rules for creating valid identifier
To create user defined identifiers, following rules apply in Python,
- First character must be letter or underscore ( _ )
- Any additional characters can be alphanumeric or underscore
- Case-sensitive
- No identifier begins with a number, symbols except underscore are allowed
Python Keywords
Below is the comprehensive list of Python keywords, to know the keywords available in the python version you can use keyword() function from python shell.
>>>keyword()
List of Python Keywords (reserved words)
- and, or, not
- if, elif, else
- for, while
- in, is
- continue, break, return
- try, except, finally, raise
- global
- class
- lambda
- import, from
- def
- pass
- del
- exec
- assert
Some important notes on Python programming,
- Variables are not declared ahead of time
- Variable types are not declared
- No memory management on programmers part
- Variable names can be recycled
- del statement allows for explicit "deallocation"
Comments
Post a Comment