Hidden Features of Python

It's tricky battle to choose the apt programming language for your career framework in the Data Science and Machine Learning field, when numerous languages are out there that serves with the much-needed options to learn as well as provide lots of features! However, the combat narrowed down to two popular languages-Python and R. And between the two, Python has emerged as the programming language leader! Now you might know why you should choose Python over R or any other languages like Java or JavaScript? Well, we will breakdown the Python's unique features that will make the picture more clear.

Unique/Hidden features of Python:

  1. Argument Unpacking
    We use two operators in Python, that is * (for tuples) and ** (for dictionaries), where we can use * to unpack the list so that all elements of it can be passed as different parameters.

  2. Braces
    Well, Curly Braces {} in python are used to define a dictionary, while in other languages, curly braces are used as part of the flow control.

  3. Chaining Comparison Operators
    Checking more than two conditions is very common in Programming languages and the most common syntax that we use to do is <, <=, >, >=, == and !=. But in Python, there is better way to write a series of comparison using Chaining comparison operators,
    for e.g.
    5== x >4o/p: True

  4. Decorators
    Decorators allows programmers to modify the behavior of function or class, that is, it allows the programmers to wrap another function in order to extend the behavior of a wrapped function, without completely modifying it. Decorators act as an important tool for python programmers, which is divided into two types: Function decorators and Class decorators

  5. Descriptors
    Descriptors are just a basic storage system, which allows users to adjust the values on attributes without any special processing. Python descriptors are created to manage the attributes of different classes which use the object as reference. Well, descriptors can be used in three different methods: _getters_(), _setters_(), and _delete_() and if any of those methods are defined for an object, it can be termed as a descriptor

  6. Dictionary Default .get value
    dict.get (key[, default]) is a built-in function, it is used when the key does not exist in the dict, then the default value specified as the second argument to get() is returned, however note that the default value defaults to 'None' if a second argument is not provided, hence there will not be any error

  7. Docstring Tests
    Docstrings in Python are used for the description of a class or a function to provide a better understanding of the code and use as well as used for Testing purposes.

  8. Ellipsis Slicing Syntax
    While Ellipsis Slicing Syntax feature in Python is used to slice higher-dimensional data structures. For example, if you have a 4-dimensional matrix of order 2x2x2x2, to select all first elements in the 4th dimension you can use the Ellipsis Slicing Syntax.

  9. Enumeration
    An enumeration is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over.

  10. For/else
    In the programming languages like Java, C++, C the use of else statement has been confined with the if conditional statementswhereas on the other hand, Python allow us to use both else and if condition with for loops

  11. Function as iter() argument
    Function as iter() argument is a built-in method, which returns an iterator object. It takes two arguments where the first argument is interpreted depending on the presence of the second argument

  12. Generator Expressions
    In order to create iterators in Python, we can use both regular functions as well as generators. Well, Generator expressions are best for implementing simple “ad hoc” iterators. Generators are written just like a normal function but we use yield()instead of return() for returning a result

  13. In Place Value Swapping
    Python allows us to swap values of the two variables with simple three lines of code rather than using s eries of codelines.
     For exa
    mple:
    a = 1
    b = 2
    a, b = b, a
    Through In Place Value Swapping method, Python allows us to swap values easily.

  14. _missing_ items
    Python 2.5 update comes with a special method called _missing_ items, that is invoked for missing items.

  15. Multi-line Regex
    With this method in Python, you can split a regular expression over multiple lines, name your matches and insert comments.

  16. Named String Formatting
    Python 3.6 introduces literal string formatting, so that you can format the named parameters without any repeating any of your named parameters outside the string For example:
    print(f'<a href="{my_url:s}">{my_url:s}</a>')

  17. Nested List/Generator Comprehensions
    Nested List Comprehensions are one of the most amazing features of Python, that is basically a list comprehension within another list comprehension which is quite similar to nested for loops. It is a smart and concise way of creating lists by iterating over an iterable object.


    Python has been widely used among companies like Google, Pinterest, Instagram, Disney, Yahoo, Nokia, IBM, and many others. Nearly 14% of the programmers use it on the operating systems like UNIX, Linux, Windows and Mac OS and around 1,26, 424 websites were developed using python programming language in the top-notch companies like Google, IBM etcSo, if you are aiming for a career in Python, then learn with us; because we have the best Python course that will suit your profession. With Edure, learn to code like a Web Developer!


Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
Edure Learning 2024 Privacy policy Terms of use Contact us Refund policy