|
1 | 1 | { |
2 | 2 | "metadata": { |
3 | 3 | "name": "", |
4 | | - "signature": "sha256:0e1c6e74b301e23ea4146d660afb3f07765686c6c7fa4752f3a4495da7949787" |
| 4 | + "signature": "sha256:7a22f6c91e4aab51a325c721dd7674622d1acc5b4a3a038ff512c736d83bbe4a" |
5 | 5 | }, |
6 | 6 | "nbformat": 3, |
7 | 7 | "nbformat_minor": 0, |
|
12 | 12 | "cell_type": "markdown", |
13 | 13 | "metadata": {}, |
14 | 14 | "source": [ |
15 | | - "Sebastian Raschka \n", |
| 15 | + "[Sebastian Raschka](http://sebastianraschka.com) \n", |
16 | 16 | "last updated: 05/03/2014 ([Changelog](#changelog))\n", |
17 | 17 | "\n", |
18 | | - "[Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb)\n", |
19 | | - "\n", |
| 18 | + "- [Link to this IPython Notebook on GitHub](https://github.com/rasbt/python_reference/blob/master/not_so_obvious_python_stuff.ipynb) \n", |
| 19 | + "- [Link to the GitHub repository](https://github.com/rasbt/python_reference) \n", |
20 | 20 | "\n" |
21 | 21 | ] |
22 | 22 | }, |
|
307 | 307 | ], |
308 | 308 | "prompt_number": 6 |
309 | 309 | }, |
310 | | - { |
311 | | - "cell_type": "code", |
312 | | - "collapsed": false, |
313 | | - "input": [], |
314 | | - "language": "python", |
315 | | - "metadata": {}, |
316 | | - "outputs": [] |
317 | | - }, |
318 | 310 | { |
319 | 311 | "cell_type": "markdown", |
320 | 312 | "metadata": {}, |
|
684 | 676 | "cell_type": "markdown", |
685 | 677 | "metadata": {}, |
686 | 678 | "source": [ |
687 | | - "** Logical `or`: ** \n", |
| 679 | + "**Logical `or`:** \n", |
688 | 680 | "\n", |
689 | 681 | "`a or b == a if a else b` \n", |
690 | 682 | "- 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", |
691 | 683 | "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", |
692 | 684 | "\n", |
693 | | - "** Logical `and`: ** \n", |
| 685 | + "**Logical `and`:** \n", |
694 | 686 | "\n", |
695 | 687 | "`a and b == b if a else a` \n", |
696 | 688 | "- 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 | 3440 | "metadata": {}, |
3449 | 3441 | "source": [ |
3450 | 3442 | "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", |
3451 | | - "But first, let us take a look at our \"traditional\" conditional else that we all are familiar with. \n", |
3452 | | - "### Conditional else:" |
| 3443 | + "But first, let us take a look at our \"traditional\" conditional else that we all are familiar with. \n" |
| 3444 | + ] |
| 3445 | + }, |
| 3446 | + { |
| 3447 | + "cell_type": "markdown", |
| 3448 | + "metadata": {}, |
| 3449 | + "source": [ |
| 3450 | + "###Conditional else:" |
3453 | 3451 | ] |
3454 | 3452 | }, |
3455 | 3453 | { |
|
0 commit comments