4 ms·
Maybe I'm missing something, but is the following valid? #!/usr/bin/python2 print open(__file__).read() # do other stuff as well That is, why not
by davidism 14y ago
Maybe I'm missing something, but is the following valid?
#!/usr/bin/python2
print open(__file__).read()
# do other stuff as well
That is, why not just print the source file, rather than store the code within itself?
- kd0amg 14y agoIf the running program has to get its source code from some external source like a file, it's generally not considered a quine (consider a Turing machine -- its state transition function is not written anywhere on the tape).
- tsm 14y agoIf you want the easy-but-legal way out, try this one (but strip out the lines with comments first): #Start of program #End of program