Second question from the same unit. Python keyword/statement

Course Name: Python for Trading: Basic, Section No: 4, Unit No: 12, Unit type: Notebook



#Below in relation to the previous question of mine from the same unit. 



In delete statement we are using square brackets while mentioning the keys;

example: del dict_name['KEY'],

while statements like pop we are using normal brackets ()

example: dict_name.pop

Why?

Hi Jeyaraman



The del keyword is a Python keyword. Everything in Python is an object; be it a dictionary or a simple variable. The del keyword is used to delete that object. Therefore, it is universal in the sense that it can be used to delete a variable/list/dictionary/set/tuple alike.



pop is a method of the dictionary data structure. It has its own syntax behind the scenes. A method is nothing but a function defined inside a class. If you check functions in Section 6 of the course, they require round brackets with arguments inside them (arguments). 



This is why we use round brackets at one place and square brackets at another.



Hope this helps.