On Thu, Jul 11, 2002 at 05:22:48PM +0800, Tim Hoffman wrote:
> I must be stupid or something, but I can't for the life
> of me work out a simple way of determining if a variable contains 
> a string or array, in a PythonScript in Zope.
> I can't import type and or use type() function.
> isinstance doesn't work because I can't give a type as the second arg.
> I obviously just can't see the wood for the trees, can anyone help
> out this silly individual ?

Testing for string methods works :)

  if hasattr(item, 'startswith'):
      # A String
      # Something else

On a similar note you can test for a specific list method.

Martijn Pieters
| Software Engineer  mailto:[EMAIL PROTECTED]
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to