We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
getattr function is used to do many stuff as you can take idea from its name (getattr ----->> get attribute ) this function can be used to use any function's attribute without prefixing that function name for eg.
if we have to add item in the list how we genrally do
lst = []
lst.append(4) <---------note this append(4) this attribute and other attribute of any fuction can be also written as
getattr(lst, 'append')(4)
i hope you got it 😊😉 haha
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Set Mutations
You are viewing a single comment's thread. Return to all comments →
getattr function is used to do many stuff as you can take idea from its name (getattr ----->> get attribute ) this function can be used to use any function's attribute without prefixing that function name for eg. if we have to add item in the list how we genrally do
lst = [] lst.append(4) <---------note this append(4) this attribute and other attribute of any fuction can be also written as
getattr(lst, 'append')(4)
i hope you got it 😊😉 haha