this post was submitted on 21 Nov 2024
193 points (97.5% liked)
Programmer Humor
32533 readers
547 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Why would python even expose the current line number? What’s it useful for?
On a serious note:
This feature is actually very useful. Libraries can use it create neat error messages. It is also needed when logging information to a file.
You should however never ever parse the source code and react to it differently.
You underestimate the power of us, print debuggers.
Why wouldn't it? Lots of languages do. In C++ you have
__LINE__
.Because it doesn't seem like a useful feature. The only occasion I imagine this could be helpful is with logging to the console to track when the function breaks, but even then - still trivial to replace.