3 ms·
For one, you can just paste in a bunch of code. Try doing that in the standard terminal! Another feature I end up using constantly is the documentation support
by brbsix 10y ago
For one, you can just paste in a bunch of code. Try doing that in the standard terminal!
Another feature I end up using constantly is the documentation support. Say you want to read the docstring for an object, just prefix or append a '?' to the object, e.g. 'subprocess?'.
If you want to examine the source code for the object, just prefix or append '??', e.g. 'subprocess.call??'.
- thomasahle 10y ago> For one, you can just paste in a bunch of code. Try doing that in the standard terminal! Usually I can paste code just fine, I think? As long as the indentation is correct and I have double blank lines between functions, etc. > Say you want to read the docstring for an object, just prefix or append a '?' to the object, e.g. 'subprocess?' Isn't that the same as typing `help(subprocess)` in the standard terminal? > If you want to examine the source code for the object, just prefix or append '??', e.g. 'subprocess.call??'. That's pretty cool :-)
- brbsix 10y agoJust try pasting the following into the default interpreter, exactly as-is: class Sample: def __init__(self): print('hehe') s = Sample() IPython wouldn't flinch.
- gknoy 10y agoNote that if you're doing this in a terminal, you MIGHT need to first do `%cpaste`: https://gist.github.com/gknoy/97de793db43ff7ea4d4bfd1bab96b408 https://gist.github.com/gknoy/97de793db43ff7ea4d4bfd1bab96b4... It seemed to work fine when I didn't use `%cpaste`, though, so that might be a vestigial thing? (I remember having to do it on my linux workstation, so maybe it's just my mac terminal behaving differently.) The cool thing about directly pasting is, if you fumble the indentation like I did when I initially pasted, it auto-indents for you. ;)
- takluyver 10y agoIn previous releases, you had to use %cpaste. With IPython 5, so long as your terminal supports 'bracketed paste', it should just work. We'll probably deprecate %cpaste eventually. We got this feature with no effort on our part - it's built into prompt_toolkit.