Author martin.panter
Recipients josh.r, martin.panter, serhiy.storchaka
Date 2015-10-17.02:56:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1445050575.25.0.973912404161.issue25419@psf.upfronthosting.co.za>
In-reply-to
Content
Josh: Thanks for pointing out I Python. I haven’t used it much myself, but it does seem to do a similar thing to my proposal. Looks like the relevant code may be around module_completion() at <https://github.com/ipython/ipython/blob/ab929fe/IPython/core/completerlib.py#L209>.

The “sys” module is one of the builtin modules that I mentioned above. I plan to discuss changing pkgutil.iter_modules() to include it, in a separate bug report.

The “os.path” case is more awkward. The “os” module is not actually a package. I believe “import os.path” only works because executing the “os” module modifies sys.modules. My code currently avoids importing non-packages, because I thought it would be annoying to accidentally run a script via tab completion (anything not protected by ‘if __name__ == "__main__" ’). On the other hand, I Python happily completes “os.path” (and many more non-submodule names). It also can be tricked into running scripts, e.g. if you do “import idlelib.__main__.” and press Tab. But maybe this is not a real problem, and I should stop being paranoid.

I tend to avoid regular expressions if practical. But Serhiy you may be right that some simple string matching rules would reduce the need for tokenizing. It looks like I Python only has a few simple rules for the entire input line being “import x” and “from x import y”. The disadvantage is less accurate understanding of more complicated syntax, like “from x import y; from z import (a, bb as b, . . .”. It is a tradeoff between simpler code that only supports basic functionality versus complex code that supports more complete functionality.

I hear your points about decoupling from Readline and backwards compatibility. I will consider the overall architecture more in a future update. It would be good to allow this stuff to be used in e.g. Idle (though I wouldn’t know where to wire it in myself).
History
Date User Action Args
2015-10-17 02:56:15martin.pantersetrecipients: + martin.panter, serhiy.storchaka, josh.r
2015-10-17 02:56:15martin.pantersetmessageid: <1445050575.25.0.973912404161.issue25419@psf.upfronthosting.co.za>
2015-10-17 02:56:15martin.panterlinkissue25419 messages
2015-10-17 02:56:13martin.pantercreate