4 ms·
I mean, obviously. I would say it counts as cheating though. It’s on the same level as opening the source code file and printing it out.
by identity0 6y ago
I mean, obviously. I would say it counts as cheating though. It’s on the same level as opening the source code file and printing it out.
- xamuel 6y agoNo it's not on the same level, it's subtly different. The file could be altered during the brief instant between when you execute the file and when the program loads itself. Or the whole thing could be run from the REPL with no "file" at all.
- identity0 6y agoNot cheating as in “it might not work,” cheating as in “it trivializes the exercise.” The point of making a quine is a programming challenge. If python had a function called “quine()”, I would still call it cheating even if it worked 100% of the time.
- xamuel 6y agoSure, which is why I said "way easier". If you were assigning quine as a python homework exercise, and you wanted an "exec" solution ruled out, you would need to explicitly rule it out in the text of the exercise. >If python had a function called "quine()"... If we wanted to REALLY trivialize it, just use the blank program (which prints nothing, thus prints itself). :)