Python Unknown (Tips and Tricks) — Part 1

Python features, tips, and tricks which are less - known.

HarshAditya_Gaur
1 min readJan 26, 2022
Hidden Features of Python

These are some python tips and tricks which are very uncommon and cannot be seen in practice by most of the users but are very useful when multiline codes are written for software development, machine learning, analytics etc.

Note - All features are tried and tested on python v3.8 (Anaconda3)

Chain Comparison - Rather than doing single comparisons. Python allows the user to do multiple comparisons at once.

Star Operator (*) - When a list or tuple is passed to a function, python does not decode it natively. This is due to ambiguity. So, the star operator comes in handy in this situation.

Ternary Operator - Sometimes called as a conditional expression which allows the user to write the if-else condition in one-liner rather than multiline code.

Syntax : value_true if condition else value_false

Walrus Operator (:=) - This operator allows the user to assign and return the value of a variable using a single expression.

Python map() function - This function provides the ability to iterate and process the data without using a loop.

More such tips and trick for python v3, coming soon in part 2..!!

Thank You..!! :)

--

--