<div class="gmail_quote">Hi,</div><div class="gmail_quote"><br></div><div class="gmail_quote">Thanks for the reply. But I guess it does not support nested file paths. <div>If user gives 'abcd' then I need to import "<i>/<b>Do/Stuff/abcd</b></i>". Out of which only <i>"abcd" is taken run time. Do and Stuff are fixed. </i></div>

<div><i>I got an error "</i>ImportError: Import by filename is not supported.". Any solution??</div><div><div></div><div class="h5"><div><div><br></div><div class="gmail_quote">On Tue, Aug 17, 2010 at 3:27 PM, Jerry Hill <span dir="ltr"><<a href="mailto:malaclypse2@gmail.com" target="_blank">malaclypse2@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>On Tue, Aug 17, 2010 at 6:21 PM, abhijeet thatte<br>
<<a href="mailto:abhijeet.thatte@gmail.com" target="_blank">abhijeet.thatte@gmail.com</a>> wrote:<br>
> Hi,<br>
> I need to import few files depending on the user input. For eg if user gives<br>
> an input as "abcd" then I will have  import "abcd.py".<br>
> Can not have any hard coding in the code. Does any one know how to solve the<br>
> problem.<br>
<br>
</div></div>Use the __import__ function (<br>
<a href="http://docs.python.org/library/functions.html#__import__" target="_blank">http://docs.python.org/library/functions.html#__import__</a> ), like this:<br>
<br>
user_module = __import__("abdc")<br>
user_module.do_stuff()<br>
<br>
--<br>
<font color="#888888">Jerry<br>
</font></blockquote></div><br></div>
</div></div></div><br>