[Image-SIG] assigning commands to a variable

Chris Barker Chris.Barker at noaa.gov
Tue Aug 24 18:36:17 CEST 2004


Chris Cogdon wrote:
> On Aug 24, 2004, at 08:16, francesco wrote:
> 
>> Hi,
>> is it possible to assign a string to a variable and then make python 
>> understand that it is not just text but a command?

> try using getattr.
> 
> <myimage>.filter( getattr ( ImageFilter, a ) )

getattr is probably the best option here, but another one is eval:

a = eval("ImageFilter.BLUR")
<myimage>.filter(a)

(not tested, but something like that would work)

-Chris





-- 
Christopher Barker, Ph.D.
Oceanographer
                                     		
NOAA/OR&R/HAZMAT         (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov


More information about the Image-SIG mailing list