in this we make iter function why we use double underscore
What is use of double underscore other than making method private
Hi deepanshu,
The double underscore (__) which is also called as Dunder it is wrap around special identifiers (method names and some other types of identifier like __name__
) which represents that these are special to the python language. So, The purpose is to minimize the chances of colliding these names with programmer chosen method_names and to keep the reserve word list relatively minimal as well.
Like __init__ , __next__
we don’t use these in our custom functions, since they have a special meaning in python.
So, it’s just those things that are special are differentiated by __ . These are sometimes also called as magic methods.
If you want to know the detailed explanation, see this blog