Shorthand is defined as “a rudimentary technique of writing using abbreviations or symbols” in simple English. For instance, we shorten the word Kentucky Fried Chicken to KFC rather than using the complete name. Shorthand is a term used to describe writing that is so condensed. Let’s now discuss what shorthand means in the context of the Python language.
Shorthand statements are executable statements that are expressed so succinctly that they only contain one line of code.
Python provides a wide variety of shorthand statements that enable us to write our code in a more condensed manner while taking up less space.
If we write the statement:
If-expression if(Condition) else else-expression
It will be same as:
if condition:
if-expression
else:
else-expression
First of all, employing the shorthand form requires less typing. It is incredibly stressful to write something in four or five lines that might be put in one if you are creating a project that requires thousands of lines of code.
The second benefit of brief programming is that it is handled effectively by the compiler. When working on a large project, such as Amazon (12 Million lines of code), Facebook (62 Million lines of code), or Google (2 Billion lines of code), it is crucial to save as many lines of code as we can by writing it in a compact form. However, it does not matter for short program, even if they are a few thousand lines long.
The fact that shorthand is difficult to read is another drawback. When working on a project in a group, we always attempt to pick the technique that is the simplest to grasp, and producing a compact code often causes problems when we share our code with someone. Regardless of the strategy we choose, we should always be aware of all other options because different strategies are employed by different people.