Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which abbreviations should we use for python variable names?

Tags:

People also ask

Should you use abbreviations in variable names?

Single letters should be avoided as variable names. Instead, the terms that the single letters are referring to should be spelled out. Confusing acronyms and abbreviations, should be avoided in variable names. Instead, acronyms should be separated and abbreviations should be spelled out.

What are valid names for variables in Python?

Officially, variable names in Python can be any length and can consist of uppercase and lowercase letters ( A-Z , a-z ), digits ( 0-9 ), and the underscore character ( _ ). An additional restriction is that, although a variable name can contain digits, the first character of a variable name cannot be a digit.


In generally I'm using the standard naming stated in PEP-8 for variables. Like:

delete_projects
connect_server

However sometimes I can't find any good name and the name just extend to a long one:

project_name_to_be_deleted 

I could use pr_nm_del , but this makes the code unreadable. I'm really suffering finding good variable names for functions. Whenever I begin to write a new function I just spent time to find a good variable name.

Is there any standard for choosing certain abbreviations for well known variable names like, delete,project,configuration, etc. ? How do you choose short but good and readable variable names ?

This question might be not depend directly to Python, but as different programming languages uses different variable names formatting I thought I limit this question to Python only.