Python Forum
how it works??? "__name__"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how it works??? "__name__"
#1
Hi I am a new to Python. Can somebody explain me how this program works and particularly the flow of program. Why the output shows as "inner". Regards and Thanks in advance.
def outer():
    x = 3
    def inner(): 
       y = 4
       result = x+y
       return result  
    return inner 

a = outer()
print(a.__name__) 
Output:
output: inner
Gribouillis write May-31-2023, 07:47 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.

Attached Files

.py   inner.py (Size: 173 bytes / Downloads: 92)
Reply


Messages In This Thread
how it works??? "__name__" - by Vensworld - May-31-2023, 07:37 AM
RE: how it works??? "__name__" - by buran - May-31-2023, 09:02 AM
RE: how it works??? "__name__" - by deanhystad - May-31-2023, 02:12 PM
RE: how it works??? "__name__" - by DeaD_EyE - May-31-2023, 03:28 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020