Last active
January 31, 2016 18:10
-
-
Save Ivoz/3de6ff284d327e49afd0 to your computer and use it in GitHub Desktop.
Revisions
-
Ivoz revised this gist
Jan 31, 2016 . 1 changed file with 2 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,10 +12,7 @@ quine = f.read() output = subprocess.check_output("%s %s" % (sys.executable, sys.argv[1])) if quine != output: sys.exit(1) foreword = """#!/usr/bin/env python3 @@ -35,10 +32,7 @@ quine = f.read() output = subprocess.check_output("%s %s" % (sys.executable, sys.argv[1])) if quine != output: sys.exit(1) foreword = """#!/usr/bin/env python3 -
Ivoz revised this gist
Jan 31, 2016 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ''' A "self-verifying" quine - `<quine> <source_file>` will only print itself if `<quine>` has the same output as `cat <source_file>` ''' source = r'''{foreword} @@ -20,8 +20,8 @@ foreword = """#!/usr/bin/env python3 \'\'\' A "self-verifying" quine - `<quine> <source_file>` will only print itself if `<quine>` has the same output as `cat <source_file>` \'\'\' source = r\'\'\'""" last_line = 'source.format(foreword=foreword + source + "\'\'\'", program=last_line)' @@ -43,8 +43,8 @@ foreword = """#!/usr/bin/env python3 \'\'\' A "self-verifying" quine - `<quine> <source_file>` will only print itself if `<quine>` has the same output as `cat <source_file>` \'\'\' source = r\'\'\'""" last_line = 'source.format(foreword=foreword + source + "\'\'\'", program=last_line)' -
Ivoz revised this gist
Jan 31, 2016 . 1 changed file with 44 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,51 @@ #!/usr/bin/env python3 ''' A "self-verifying" quine - `python quine.py quine.py` will only print itself if `python quine.py` is the same as `cat quine.py` ''' source = r'''{foreword} import sys, subprocess if len(sys.argv) > 1: with open(sys.argv[1], 'rb') as f: quine = f.read() output = subprocess.check_output("%s %s" % (sys.executable, sys.argv[1])) if quine == output: sys.stdout.buffer.write(output) sys.exit() else: sys.exit(1) foreword = """#!/usr/bin/env python3 \'\'\' A "self-verifying" quine - `python quine.py quine.py` will only print itself if `python quine.py` is the same as `cat quine.py` \'\'\' source = r\'\'\'""" last_line = 'source.format(foreword=foreword + source + "\'\'\'", program=last_line)' sys.stdout.write({program}) ''' import sys, subprocess if len(sys.argv) > 1: with open(sys.argv[1], 'rb') as f: quine = f.read() output = subprocess.check_output("%s %s" % (sys.executable, sys.argv[1])) if quine == output: sys.stdout.buffer.write(output) sys.exit() else: sys.exit(1) foreword = """#!/usr/bin/env python3 \'\'\' A "self-verifying" quine - `python quine.py quine.py` will only print itself if `python quine.py` is the same as `cat quine.py` \'\'\' source = r\'\'\'""" last_line = 'source.format(foreword=foreword + source + "\'\'\'", program=last_line)' sys.stdout.write(source.format(foreword=foreword + source + "'''", program=last_line)) -
Ivoz created this gist
Jan 31, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ source = r'''{foreword} import sys line = 'source.format(foreword="source = r\'\'\'" + source + "\'\'\'", program=line)' sys.stdout.write({program}) ''' import sys line = 'source.format(foreword="source = r\'\'\'" + source + "\'\'\'", program=line)' sys.stdout.write(source.format(foreword="source = r'''" + source + "'''", program=line))