tab complete dictionary keys in ipython

只愿长相守 提交于 2020-01-12 14:18:08

问题


I was wondering if anybody knows how to enable or implement tab completion for dictionary keys in IPython? It seems like it wouldn't be very different from functionality that already exists, like tab completion of object attributes. If I'm wrong, then I'd like to understand why


回答1:


IPython supports dict key completion for string keys since version 3.0.0 (despite not appearing in release notes), thanks to this patch. It also supports column name completion for numpy struct arrays and pandas DataFrame columns, and for other types that redefine __getitem__ through defining _ipython_key_completions_.




回答2:


It's not built into IPython 2.x. If you want to add it, have a look at this, where someone hacked a solution:

https://github.com/ipython/ipython/issues/1533

Also, there are many short and easy ways to create objects from dictionaries, to gain the usual tab completion. If that would help you, use one of the ways described in this question:

Convert Python dict to object?



来源:https://stackoverflow.com/questions/17974777/tab-complete-dictionary-keys-in-ipython

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!