this post was submitted on 21 Nov 2024
284 points (90.8% liked)
Programmer Humor
32559 readers
604 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
Can we just clarify that you mean that comments should never be parsed by the language engine. There are valid annotation systems, but the goal is alway to ensure that one passable can never impact the other.
Imagine if here a comment could create a syntax error! This is even worse for runtime scripting languages like python.
Sure, but let's just clarify that this is someone going out of their way to create this problem, using Python's ability to read it's own code.
Basically, you can load any text file, including a source code file, and do whatever you want with it.
So, a function can be written that finds out whatever's calling it, reads that file, parses the comments, and uses them as values. This can also be done with introspection, using the same mechanism that displays tracebacks.