You can avoid ugly exec()s if you use __import__: <a href="http://docs.python.org/library/functions.html#__import__">http://docs.python.org/library/functions.html#__import__</a> <br><br><div class="gmail_quote">On Tue, Dec 30, 2008 at 10:55 AM, Rob McBroom <span dir="ltr"><<a href="mailto:textmate@skurfer.com">textmate@skurfer.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="Ih2E3d">On 2008-Dec-29, at 3:41 PM, Andrea Crotti wrote:<br>
<br>
> Thanks a lot Rob, I have another problem, the thing<br>
> #!/usr/bin/env python<br>
><br>
> import dis<br>
> from os import environ<br>
> mod = environ['TM_FILENAME'].split('.')[0]<br>
> dis.dis(mod)<br>
><br>
> Doesn't work because I also need to import mod, but if I put also<br>
> import mod, of course it doesn't work as it's not substituted the<br>
> variable<br>
> value in the import statement.<br>
<br>
</div>This seemed to work with the limited testing I did:<br>
<br>
exec('import ' + mod)<br>
<br>
Just insert that before the call to dis.dis().<br>
<div><div></div><div class="Wj3C7c"><br>
--<br>
Rob McBroom<br>
<<a href="http://www.skurfer.com/" target="_blank">http://www.skurfer.com/</a>><br>
<br>
Because it screws up the order in which people normally read text.<br>
<br>
Original message:<br>
<br>
> Why is it bad to top-post your reply?<br>
<br>
<br>
_______________________________________________<br>
textmate mailing list<br>
<a href="mailto:textmate@lists.macromates.com">textmate@lists.macromates.com</a><br>
<a href="http://lists.macromates.com/listinfo/textmate" target="_blank">http://lists.macromates.com/listinfo/textmate</a><br>
</div></div></blockquote></div><br>