Re: Python self-evaluating strings

2008-01-29 Thread Ant
In the spirit of "Simple is better than complex." and totally bypassing the intention of quines (though not necessarily the definition): --- probably_not_a_real_quine.py import sys for line in open(sys.argv[0]): print line, -- ;-) -- Ant. -- http:/

Re: Python self-evaluating strings

2008-01-28 Thread Arnaud Delobelle
On Jan 29, 3:48 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | I found > this:http://groups.google.com/group/comp.lang.python/browse_thread/thread/... > > Exactly the one I meant. > > | It contains a lambda-solu

Re: Python self-evaluating strings

2008-01-28 Thread Terry Reedy
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | I found this: http://groups.google.com/group/comp.lang.python/browse_thread/thread/a1316cb4e216eba4/0cda739385abd03c?lnk=gst&q=Self-Reproducing+Program#0cda739385abd03c Exactly the one I meant. | It contains a lamb

Re: Python self-evaluating strings

2008-01-27 Thread Arnaud Delobelle
On Jan 27, 11:58 pm, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message > Some years ago there was a substantial thread on this, (Shortest > Self-Reproducing Programs, or some such) including a fairly long one from > me that gave several 'shortest' (

Re: Python self-evaluating strings

2008-01-27 Thread Arnaud Delobelle
On Jan 27, 4:14 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: [...] > 1. Starting from the classic idea (lambda x:x%x)('lambda x:x%x') I got   > the following > v=(lambda x:x%('"''""'+x+'"''""'))("""(lambda x:x%%('"''""'+x+'"''""')) > (%s)""") A bit more readable: v1=(lambda x:x%('r\"'+x+'\"'))

Re: Python self-evaluating strings

2008-01-27 Thread Terry Reedy
"Arnaud Delobelle" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | An earlier post today got me thinking about "quines" (programs that | output themselves) in Python. I tried to find some on the web but | didn't find many ([1]). In particular I didn't find any that | corresponded

Re: Python self-evaluating strings

2008-01-27 Thread Boris Borcic
Now there's always that style : >>> print x Traceback (most recent call last): File "", line 1, in eval(x) File "", line 2 Traceback (most recent call last): ^ SyntaxError: invalid syntax >>> eval(x) Traceback (most recent call last): File "", lin

Re: Python self-evaluating strings

2008-01-27 Thread dg . google . groups
It's a bit cheap, but how about >>> from inspect import getsource >>> print getsource(getsource) or similarly def f(g): import inspect return inspect.getsource(g) print f(f) Dan -- http://mail.python.org/mailman/listinfo/python-list

Python self-evaluating strings

2008-01-27 Thread Arnaud Delobelle
Hi all, An earlier post today got me thinking about "quines" (programs that output themselves) in Python. I tried to find some on the web but didn't find many ([1]). In particular I didn't find any that corresponded to my instinctive (LISP-induced, probably) criterion: def self_evaluating