免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2014年12月12日 星期五

try ipython #1

[Q] what's ipython ?
* an enhanced interactive Python interpreter, offering tab completion, object introspection...
* an enhanced command shell for Python
* high performance tools for parallel computing ?
* supporting interactive computing in any language ?

http://ipython.org/


//=== my environment, Win7x64

0. download and install Anaconda (Python+ iPython + notebook +  ... )
    http://continuum.io/downloads

1. open Anaconda cmd prompt


//=== install ipython by Anaconda
> conda update conda
> conda update ipython


or
traditional way
> pip install ipython

or include the dependencies for the IPython notebook:
> pip install "ipython[notebook]"

or
manually download IPython from Github or PyPI. To install one of these versions, unpack it and run the following from the top-level source directory using the Terminal:
> python setup.py install

* ipython is a module for python from this perspective


//=== how to start ipython
anaconda cmd prompt
> ipython



//=== http://ipython.org/ipython-doc/stable/interactive/tutorial.html
line-oriented and cell-oriented magics.

""" ...
Line magics are prefixed with the % character and work much like OS command-line calls:
they get as an argument the rest of the line, where arguments are passed without parentheses or quotes.

Cell magics are prefixed with a double %%, and they are functions that get as an argument
not only the rest of the line, but also the lines below it in a separate argument.

%run
%edit
%history

%pastebin 3 18-20 ~1/1-5
This will take line 3 and lines 18 to 20 from the current session, and lines 1-5 from the previous session.
..."""

In [1]: !ping www.bbc.co.uk
In [2]: !ls
'ls' is not recognized as an internal or external command,

In [3]: !dir
In [4]: x=4
In [5]: !echo $x
In [6]: quit

D:\ipython>

//=== http://ipython.org/ipython-doc/stable/interactive/tutorial.html
> ipython profile create
to produce the default config files.
These will be placed in ~/.ipython/profile_default


//=== http://ipython.org/ipython-doc/stable/config/intro.html#profiles

> ipython profile create foo # create the profile foo
> ipython locate profile foo
> ipython --profile=foo # start IPython using the new profile


//==  http://www.computerhope.com/prompthl.htm

myipy.bat

""" ...
chdir D:\ipython
D:
rem prompt $P$G
ipython --profile=urprofile
..."""


//=== ipython tutorial
http://ipython.org/ipython-doc/stable/interactive/tutorial.html


[Q] what's ipython ?
[Q] what's ipython notebook ?
[Q] what's ipython Qt console?



//=== ipython notebook :
0. a web app
1. turn console-based ipython to web-based
2. code + contents


http://ipython.org/ipython-doc/stable/notebook/notebook.html#introduction

* to start an ipython notebook server from the command line
> ipython notebook --profile=urprofile



*** nbconvert and nbviewer
Notebooks may be exported to a range of static formats, including HTML, Markdown, LaTeX, PDF ... , via  'nbconvert'

In effect, nbviewer is simply nbconvert as a web service ?

> ipython nbconvert notebook.ipynb
> ipython nbconvert --to html notebook.ipynb
> ipython nbconvert --to markdown notebook.ipynb --stdout



//=== how to run code in the IPython Notebook
http://ipython.org/ipython-doc/stable/notebook/notebook.html#introduction

* Shift-Enter: run cell
Execute the current cell, show output (if any), and jump to the next cell below.

* Ctrl-Enter: run cell in-place
Execute the current cell as if it were in “terminal mode”, where any output is shown, but the cursor remains in the current cell.

* Alt-Enter: run cell, insert below
Executes the current cell, shows the output, and inserts a new cell between the current cell and the cell below

* Esc and Enter: Command mode and edit mode


[Q] where does ipython notebook store the new document?
--> under the folder where you start notebook.





沒有留言:

張貼留言