python_reference/ipython_magic/datemagic.ipynb

356 lines
6.6 KiB
Plaintext
Raw Normal View History

2014-06-28 05:33:53 +00:00
{
"metadata": {
"name": "",
2014-06-28 07:05:21 +00:00
"signature": "sha256:b0db931ae8afaadadc3173ffe809324b1b9396a4360f574e697b83ce32103015"
2014-06-28 05:33:53 +00:00
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"IPython magic function documentation - `%date`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Installation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can install the magic function directly from my GitHub repository via:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 07:05:21 +00:00
"#%install_ext https://raw.githubusercontent.com/rasbt/python_reference/master/ipython_magic/datemagic.py"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Installed datemagic.py. To use it, type:\n",
" %load_ext datemagic\n"
]
}
],
"prompt_number": 1
},
2014-06-28 06:41:42 +00:00
{
"cell_type": "code",
"collapsed": false,
"input": [
"%install_ext ./datemagic.py"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Installed datemagic.py. To use it, type:\n",
" %load_ext datemagic\n"
]
}
],
"prompt_number": 1
},
2014-06-28 05:33:53 +00:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Loading the `%date` magic"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To load the `date` magic, execute the following line in your IPython notebook or current IPython shell"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%load_ext datemagic"
],
"language": "python",
"metadata": {},
2014-06-28 07:05:21 +00:00
"outputs": [],
2014-06-28 05:33:53 +00:00
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Usage"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In order to display the available `magic` arguments, type:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 07:05:21 +00:00
"%watermark?"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [],
2014-06-28 05:35:21 +00:00
"prompt_number": 3
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<pre>%date [-d] [-t] [-s] [-p] [-i]\n",
"\n",
" \n",
"IPython magic function for printing the current date, time, Python,\n",
"and IPython version.\n",
"\n",
"optional arguments:\n",
" -d, --date prints date (default)\n",
" -t, --time print current time\n",
" -s, --datetime print current time\n",
" -p, --python prints Python version\n",
" -i, --ipython prints IPython version\n",
"</pre>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>\n",
"<br>"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Examples"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2014-06-28 07:05:21 +00:00
"%watermark"
2014-06-28 05:33:53 +00:00
],
"language": "python",
"metadata": {},
"outputs": [
{
2014-06-28 07:05:21 +00:00
"output_type": "stream",
"stream": "stdout",
"text": [
"28/06/2014 02:56:36\n",
"Python 3.4.1\n",
"IPython 2.1.0\n",
"\n",
"compile : GCC 4.2.1 (Apple Inc. build 5577)\n",
"system : Darwin\n",
"release : 13.2.0\n",
"machine : x86_64\n",
"processor : i386\n",
"CPU count : 2\n",
"interpreter: 64bit\n"
2014-06-28 05:33:53 +00:00
]
}
],
2014-06-28 07:05:21 +00:00
"prompt_number": 3
2014-06-28 05:33:53 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%date -t"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"01:18:28\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%date -dt"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"28/06/2014 01:18:33\n"
]
}
],
"prompt_number": 7
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%date -p"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Python 3.3.5\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%date -i"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"IPython 2.1.0\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<br>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"%date -d -i -z -p"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stderr",
"text": [
"UsageError: unrecognized arguments: -z"
]
}
],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}