naming conventions Flashcards
Name Constants
Use all uppercase, can also use with snake case
Name Classes
CapitalizedWords - camel case
What is ugly
Capitalized words with underscores
Match each definition to its corresponding naming style:
(1) Words are separated with a single capitalized letter and the first word starts with a lowercase letter.
(2) Words are separated with an underscore and all words start with a lowercase letter.
(3) Words are separated with a single capitalized letter and the first word starts with an uppercase letter.
1) Lower camel case
2) snake Case
3) Upper camel case
Upper Camel Case is also known as…
Pascal Case
Variable names must start with?
A letter or underscore
What can a variable name not start with
Number
Can a variable name contain special symbols
No, Only alphanumeric characters
style/PEP8 variable names
snake case
style/PEP8 functions names
snake case
Should variable names be pronounceable?
Yes, try not to abbreviate
Should variable names be easy to do search on?
Yes
What letters should you never use as single character variable names.
Never use the characters ‘l’ (lowercase letter el), ‘O’ (uppercase letter oh), or ‘I’ (uppercase letter eye) as single character variable names.
In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use ‘l’, use ‘L’ instead.
style/PEP8 if you have to use a python keyword as a variable/function name add ? at the end of the name
underscore
class_
Boolean Variables:
Usually, the names of variables that only take boolean values (True and False) should start with the following prefixes:
is
has
Examples:
is_valid is_logged_in is_open is_finished has_pets has_next has_children