Ty's Creatively Named Blog

Tuesday, February 28, 2006

Step on no pets (especially pythons)

Pleased with the symmetry of the last Python Quine, I decided to try for a different kind of symmetry. Here is the first, as far as I know, bytewise palindromic python quine:


#"""
d='print \'\\n#\\"\\"\\"\\nd=%s\\nexec d\\n\\"\\"\\"\\nd cexe\\n%s=d\\n\\"\\"\\"
#\'%(`d`,\'\'.join([`d`[-x] for x in range(1,len(`d`)+1)]))'
exec d
"""
d cexe
'))])1+)`d`(nel,1(egnar ni x rof ]x-[`d`[(nioj.'\'\,`d`(%'\#"\\"\\"\\n\\d=s%n\\e
xec dn\\"\\"\\"\\n\\d cexen\\s%=dn\\"\\"\\"\\#n\\'\ tnirp'=d
"""#


(Note: it starts with a blank line)

Monday, February 27, 2006

A Python Quine (at least there is symmetry)

Several years ago now, I think, I ran into a webpage with a collection of Quines in different languages. The Python entry was rather disappointing -- too long and unoriginal. I've seen a number of better ones since, but at the time I was inspired to create one that was shorter and used a unique feature of the language. So without further ado:

'print `__doc__`;print __doc__'
print `__doc__`;print __doc__

It can be shortened 5 bytes by using a temporary variable:

'd=__doc__;print`d`;print d'
d=__doc__;print`d`;print d


However, this version is still almost twice as long as the shortest Python quine I know of. So I will stick with the original. It may not be the shortest, but at least there is symmetry.

And so it begins...

So, the Web is coming up on 15 years old this August. I've been on "the net" since before that meant the Internet, back in the days of UUCP. I once had a BITNET address. But I still had no web presence. I was, er, virtually nonexistant.

But PJE and others have inspired me, and now I have a blog.

It doesn't have a name. It doesn't have a graphic theme I like. It doesn't have a coherent vision of what its topic might be. But now it has a post. And you are reading it, so now it has an audience.

Hi!

So, having created an audience out of thin air for a blog with no name, no topic, and only one post... well, that's a lot for one day. Time to knock off.

I will leave you with this thought:

If the aliens are reading our email to learn more about humans, they must have come to the conclusion by now that earthlings are obsessed with the pursuit of pleasure. Further, they have learned about our three most popular forms of pleasure:


  • Sex
  • Drugs
  • Mortgages

PMI-me-harder-ly yours,
Ty

(Tomorrow: A Python Quine)