Hacker News new | ask | show | jobs
by a1369209993 1372 days ago
The same way as a normal quine:

  $ cat >a.py
  #! /bin/python
  import hashlib
  s='#! /bin/python\nimport hashlib\ns=%r\nprint hashlib.sha512(s%%s).hexdigest()\n'
  print hashlib.sha512(s%s).hexdigest()
  $ python a.py
  cf1daf466a7a95b245eab685b808fb861dab9af26078250a8041c4c08a8ff384 (edit: wrap)
  7f7d1853f9d62d6b40cc53d0c5be3efd80eb09f57b71250910c0d6157b73fcd3
  $ sha512sum a.py
  cf1daf466a7a95b245eab685b808fb861dab9af26078250a8041c4c08a8ff384 (edit: wrap)
  7f7d1853f9d62d6b40cc53d0c5be3efd80eb09f57b71250910c0d6157b73fcd3  a.py
1 comments

Oh duh. That's a clever trick which is rather obvious in hindsight.