#NEWLINE# def require( * mods ) : #NEWLINE# #INDENT# "Simple decorator for requiring names to be importable.\n    \n    Examples\n    --------\n    \n    In [1]: @require('numpy')\n       ...: def norm(a):\n       ...:     import numpy\n       ...:     return numpy.linalg.norm(a,2)\n    " #NEWLINE# names = [ ] #NEWLINE# for mod in mods : #NEWLINE# #INDENT# if isinstance ( mod , ModuleType ) : #NEWLINE# #INDENT# mod = mod . __name__ #NEWLINE# #UNINDENT# if isinstance ( mod , str ) : #NEWLINE# #INDENT# names . append ( mod ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( ( 'names must be modules or module names, not %s' % type ( mod ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return depend ( _require , * names )