Iteration of strings

Duncan Booth duncan at NOSPAMrcp.co.uk
Mon Nov 25 08:37:30 EST 2002


On 25 Nov 2002, you wrote in comp.lang.python::

>> def dont_allow_string_argument(v):
>>     for t in types.StringTypes:
>>        assert not isinstance(v, t)
> 
> loop unneeded in recent Python versions (at least since 2.2.1 -- no
> older one around to check, sorry):
> 
>>>> import types
>>>> isinstance('ciao', types.StringTypes)
> 1
>>>> isinstance(23, types.StringTypes)
> 0
>>>>

Its that darn time machine again!

Even though I glanced at the docstring for isinstance before posting, it 
failed to register that Python, as usual, implements isinstance in the most 
helpful way possible.

Thanks

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?



More information about the Python-list mailing list