this post was submitted on 21 Nov 2024
278 points (90.9% liked)
Programmer Humor
32557 readers
425 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
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.