IdeaMonk

thoughts, ideas, code and other things...

Saturday, March 20, 2010

Quine attempt :)

Just tried writing a quine in python, I'm ashamed that it took me too much time to find a solution, so the hide the shame I covered my quine in an ascii art -

#!/usr/bin/env python
# -*- coding: utf-8 -*-
if __name__ == '__main__':
"""
'adppppba, pp
dp" `"pb ""
dp` `pb
pp pp pp pp pp pb,dPPYba, ,adPPYba,
pp pp pp pp pp ppP` `"pa apP_____pp
Yp, "pp,,pP pp pp pp pp pp pPP'""'"""
print open(__file__).read();"""pp pp "pb, ,aa
`"YppppY"Ypa `"YbbdP'Yp pp pp pp '"Ybbdp'
"""


Another approach with sys.exit() -
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
if __name__=='__main__':
print open(__file__).read()
sys.exit(0)

for x in xrange(1,10):
for y in xrange(x):
print chr(y),
print

# ^^ this one is just a cover up, actual quine ends at exit


and yet another approach with muting the stdout :P -
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

class Mute:
def write(self,msg):
''' I am a quine alright '''
def flush(self):
''' so am i :P '''

if __name__=='__main__':
print open(__file__).read()
sys.stdout, sys.stderr = Mute(),Mute()
for x in xrange(1,10):
for y in xrange(x):
print chr(y),
print

foozooooo < iz_this_an_error

if now_this_too:
if you_too:
if santa:
if you:
if me:
if no_one_at_all:
' /( )\
\ \__ / /\
/- _ `-/ / \
(/\/ \ \ \
/ / | ` \
O O ) |\
`-^--``< /\
(_.) _ ) / \
`.___/` |\
`-----` \
<----. __ / __ \
<----|====O)))==) \) \
<----` `--` `.__,` \
| |\
\ /\
____( (_ / \_____\
,` ,----` | \
`--{__________) \/'

Labels: ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home