__FILE__ and __LINE__ in Python
Ned Batchelder shows how to use sys._getframe() to get the current (or calling) filename, line, and function in Python. In C, this happens at compile-time. Practically everything in Python happens at runtime, so this is slower, but you can also do things like inspect the local variables in the stack frames.
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed