Fwd: Need to import stuff
abhijeet.thatte at gmail.com
Wed Aug 18 00:40:28 CEST 2010
Thanks for the reply. But I guess it does not support nested file paths.
If user gives 'abcd' then I need to import "*/Do/Stuff/abcd*". Out of which
only *"abcd" is taken run time. Do and Stuff are fixed. *
*I got an error "*ImportError: Import by filename is not supported.". Any
On Tue, Aug 17, 2010 at 3:27 PM, Jerry Hill <malaclypse2 at gmail.com> wrote:
> On Tue, Aug 17, 2010 at 6:21 PM, abhijeet thatte
> <abhijeet.thatte at gmail.com> wrote:
> > Hi,
> > I need to import few files depending on the user input. For eg if user
> > an input as "abcd" then I will have import "abcd.py".
> > Can not have any hard coding in the code. Does any one know how to solve
> > problem.
> Use the __import__ function (
> http://docs.python.org/library/functions.html#__import__ ), like this:
> user_module = __import__("abdc")
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list