[TxMt] Re: Adding python commands
Dougal
dougal at gmail.com
Thu Jan 1 04:23:58 UTC 2009
You can avoid ugly exec()s if you use __import__:
http://docs.python.org/library/functions.html#__import__
On Tue, Dec 30, 2008 at 10:55 AM, Rob McBroom <textmate at skurfer.com> wrote:
> On 2008-Dec-29, at 3:41 PM, Andrea Crotti wrote:
>
> > Thanks a lot Rob, I have another problem, the thing
> > #!/usr/bin/env python
> >
> > import dis
> > from os import environ
> > mod = environ['TM_FILENAME'].split('.')[0]
> > dis.dis(mod)
> >
> > Doesn't work because I also need to import mod, but if I put also
> > import mod, of course it doesn't work as it's not substituted the
> > variable
> > value in the import statement.
>
> This seemed to work with the limited testing I did:
>
> exec('import ' + mod)
>
> Just insert that before the call to dis.dis().
>
> --
> Rob McBroom
> <http://www.skurfer.com/>
>
> Because it screws up the order in which people normally read text.
>
> Original message:
>
> > Why is it bad to top-post your reply?
>
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20081231/17ec8044/attachment.html>
More information about the textmate
mailing list