Maria Teresa notation for Python (also known as MT notation) is intended to help developers with the programming style and the variable names in Python.
As the type hinting of Python is weak, the notation helps to identify bugs by seeing, with the prefix, what kind of variable was it intended for.
It is inspired by the old and useful Hungarian notation.
I would like to credit and to show gratitude to a great person and developer, that passed away many years ago, and who shown me for the very first time the advantages of using prefix notation when coding, long time ago much before PHP appeared. In loving memory of Emilio.
Specification v. 1.0 Created on 1999-07-01
Specification v. 1.12. Last modified 2020-04-10
Specification v. 1.20. Last modified 2021-07-16
In general following PEP-8, with some additions.
The names have to be significant, so auto-descriptive.
Do not use k or i even for loops.
Use i_loop i_counter i_num_matches etcetera instead.
It recommends some prefixes:
It is not recommended to use Global variables, but if you have to use them variables defined in the main body that are intended to used publicly, or used inside many methods and functions, being accessed globally will start with:
|Prefix||Type of variable|
|i_||Integer or numeric in general if you don’t use f_|
|f_||Float. Optional use|
|h_ or d_||Array hash, also called dictionary|
|a_||Array List, with numeric keys|
|t_||Tuples. Like Lists, but immutables. Optional use|
|c_||Counters. From collections.Counter()|
|o_||Object / Class / Resource or Recordset|
|l_[x]_||Local variable. Optional use.|
l_o_subprocess inside a method or function in opposition to the o_subprocess from the global scope.
Class names in Camel Case and Constants in Uppercase.
If you use an array were all the values are String, you can prepend a_s_
If you use a dictionary where keys are String and values are Integer you can prepend d_s_i_
If you use a dict where keys are String and values are Arrays you can prepend d_s_a_
The MT notation can also be used to build SQL queries. It is specially useful for locating errors quickly in JOINS (like comparing VARCHAR and INT) and in Stored Procedures.