code blocks

Dr. John Q. Hacker zondervanz at gmail.com
Sat May 2 14:30:21 EDT 2015


Hello,

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.

Since Python has already a plethora of ambiguous string designations, one
of them could be set aside specificially for code blocks:

"""for i in n: print i"""

For any variables, like "n", it would access the scope in which it was
running.  When you tried to print a triple-double-quoted code block,
perhaps it could invoke the code.

My suggestion would be to use triple double-quoted strings.

You probably already know that Ruby has code blocks.

zipher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150502/26f079e0/attachment.html>


More information about the Python-list mailing list