recentpopularlog in

kme : ipython   49

metakernel/metakernel/magics at master · Calysto/metakernel · GitHub
Jupyter/IPython Kernel Tools. Contribute to Calysto/metakernel development by creating an account on GitHub.
ipython  ipythonnb  ipythonnotebook  magics  reference 
may 2019 by kme
numpy - Automatically import modules when entering the python or ipython interpreter - Stack Overflow |
Use the environment variable PYTHONSTARTUP. From the official documentation:
If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same namespace where interactive commands are executed so that objects defined or imported in it can be used without qualification in the interactive session.

python  ipython  ptpython  startup  configfile  solution 
may 2018 by kme
shell - How to save a Python interactive session? - Stack Overflow
If you run ptpython as 'ptipython' you get the "%save" magic, too.
python  ipython  solution 
april 2017 by kme
spark/pyspark at master · apache/spark · GitHub

(works for ptpython, too)
pyspark  spark  ipython  ptpython  solution 
april 2017 by kme
Built-in magic commands — IPython 3.2.1 documentation
Solution: give '-n' option to '%timeit' to control the number of loops. IPython tries successive powers of ten until the result takes at least 0.2 seconds.

e.g., %timeit -n10 function(arg1, arg2)
ipython  python  repl  magic  solution 
january 2017 by kme
python - Disable IPython Exit Confirmation - Stack Overflow
If you also want Ctrl-D to exit without confirmation, in IPython 0.11, add
<code class="language-python">
c.TerminalInteractiveShell.confirm_exit = False
to your config file (~/.ipython/profile_default/

If you don't have a config file yet, run ipython profile create to create one.

It's worth noting that 'ipython locate profile <profilename>' will reveal where IPython will look for th...
ipython  annoyance  configfile  dotfile  solution  flask  fuckina 
january 2017 by kme
[Configuring IPython]
Add 'c.TerminalInteractiveShell.confirm_exit = False' to $profile/ (courtesy
python  ipython  configuration  dotfiles  solution 
january 2017 by kme
python - How to use timeit module - Stack Overflow
If you want to use timeit in an interactive Python session, there are two convenient options:

Use the IPython shell. It features the convenient %timeit special function:

In [1]: def f(x):
...: return x*x

In [2]: %timeit for x in range(100): f(x)
100000 loops, best of 3: 20.3 us per loop

In a standard Python interpreter, you can access functions and other names you defined earlier during the interactive session by importing them from __main__ in the setup statement:

>>> def f(x):
... return x * x
>>> import timeit
>>> timeit.repeat("for x in range(100): f(x)", "from __main__ import f",
[2.0640320777893066, 2.0876040458679199, 2.0520210266113281]
python  benchmarking  timing  timit  ipython  solution 
january 2017 by kme
GitHub - nteract/nteract: Interactive literate coding notebook!
The second command really *is* necessary:
At least for now, we need the python 3 kernel installed when hacking on nteract:

python3 -m pip install ipykernel
python3 -m ipykernel install --user
python  ipython  ipythonnotebook  jupyter  repl  mac  osx  gui 
december 2016 by kme
How to get the last exception object after an error is raised at a Python prompt? - Stack Overflow []
The sys module provides some functions for post-hoc examining of exceptions: sys.last_type, sys.last_value, and sys.last_traceback.

sys.last_value is the one you're looking for.
ipython  python  debugging  solution  fuckinga 
july 2016 by kme
IPython Tip Sheet
As noted above, setting %pdb on within ipython will make it such that the pdb debugger will automatically be started at the point of an exception, once it is encountered.
python  ipython  cheatsheat  debugging  debugger  pdb  tipsandtricks  reference 
july 2016 by kme
Where's python-argparse package in RHEL? - Stack Overflow
Installing python-ipython against Python 2.6.6 on CentOS 6 yielded the error message:
File "/usr/lib/python2.6/site-packages/IPython/external/argparse/", line 10, in <module>
from _argparse import *
ImportError: No module named _argparse

The solution appears to have been to install 'python-argparse' (not automatically pulled in as a dependency).
ipython  centos  python  errormessage  solution 
december 2014 by kme

Copy this bookmark:

to read