240
Using comments as arguments in python.
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
As if I needed more reasons to start away from python
You can so stupid shit in any language. I admit Python doesn't exactly make it difficult. A bit like JS, but different.
Do you stay away from C++ too? You can do this there too
https://en.cppreference.com/w/cpp/utility/source_location/line
Being able to get the line number is very different from comments being parsed.
Edit: didn't realize this was custom code built to be cursed.
You should look at how OPs example works first maybe
The python interpreter isn't parsing comments, the add() function is just getting the current line number from the call stack context, and using a regex to spit out the numbers to the right of the "#" on the current executing line of the source code.
Yeah fair I was just assuming this was standard library, I see your point now.