#NEWLINE# def iterit( * args , **kwargs ) : #NEWLINE# #INDENT# '\n    This takes some input (int, string, list, iterable, whatever) and\n    makes sure it is an iterable, making it a single item list if not.\n    Importantly, it does rational things with strings.\n\n    You can pass it more than one item. Cast is optional.\n\n    def foo(offsets=10):\n        offsets = iterit(offsets, cast=int)\n        for f in offsets:\n            print "Value %s" % (10 + f)\n\n    >>> foo()\n    Value 20\n    >>> foo(3)\n    Value 13\n    >>> foo([1,2])\n    Value 11\n    Value 12\n    >>> foo(\'3\')\n    Value 13\n    >>> foo((\'3\', 4))\n    Value 13\n    Value 14\n\n    Also useful this way:\n    foo, bar = iterit(foo, bar)\n    ' #NEWLINE# if ( len ( args ) > 1 ) : #NEWLINE# #INDENT# return [ iterit ( arg , ** kwargs ) for arg in args ] #NEWLINE# #UNINDENT# return map ( kwargs . get ( 'cast' , None ) , ( args [ 0 ] if hasattr ( args [ 0 ] , '__iter__' ) else [ args [ 0 ] ] ) )