Python Forum
a module discovering its own name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a module discovering its own name
#1
in a module that could be renamed when installed, is there a way for it to discover its own name at the time it is imported?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
myname = __file__
Reply
#3
__name__
Reply
#4
yay! they both work.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#5
__name__ is better, __file__ doesn't work in interactive mode because there is no file
Reply


Forum Jump:

User Panel Messages

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