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

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

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

IIT Roorkee professor develops software to detect COVID19 in 5 second..

A professor at IIT-Roorkee has developed a software, which he claimed, can detect COVID-19 within five seconds. Kamal Jain IIT Roorkee’s Civil Engineering Department claimed that he took 40 days to develop the software, which will not only reduce time, but also testing costs drastically. At present, it takes about 24 to 48 hours to get COVID19 test results, and costs around Rs 4,500. The IIT professor also claimed that the new software will also reduce the risk of exposure to healthcare professionals. However, there has been no verification of his claim by any medical institution, including the Indian Council of Medical Research (ICMR). But, Kamal Jain is confident about his software, and has already filed a patent for the technique, and has also approached the ICMR for a endorsement. He claimed to have developed an AI-based database, which can analyze more than 60,000 X-ray scans, including those of COVID19, pneumonia and TB patients in about five seconds. In the pro