Typenbestimmung von Elementen


>>> list1 = ['a', 'b']
>>> list2 = ['1', ['a', 'b'], '2']
>>> import types
>>> def visitEachListElementOf(alist):
 for el  in alist:
  if isinstance(el, types.ListType):
   visitEachListElementOf(el)
  else:
   print el      # do whatever is necessary with the list element
 
>>> visitEachElelementOf(list2)
1
a
b
2