Translating a Perl script into Python
Alex Martelli
aleaxit at yahoo.com
Sat Jan 20 18:30:11 EST 2001
"Carel Fellinger" <cfelling at iae.nl> wrote in message
news:94d4hk$1sq$1 at animus.fel.iae.nl...
[snip]
> and yet in some circumstances even the more elaborate variant
>
> PROC.write("%(key)s = %(value)s\n" % {key:key,
val:os.environ[key]})
>
> The latter form comes very close to the Perl way of coding, and
> is espescially suited for format strings spanning several lines.
I think this is error-prone, though -- the dictionary after the % would
have to be coded as {'key':key, 'value':os.environ[key]}.
Alex
More information about the Python-list
mailing list