How to tell the difference between string and list
Michael Hudson
mwh at python.net
Fri Dec 5 11:14:59 EST 2003
Gerhard Häring <gh at ghaering.de> writes:
> Skip Montanaro wrote:
> > Jan> I need to recognize 'var' and ['var'], usually I would use:
> > ...
> > Try
> > if isinstance(a, str):
> > pass
> > elif isinstance(a, list):
> > pass
>
> This requires Python 2.2 or later, but ZOPE still uses Python 2.1
> AFAIK, so you can try one of the Python 2.1 compatible solutions that
> I proposed.
The method the OP posted had zero chance of working in Pythons <
2.2...
Cheers,
mwh
--
... when all the programmes on all the channels actually were made
by actors with cleft pallettes speaking lines by dyslexic writers
filmed by blind cameramen instead of merely seeming like that, it
somehow made the whole thing more worthwhile. -- HHGTG, Episode 11
More information about the Python-list
mailing list