Easy "here documents" ??

Jim Hill jimhill at swcp.com
Mon Dec 20 00:52:40 EST 2004


Fredrik Lundh wrote:
>Scott David Daniels wrote:
>
>> And if you enjoy building insecure stuff, try:
>>
>>     def fix(text, globals_=None, locals=None, quote='"'):
>>         d = (globals_ or locals or globals()).copy()
>>         source = text.split(quote)
>>         source[1::2] = (str(eval(expr, d, locals or d))
>> for expr in source[1::2])
>>         return ''.join(source)
>>
>And if you prefer not to type so much:
>
>def I(*args): return "".join(map(str, args))
>def F(v, fmt): return ("%" + fmt) % v

Not that I don't appreciate the suggestions from masters of the Python
universe, but the reason I'm switching to Python from Perl is for the
readability.  What you fells are suggesting might as well be riddled
with dollar signs and semicolons...  <emoticon>.


Jim
-- 
"I regard NASCAR the same way I regard gay porn: I know it exists and I
know some guys like it; I just don't want to see it."  --  Z. B. Goode



More information about the Python-list mailing list