Sublime Forum

Why is "sys.argv" not available?

#1

Dear forum!

I wrote the following little Plugin to illustrate, that sys.argv is not working on my Ubuntu 12.04, Subulime-Text2 v.2.0.1:

[code]import sublime, sublime_plugin
import sys

class TestCommand(sublime_plugin.TextCommand):
def run(self, edit):
print dir(sys)
print sys.argv[/code]

You can test the plugin by copying it into sublime_packages_dir/User and then pressing ctrl+` to open the python console and typing:

view.run_command('test')

I get the following output:

[code]>>> view.run_command(‘test’)
displayhook’, ‘doc’, ‘excepthook’, ‘name’, ‘package’, ‘stderr’, ‘stdin’, ‘stdout’, ‘_clear_type_cache’, ‘_current_frames’, ‘_getframe’, ‘api_version’, ‘builtin_module_names’, ‘byteorder’, ‘call_tracing’, ‘callstats’, ‘copyright’, ‘displayhook’, ‘dont_write_bytecode’, ‘exc_clear’, ‘exc_info’, ‘exc_type’, ‘excepthook’, ‘exec_prefix’, ‘executable’, ‘exit’, ‘exitfunc’, ‘flags’, ‘float_info’, ‘getcheckinterval’, ‘getdefaultencoding’, ‘getdlopenflags’, ‘getfilesystemencoding’, ‘getprofile’, ‘getrecursionlimit’, ‘getrefcount’, ‘getsizeof’, ‘gettrace’, ‘hexversion’, ‘last_traceback’, ‘last_type’, ‘last_value’, ‘maxint’, ‘maxsize’, ‘maxunicode’, ‘meta_path’, ‘modules’, ‘path’, ‘path_hooks’, ‘path_importer_cache’, ‘platform’, ‘prefix’, ‘py3kwarning’, ‘setcheckinterval’, ‘setdlopenflags’, ‘setprofile’, ‘setrecursionlimit’, ‘settrace’, ‘stderr’, ‘stdin’, ‘stdout’, ‘subversion’, ‘version’, ‘version_info’, ‘warnoptions’]

Traceback (most recent call last):
File “./sublime_plugin.py”, line 362, in run_
File “./myTestPlugin.py”, line 8, in run
AttributeError: ‘module’ object has no attribute ‘argv’[/code]

Is there any reason why this is not available?
Thanks a lot for any help!

0 Likes