What is a private method in Python?
Answer
Private methods signal to readers of the code that the methods are/should be used only within the class. So if you want to rename the private method or change its signature, you know that it should be called only from the same class. Thanks to this you know that you won't break calls from other classes, because there should be none.
The word "should" is used intentionally because in Python it is possible to call a private method from outside. However, it is highly recommended not to do so, because the private method communicates: "This method was designed by its author as a method that the others shouldn't be calling.". So if you decide to call it and the author renames it in the future and your code breaks, it is your fault because you ignored a wish of the original author for you not to use the method.
Related Python job interview questions
How do you add a new item to a list in Python?
Python JuniorHow do you display a number of items in a list in Python?
Python JuniorWhy would you use a private method in Python?
Python JuniorHow do you pass an argument to a class constructor in Python?
Python JuniorHow do you define a constructor in a class in Python?
Python Junior
Chat
Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.
e
@@xeDO0
1'"
e'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
L7oVYP7m')) OR 312=(SELECT 312 FROM PG_SLEEP(15))--
A1v25QPv') OR 393=(SELECT 393 FROM PG_SLEEP(15))--
kxT46vOm' OR 479=(SELECT 479 FROM PG_SLEEP(15))--
VTgcz37T'; waitfor delay '0:0:15' --
1 waitfor delay '0:0:15' --
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
if(now()=sysdate(),sleep(15),0)
-1" OR 3+906-906-1=0+0+0+1 --
-1" OR 2+906-906-1=0+0+0+1 --
-1' OR 3+316-316-1=0+0+0+1 or '8BoDIAd6'='
-1' OR 2+316-316-1=0+0+0+1 or '8BoDIAd6'='
-1' OR 3+137-137-1=0+0+0+1 --
-1' OR 2+137-137-1=0+0+0+1 --
-1 OR 3+877-877-1=0+0+0+1
-1 OR 2+877-877-1=0+0+0+1
-1 OR 3+418-418-1=0+0+0+1 --
-1 OR 2+418-418-1=0+0+0+1 --
e
e