wtfpython icon indicating copy to clipboard operation
wtfpython copied to clipboard

Another mangling example

Open MatzeB opened this issue 5 years ago • 1 comments

>>> def __greet():
...   print("hello")
...
>>> __greet()
hello
>>> class C:
...   def run(self):
...     __greet()
...
>>> C().run()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in run
NameError: name '_C__greet' is not defined

MatzeB avatar May 02 '20 04:05 MatzeB

Interesting, I'm wondering what should be the right way to call __greet inside the run method then

satwikkansal avatar Aug 01 '20 12:08 satwikkansal