Ipython自动完成列表或对象的字典
发布时间:2021-01-17 13:36:59 所属栏目:Python 来源:互联网
导读:我想在I Python(Jupyter qtconsole或控制台)中自动完成以下情况: 我创建了一个类 class MyClass(object): def __init__(self, a, b): self.a = a self.b = b 并将此类的几个对象放入列表或词典中 my_list = []my_list.append(MyClass(2,
|
我想在I Python(Jupyter qtconsole或控制台)中自动完成以下情况: 我创建了一个类 class MyClass(object):
def __init__(self,a,b):
self.a = a
self.b = b
并将此类的几个对象放入列表或词典中 my_list = [] my_list.append(MyClass(2,3)) my_list.append(MyClass(9,2)) my_list.append(MyClass(8,4)) 现在,如果我这样做 my_list[0].TAB 自动完成功能无效. 我想看一下我的类属性和方法的列表.我错过了什么,或者这只是不支持IPython? 感谢您的帮助 … 解决方法您可以在Jupyter Notebook的单元格中执行该操作:%config IPCompleter.greedy=True 这给出了(在ipython / jupyter控制台中,但在笔记本中相同) In [10]: my_list[0].<TAB> my_list[0].a my_list[0].b 要永久保存它,只需编辑您的文件ipython_config.py,使其看起来像这样(注释行已经存在且未经修改,在第506-514行附近): #------------------------------------------------------------------------------ # Completer configuration #------------------------------------------------------------------------------ # Activate greedy completion # # This will enable completion on elements of lists,results of function calls,# etc.,but can be unsafe because the code is actually evaluated on TAB. c.Completer.greedy = True # <-- uncomment this line and set it to True 如果/ .ipython / profile_default /中没有ipython_config.py,您可以创建一个: ipython profile create (编辑:长春站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- python – 使用sсikit-learn TfIdf和gensim LDA
- Python ConfigParser检查Section和Key Value的存在
- Python Flask-WTF – 使用相同的表单模板进行添加和编辑操作
- 如何使用Python的ctypes和readinto读取包含数组的结构?
- python – 从文件中随机抽样
- Django:如何在内联formset中显示每个模型对象的表单错误
- 使用scipy.stats和statsmodels计算线性回归时的结果不同
- python-3.x – Keras(TensorFlow,CPU):训练循环中的顺序模
- Python中lambda的用法及其与def的区别解析
- 如何使用genfromtxt()从NumPy中的文本文件中读取不同长度的
