Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a function name dunder
#3
that's outside of foo(). what about inside? code foo() to print() the value it has (e.g. for a function to realize its own name). the purpose is so i can insert or import some code from another file or module that will learn the name of the function it was in the definition of.

Output:
lt1a/forums/3 /home/forums 6> python3.8 Python 3.8.10 (default, Nov 22 2023, 10:22:35) [GCC 9.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def foo(): ... print(__name__) ... >>> bar = foo >>> bar() __main__ >>> lt1a/forums/3 /home/forums 7>
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
a function name dunder - by Skaperen - May-29-2024, 04:15 AM
RE: a function name dunder - by Gribouillis - May-29-2024, 06:31 AM
RE: a function name dunder - by Skaperen - May-29-2024, 05:35 PM
RE: a function name dunder - by Gribouillis - May-29-2024, 06:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Dunder Methods menator01 8 2,116 Mar-24-2022, 03:58 AM
Last Post: deanhystad
  Hi, looking for "dunder" tutorials. AlluminumFoil 3 2,167 Mar-02-2020, 08:37 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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