Python Python: Retrieve Function Name Without Execution

  • Thread starter Thread starter zeion
  • Start date Start date
  • Tags Tags
    Minor Python
AI Thread Summary
The discussion centers around retrieving the name of a function in Python without executing it. The original poster inquires about how to print the name of a function, specifically asking if it's possible to display "apple" for a function defined as "def apple():". The solution provided indicates that one can use the syntax `print <function>.func_name` to achieve this. The poster later confirms that they found the answer, suggesting that the information may be useful for others encountering a similar question.
zeion
Messages
455
Reaction score
1

Homework Statement



Hi there,

I just have a quick one here..
Is there a way to bring the NAME of a function? Not execute it?

Like if I had

def apple():
return

Can I get it to print "apple" somehow?
Thanks

Homework Equations





The Attempt at a Solution

 
Technology news on Phys.org
Nevermind I found the answer.
In case anyone else is curious you can do

print <function>.func_name
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
16
Views
2K
Replies
2
Views
1K
Replies
19
Views
2K
Replies
2
Views
1K
Replies
15
Views
2K
Replies
18
Views
1K
Replies
9
Views
3K
Back
Top