<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div></div><div><br></div><div>Attached is an updated patch file which uses os.sep as suggested, and uses the new examples/customization directory to store the example import command (plus a README). If you feel any more changes are required before this is ready for commit, let me know.</div></div></div><br><div><div></div><blockquote type="cite"><div>On Oct 12, 2011, at 8:11 PM, Jim Ingham wrote:</div><br class="Apple-interchange-newline"></blockquote><blockquote type="cite"><div>This is a nice convenience, I was a little worried at first because I want to try to avoid introducing top-level name commands when not necessary... I want to keep that namespace as clean as possible so people can use it for shortcuts. <br><br>On thinking a bit, it seems more logical to me if the same functionality was done through "command script import"; that could do whatever the current script language does to import a module into the scripting language.<br><br>It is also pretty consistent with having "command script add/delete/etc..."<br><br>If you follow this through further, if we have control of it we could also make some convention like if you do:<br><br>def __lldb_init_for_interpreter (lldb_interpreter):<br><br></div></blockquote><blockquote type="cite"><div>we would call this and pass in the LLDB interpreter that was doing the import. Then you could put your package's "command script add" commands in there. That way you could make up modules that you import and they would add all their commands to the LLDB interpreter they were being imported into...<br><br></div></blockquote><div><br></div><div>My personal preference would be to pass the SBDebugger instead. From the SBDebugger one can go to the associated SBCommandInterpreter, but doing the reverse is not possible as far as I can tell. Is there anything sensible that one could do with the Debugger in this scenario other than just grab the SBCommandInterpreter and run a few "command script add" commands? While I cannot think about any obvious example, having access to the list of targets seems valuable..</div><br><blockquote type="cite"><div>We could also add commands to set the PYTHONPATH, etc, like:<br><br>command script import --path-component ~/.lldb_python my_script...<br></div></blockquote><div><br></div><div>Would this command read like "import a file named my_script.py from a folder name ~/.lldb_python?" I was thinking about something like</div><div>command script import ~/myfile.py which would automatically check whether ~ is in sys.path and if not append it, and then import myfile</div><div>Most probably, it makes sense to delegate this to the ScriptInterpreterPython for actual implementation, and if LLDB script language is set to anything different, just reject the command "sorry, do not know how to import for your current script language" (much like we do for command script add currently)</div><br><blockquote type="cite"><div><br>This is more work, so I have no problem with adding the example for now. But if we do more work on it, I argue more for it's going into "command script import..."<br><br></div></blockquote><div><br></div><div>I would go for adding the example script for the time being. I can definitely work on "command script import", but it is going to take a few days, so I guess having the Pythonic example there won't hurt. Once I get to implementing the new command, I will also rework the test case to test that one instead of the script.</div><div>I will keep you up to date on progress there. As usual, if you have any feedback or suggestions, let me know.</div><br><blockquote type="cite"><div>Jim<br></div></blockquote></div><div><br></div><div><div apple-content-edited="true"><div>- <i>Enrico</i></div></div></div></body></html>