Skip to content

Commit 4662f75

Browse files
author
Sagar Chalise
committed
variable naming of loops and contexts
1 parent 420d0c9 commit 4662f75

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/python/variables.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ sidebar_label: Variables
1414
- `__{variable_name}` are not directly accesible while `_{variable_name}` are. They are just for convention.
1515
* Avoid builtin variable clash. Especially in `globals`. You can attach `_` as suffix to builtin names if you deem the name necessary for your variable.
1616
- `all` or `id` is very tempting variable names but they are builtin methods in python. Go with `all_` or `id_` for these or better yet choose something else as a name.
17+
* While it is tempting to use `i`, `k`, `v` and `f` especially in contexts and for loops. Please avoid them.
18+
- use `key`, `value`, `index` instead.
19+
- use descriptive contexts such as `with open(FILENAME) as open_file: pass` rather that `with open(FILENAME) as f:`

0 commit comments

Comments
 (0)