Posts: 4,646
Threads: 1,493
Joined: Sep 2016
how can a function find the name by which it is called?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
if foo calls
bar()
the name i want is "bar", not "foo"
if foo does
xyzzy = bar
then calls
xyzzy()
the name i want is "xyzzy"
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
(Aug-14-2022, 07:28 PM)Gribouillis Wrote: what do you want when foo calls
probably "xyz[0]". if i can get that piece of code, that would work. i suspect otherwise i'd get the function's
def name.
(Aug-14-2022, 07:28 PM)Gribouillis Wrote: Also what is the purpose of all this?
to allow the function to output a more meaningful message in the case of certain errors.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
i am wanting to phrase the message in a certain context for this user base that is following some specific instructions to get specific results. these users are running commands (in the future, to use a GUI app) that constructs some Python code. these users are not coders and probably have no understanding of a traceback or the Python message. if the function can get the name that would simplify the task. otherwise i will need to add another argument in both the function and all makers of calling code.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.