Creating slice notation from string

Rhodri James rhodri at wildebst.demon.co.uk
Wed Sep 2 19:16:29 EDT 2009


On 2009年9月02日 23:57:48 +0100, Bob van der Poel <bob at mellowood.ca> 
wrote:
>>> Of course, you could also do something like this:
>>>>      eval('x' + s)
>> or
>>      eval(str(x) + s)
>>>> Yes, I have user inputed 's'. So, if I can't get the generalized list
> version from Robert working I'll have to use this. Speed is not a big
> deal in this. As to malicious input, I could pretty easily check to
> see that all the values are integers.

If you've done that check, you've parsed the input so you might as well
use the values you've derived rather than waste time and add risk by
using eval().
-- 
Rhodri James *-* Wildebeest Herder to the Masses


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /