[Python-Dev] PEP_215_ (string interpolation) alternative EvalDict

Steven Majewski sdm7g@Virginia.EDU
Tue, 15 Jan 2002 01:27:19 -0500 (EST)


On Mon, 14 Jan 2002, Paul Prescod wrote:

> Sure, for the same semantics. But EvalDict doesn't have the same
> semantics. Even if we ignore double interpolation there is the issue of
> code like this:
>
>
> >>> def double():
> ...    user_val = raw_input("Please enter a number:")
> ...    print "%(2*user_val)" % EvalDict
>
> >>> double()
> Please enter a number: 3 + (os.system("rm -rm *"))
>

But in EvalDict you have to explicitly pass it a namespace dict.
You just don't pass it one with access to os.system ( or most
other os calls. ) That's why I disliked an implicit namespace.

But your example suggests to me:

>>> input('?: ')
?: r'raw string'
'raw string'

>>> input('?: ')
?: u'unicode string'
u'unicode string'

>>> input('?: ')
?: $'$os.system("rm -rm *" )'

I guess you need to special case that out of the compiler also.
( Are there any others lurking about ? )


-- Steve