Skip to main content

5 less-popular Python features you may not know


     BY DIVAKAR KUMAR PANDAY

Python is among the fastest-growing programming languages today. There are more and more developers exploring Python than ever before. Some of the Python functionalities are brilliant. Here are a few of the Python functions that are less popular among developers.

1. Variable Assignment
Similar to functions such as args and kwargs, you can use the same syntax in variable assignments. Using iterable variable assignment methods can be useful when merging dictionaries. But you need to be cautious as there are many common keys between these two dictionaries. The latest Python 3.9 offers a fresh new syntax for this exact problem.

2. Frozensets
You can use sets, which are unordered collections of distinct objects. These sets are mutable, which can help in changing them with add() and remove(). You can also use these immutable frozenset() but cannot change its values. Using the frozenset() as a dictionary key is not that useful but it can give more explicit intentional code.

3. Better than Lambdas
Using lambdas for quick and easy one-liners is pretty common. You can rarely use it to build multi-argument functions. These lambdas can be used to create elegant one-liner functions. Before you start coding lambdas everywhere, be aware that this is probably one of the most hated uses of syntax in Python.

4. Multiple conditionals
Cleaning up messy if-statements is possible with multiple conditionals. You can use the multiple conditionals to add more conditional statements and chain them together with bitwise operators.

5. Check if a variable exists
You can check for variables in both the global and local scopes using globals() and locals() respectively. Both scope functions return dictionaries to implement our dictionary merging syntax. The code then checks for both test1 and test2 in this merged scope dictionary.

Comments

Popular posts from this blog

Know About Lindedin

             BY   DIVAKAR KUMAR PANDAY LinkedIn is an American business and employment-oriented online service that operates via websites and mobile apps. it is mainly used for professional networking, including employers posting jobs and job seekers posting their CVs. Founded:   2002, Mountain View, California, United States Headquarters:   Sunnyvale, California, United States Launched on May 5, 2003 Official website :   https://www.linkedin.com/ Parent organization: Microsoft Corporation Founders:  Konstantin Guericke                       Reid Hoffman                      Jean-Luc Vaillant LinkedIn is a social media platform geared to professionals. It enables you to network and to build your professional portfolio, but you can also go out into the world and look for a new job. Professionals who’ve been in business for decades use LinkedIn and so do newly minted college grads. It is also used by employers and recruiters who are looking for job candida

Nearly 2,000 e-contents uploaded to Magadh University website: VC

          BY  DIVAKAR KUMAR PANDAY. Ever since the introduction of online teaching in Magadh University in mid-April, nearly 2000 e-contents have been uploaded to the university website, says vice chancellor Prof Rajendra Prasad and fresh uploads are being made for the benefit of students. The good thing, according to the VC was that students of other universities too can benefit from the study material available on the MU website. The colleges too have been directed to provide links of their online teaching programmes on their respective websites. “Conceding that online teaching cannot be a substitute to classroom interactions,” the VC said that the university has to adapt itself to the post-covid realities. E-learning was here to stay post Covid as well in the form of supplement to class room teaching, said Prof Rajendra Prasad. Whereas the performance of PG departments and constituent colleges have been satisfactory in the field of online teaching, the same cannot be said about the

Reliance launches e-commerce platform JioMart across several cities

           BY   DIVAKAR KUMAR PANDAY     Reliance has finally launched its e-commerce portal JioMart for several cities across India after running a pilot for limited pin codes in Mumbai, a move that is set to change the current positioning of the online grocery delivery service in India which is currently dominated by Bigbasket and Grofers. The service is live across Mumbai, Chennai, Kolkata, Hyderabad, Delhi, Bengaluru, Jaipur, Trivandrum and some tier II cities as well. During the pilot, JioMart was working with a WhatsApp business account. The JioMart website has listed essential grocery items as well as farm produce. The fruits and vegetables will be directly sourced from farmers that have collaborated with the brand. So technically, it would also compete with micro delivery platforms such as Swiggy’s Suprdaily, BBDaily and Milkbasket, and also farm to fork businesses including Ninjacart and Crofarm. The  platform  covers everything related to grocery, FMCG and consum