IsList?

Gerhard Häring gerhard at bigfoot.de
Mon Apr 8 03:43:34 EDT 2002


* Magnus Lie Hetland <mlh at vier.idi.ntnu.no> [2002-04-08 06:50 +0000]:
> In article <slrnab2b3b.1gd.gerhard at lilith.my-fqdn.de>, Gerhard
> =?iso-8859-15?Q?H=E4ring?= wrote:
> >John wrote in comp.lang.python:
> >> Hi, How can one know wheter var 'a' is list or not? Is there any
> >> IsList-like function?
> [snip lots of stuff]
> 
> If you want to check for sequences in general you can use the
> isSequenceType function:
> 
> >>> from operator import isSequenceType
> >>> isSequenceType([1, 2, 3])
> 1
> >>> isSequenceType((1, 2, 3))
> 1
> >>> isSequenceType("1, 2, 3")
> 1
> >>> isSequenceType(123)
> 0

I know about these, but I've read Guido wants them depreciated:

http://groups.google.com/groups?selm=199808242112.RAA20599%40eric.CNRI.Reston.Va.US

I don't know if he has changed his mind in the meantime, in that
isSequenceType could be implemented reliably.

IMO it gets even hairier with isMappingType.

Gerhard
-- 
mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))





More information about the Python-list mailing list