print fixes

This commit is contained in:
rasbt 2014-05-06 16:13:21 -04:00
parent 3db65c7686
commit 3ef96e3874
6 changed files with 40 additions and 2329 deletions

View File

@ -7,7 +7,7 @@ Useful functions, tutorials, and other Python-related things
###Links to view the IPython Notebooks ###Links to view the IPython Notebooks
- [Python benchmarks via `timeit`](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/timeit_tests.ipynb?create=1) - [Python benchmarks via `timeit`](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/timeit_tests.ipynb?create=1)
- [Implementing the least squares fit method for linear regression and speeding it up via Cythonook](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/cython_least_squares.ipynb?create=1) - [Implementing the least squares fit method for linear regression and speeding it up via Cython](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/cython_least_squares.ipynb?create=1)
- [Benchmarks of different palindrome functions](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/palindrome_timeit.ipynb?create=1) - [Benchmarks of different palindrome functions](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/benchmarks/palindrome_timeit.ipynb?create=1)
- [A collection of not so obvious Python stuff you should know!](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb?create=1) - [A collection of not so obvious Python stuff you should know!](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb?create=1)
- [Python's scope resolution for variable names and the LEGB rule](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/tutorials/scope_resolution_legb_rule.ipynb?create=1) - [Python's scope resolution for variable names and the LEGB rule](http://nbviewer.ipython.org/github/rasbt/python_reference/blob/master/tutorials/scope_resolution_legb_rule.ipynb?create=1)

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:6ea19109869c82ee989c8ea0599ec49401e74246a542ad0b7b05f6ef464bda19" "signature": "sha256:3d878b64b4503fd987496df562af53903ad85d4cce103ea0a2e6c456519c03c7"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -12,8 +12,20 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Sebastian Raschka 04/2014\n", "[Sebastian Raschka](http://sebastianraschka.com) \n",
"last updated: 05/03/2014\n",
"\n", "\n",
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/benchmarks/palindrome_timeit.ipynb) \n",
"- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n",
"\n",
"<br>\n",
"<br>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#Timing different Implementations of palindrome functions" "#Timing different Implementations of palindrome functions"
] ]
}, },
@ -178,14 +190,6 @@
} }
], ],
"prompt_number": 11 "prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
} }
], ],
"metadata": {} "metadata": {}

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:75d807f509bd9f76b2e14a5a048cb44852a3318bcd0d95afc95d1c9b2904c078" "signature": "sha256:132d5623e27eb721587599809f9870d397887ec873bbbdc95b25a05e710d160e"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,

View File

@ -1,7 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "", "name": "",
"signature": "sha256:0e1c6e74b301e23ea4146d660afb3f07765686c6c7fa4752f3a4495da7949787" "signature": "sha256:7a22f6c91e4aab51a325c721dd7674622d1acc5b4a3a038ff512c736d83bbe4a"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -12,11 +12,11 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Sebastian Raschka \n", "[Sebastian Raschka](http://sebastianraschka.com) \n",
"last updated: 05/03/2014 ([Changelog](#changelog))\n", "last updated: 05/03/2014 ([Changelog](#changelog))\n",
"\n", "\n",
"[Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb)\n", "- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb) \n",
"\n", "- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n",
"\n" "\n"
] ]
}, },
@ -307,14 +307,6 @@
], ],
"prompt_number": 6 "prompt_number": 6
}, },
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
@ -684,13 +676,13 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"** Logical `or`: ** \n", "**Logical `or`:** \n",
"\n", "\n",
"`a or b == a if a else b` \n", "`a or b == a if a else b` \n",
"- If both values in `or` expressions are `True`, Python will select the first value (e.g., select `\"a\"` in `\"a\" or \"b\"`), and the second one in `and` expressions. \n", "- If both values in `or` expressions are `True`, Python will select the first value (e.g., select `\"a\"` in `\"a\" or \"b\"`), and the second one in `and` expressions. \n",
"This is also called **short-circuiting** - we already know that the logical `or` must be `True` if the first value is `True` and therefore can omit the evaluation of the second value.\n", "This is also called **short-circuiting** - we already know that the logical `or` must be `True` if the first value is `True` and therefore can omit the evaluation of the second value.\n",
"\n", "\n",
"** Logical `and`: ** \n", "**Logical `and`:** \n",
"\n", "\n",
"`a and b == b if a else a` \n", "`a and b == b if a else a` \n",
"- If both values in `and` expressions are `True`, Python will select the second value, since for a logical `and`, both values must be true.\n" "- If both values in `and` expressions are `True`, Python will select the second value, since for a logical `and`, both values must be true.\n"
@ -3448,8 +3440,14 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"I would claim that the conditional \"else\" is every programmer's daily bread and butter. However, there is a second flavor of \"else\"-clauses in Python, which I will call \"completion else\" (for reason that will become clear later). \n", "I would claim that the conditional \"else\" is every programmer's daily bread and butter. However, there is a second flavor of \"else\"-clauses in Python, which I will call \"completion else\" (for reason that will become clear later). \n",
"But first, let us take a look at our \"traditional\" conditional else that we all are familiar with. \n", "But first, let us take a look at our \"traditional\" conditional else that we all are familiar with. \n"
"### Conditional else:" ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###Conditional else:"
] ]
}, },
{ {

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
{ {
"metadata": { "metadata": {
"name": "" "name": "",
"signature": "sha256:f6d59feb844af096c0581919fa052e8f29f4fa0aaa81752f5e50241ab084a0e9"
}, },
"nbformat": 3, "nbformat": 3,
"nbformat_minor": 0, "nbformat_minor": 0,
@ -11,7 +12,12 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Sebastian Raschka, 03/2014 \n", "[Sebastian Raschka](http://sebastianraschka.com) \n",
"last updated: 05/03/2014\n",
"\n",
"- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/benchmarks/python_true_false.ipynb) \n",
"- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n",
"\n",
"Code was executed in Python 3.4.0" "Code was executed in Python 3.4.0"
] ]
}, },
@ -392,8 +398,8 @@
"\n", "\n",
"Possibly the best explanation of shallow vs. deep copies I've read so far:\n", "Possibly the best explanation of shallow vs. deep copies I've read so far:\n",
"\n", "\n",
"*** \"Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.\n", "***\"Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.\n",
"Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.\"***\n", "Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.\"*** \n",
"\n", "\n",
"(via [S.Lott](http://stackoverflow.com/users/10661/s-lott) on [StackOverflow](http://stackoverflow.com/questions/184710/what-is-the-difference-between-a-deep-copy-and-a-shallow-copy))" "(via [S.Lott](http://stackoverflow.com/users/10661/s-lott) on [StackOverflow](http://stackoverflow.com/questions/184710/what-is-the-difference-between-a-deep-copy-and-a-shallow-copy))"
] ]