0% found this document useful (0 votes)
12 views

2.1 Python Identifiers and Reserved Words

Uploaded by

Rahul Sonawane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

2.1 Python Identifiers and Reserved Words

Uploaded by

Rahul Sonawane
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Names and tokens

 Allowed characters: a-z A-Z 0- 9, underscore, and must begin with a letter or underscore.
 Names and identifiers are case sensitive.
 Identifiers can be of unlimited length.
 Special names, customizing, etc. Usually begin and end in double underscores.
 Special name classes Single and double underscores.
o Single leading single underscore--Suggests a "private" method or variable name.
Not imported by "from module import *".
o Single trailing underscore-- Use it to avoid conflicts with Python keywords.
o Double leading underscores-- Used in a class definition to cause name mangling
(weak hiding). But, not often used.
 Naming conventions Not rigid, but:
o Modules and packages all lower case.
o Global and constants Upper case.
o Classes Bumpy caps with initial upper.
o Methods and functions All lower case with words separated by underscores.
o Local variables Lower case (with underscore between words) or bumpy caps with
initial lower or your choice.
o Good advice Follow the conventions used in the code on which you are working.
 Names/variables in Python do not have a type. Values have types.

You might also like