Home Download Buy Blog Forum Support

Jon: Could not import exec.py and others plugin questions

Jon: Could not import exec.py and others plugin questions

Postby bizoo on Fri Jun 24, 2011 6:48 am

I want to create a new command inherited from ExecCommand, but I hit the problem that:
Code: Select all
import exec

is not a valid Python statement, exec is a reserved keyword.
So I change to this:
Code: Select all
execcmd = imp.load_source("execcmd", r"C:\Users\bizoo\AppData\Roaming\Sublime Text 2\Packages\Default\exec.py")


Could you please rename the exec.py in the next build ?

And is there any drawback to create a command inheriting another command ?
I didn't find any sample in the default ST2 installation.

And in the same subject:
Could I use an __init__ method in a command like:
Code: Select all
class WebColorsCommand(sublime_plugin.WindowCommand):
  def __init__(self, *args, **kwargs):
     super(WebColorsCommand, self).__init__(*args, **kwargs)
bizoo
 
Posts: 886
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Jon: Could not import exec.py and others plugin questions

Postby jps on Fri Jun 24, 2011 6:57 am

You can also import exec via:

Code: Select all
__import__("exec")


I've never had a reason in inherit one command from another, but off the top of my head it should be fine.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: Jon: Could not import exec.py and others plugin questions

Postby bizoo on Fri Jun 24, 2011 7:59 am

jps wrote:You can also import exec via:

Code: Select all
execcmd = __import__("exec")


Didn't know, and way simpler than my solution.

jps wrote:I've never had a reason in inherit one command from another, but off the top of my head it should be fine.

I want to make my own build command (ExecCommand) that differ only slightly from the default one, so inheriting it seems a good idea.
I will try it and post here the problems I encounter if there are any.

Thanks for your answer.
bizoo
 
Posts: 886
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to General Discussion

Who is online

Users browsing this forum: Google [Bot] and 14 guests