shortest python quine?

后端 未结 10 1787
天涯浪人
天涯浪人 2020-12-23 19:55
_=\'_=%r;print _%%_\';print _%_

Is this the shortest possible python quine, or can it be done better? This one seems to improve on all the entrie

10条回答
  •  执念已碎
    2020-12-23 20:48

    Both

    print open(__file__).read()
    

    and anything involving import are not valid quines, because a quine by definition cannot take any input. Reading an external file is considered taking input, and thus a quine cannot read a file -- including itself.

    For the record, technically speaking, the shortest possible quine in python is a blank file, but that is sort of cheating too.

提交回复
热议问题