Hi folks,
in order to prevent cyclic import problems i've written this class:
====
class lazy_import:
def __init__(self, module, method = None ):
if method:
self.module = module
self.method = method
else:
tokens = module.split('.')
assert len(tokens) > 1
self.module = '.'.join( tokens[:-1] )
self.method = tokens[-1]
def __call__(self,*a,**kw):
return __import__( self.module, fromlist = self.method
).__getattribute__( self.method ).__call__( *a, **kw)
====
you can use it, for example, by:
some_func = lazy_import ('module.func')
some_func( bla )
my question is: i know django already does this somehow (in settings and
urlconf), but i couldn't find were it defines this. somebody help
?
thanks
itay
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.