> I'm thinking how interesting it would be to add code blocks to Python, so 
 > that arbitrary strings of code can be passed around.   It would open up some 
 > interesting possibilities for self-modifying code and generic programming.
>
> My suggestion would be to use triple double-quoted strings.  

Hmmm.  Would be interesting to do this:

>>> codestr = decode(SomeClass)

...and have it return a triple-quoted string of the perhaps-reduced source for 
the class.  It's like serialization of code objects, but the serialization is 
just the source string w/LFs that would re-make the object.

Similarly, you'd want:

>>> encode(codestr)

to instantiate all objects in the codestr.  You can't do this with eval, 
because it doesn't allow assignment (eval(n=2) returns "InvalidSyntax").

mark
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to