Asking to much from MicroPython? Get method name from method pointer? #16310
Replies: 3 comments 5 replies
-
Do you mean something like this? def fn():
...
print(f"Calling {fn.__name__}")
fn() Which will print |
Beta Was this translation helpful? Give feedback.
-
You can use the string representation of the function or method. obj = MyClass() |
Beta Was this translation helpful? Give feedback.
-
For my purposes... a bit of enhanced tracking/logging name was sufficient. I had base class, and I had several classes using the same base, but I wanted to log the name of derived class, from within a base class method, for example in init and my 'dispose' (versus del given it is not consistently called automatically in MP) base method, so logging would show when a class was constructed and destructed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Asking to much from MicroPython? Maybe? Get method name from method pointer?
Using (regular) Python, I often log method calls before the actual call is executed, getting the name of the method from its functional pointer is not always straight forward even in (regular) Python, but is the same in concept doable in MicroPython? A bridge too far?
Beta Was this translation helpful? Give feedback.
All reactions