[Zope] type in python scripts

Paul Winkler pw_lists at slinkp.com
Tue May 4 16:17:23 EDT 2004


On Tue, May 04, 2004 at 12:46:08PM -0700, Sam Gendler wrote:
> How does one check the type of a variable in a python script?  I get a 
> global name error when I try to use the type method.

yep, it's one of the builtins that are forbidden in TTW code
for murky security reasons.
The "same_type" function is available for that purpose.

if same_type(foo, ''):
    # it's a string
elif same_type(foo, 1):
    # ... you get the idea


-- 

Paul Winkler
http://www.slinkp.com




More information about the Zope mailing list