> What if was gibing a string like this: 'math.ceil', and i had to import the
> function(not the module) dynamically(from the string), how can i do that?
> import_module is for importing... modules, not functions.
Why don't you just read the code snippet I posted ?
For the record:
* modules are objects
* functions, classes and anything else defined in a module are
attributes of the module
* "getattr(obj, "attrib")" is the exact equivalent of "obj.attrib"
also and FWIW, you never import functions (or anything else) directly.
The
from module import name
syntax is syntactic sugar for:
import module
name = module.name
del module
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment