├── .gitignore
├── .ipynb_checkpoints
├── 01-BasicPythonSyntax-checkpoint.ipynb
├── 02-Builtins-checkpoint.ipynb
├── 03-FileIO-checkpoint.ipynb
└── 04-UsingModules-checkpoint.ipynb
├── 01-BasicPythonSyntax.html
├── 01-BasicPythonSyntax.ipynb
├── 01-BasicPythonSyntax.pdf
├── 01-BasicPythonSyntax
├── hello.py
├── reverse_list.py
├── sum_even_values.py
├── sum_values.py
└── telephone_directory.py
├── 01-BasicPythonSyntax_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 02-Builtins.html
├── 02-Builtins.ipynb
├── 02-Builtins.pdf
├── 02-Builtins
├── ascii2str.py
└── make_dict.py
├── 02-Builtins_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 03-FileIO.html
├── 03-FileIO.ipynb
├── 03-FileIO.pdf
├── 03-FileIO
└── print_file.py
├── 03-FileIO_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 04-UsingModules.html
├── 04-UsingModules.ipynb
├── 04-UsingModules.pdf
├── 04-UsingModules
├── change_path.py
├── convert_dt_to_ts.py
├── datetime_every_second.py
├── e_to_the_jpi.py
├── print_file.py
├── print_file_debug.py
├── print_my_argv.py
├── print_my_path.py
└── time_every_second.py
├── 04-UsingModules_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 05-Strings.html
├── 05-Strings.ipynb
├── 05-Strings.pdf
├── 05-Strings
├── get_word_count.py
├── get_words.py
└── print_centered_words.py
├── 05-Strings_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 06-Regex.html
├── 06-Regex.ipynb
├── 06-Regex.pdf
├── 06-Regex
└── regex_tests.py
├── 06-Regex_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 06a-Packages
├── mypackage
│ ├── __init__.py
│ └── mysubpackage
│ │ ├── __init__.py
│ │ └── mymodule.py
├── test1.py
├── test2.py
└── test3.py
├── 07-Functions.html
├── 07-Functions.ipynb
├── 07-Functions.pdf
├── 07-Functions
└── log_function.py
├── 07-Functions_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 08-AdvancedFunctions.html
├── 08-AdvancedFunctions.ipynb
├── 08-AdvancedFunctions.pdf
├── 08-AdvancedFunctions
├── myfilter.py
└── postorder.py
├── 08-AdvancedFunctions_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 09-Logging.html
├── 09-Logging.ipynb
├── 09-Logging.pdf
├── 09-Logging
├── fileconfig.ini
├── log_example.py
└── log_file_config.py
├── 09-Logging_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 10-OOP1.html
├── 10-OOP1.ipynb
├── 10-OOP1.pdf
├── 10-OOP1
└── directory.py
├── 10-OOP1_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 11-OOP2.html
├── 11-OOP2.ipynb
├── 11-OOP2.pdf
├── 11-OOP2
├── directory-1.py
└── directory-2.py
├── 11-OOP2_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 12-Decorators.html
├── 12-Decorators.ipynb
├── 12-Decorators.pdf
├── 12-Decorators
├── log_function_calls.py
├── read-only-property.py
└── with_file.py
├── 12-Decorators_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 13-Generators
└── tree-print.py
├── 13-GeneratorsAndIterators.html
├── 13-GeneratorsAndIterators.ipynb
├── 13-GeneratorsAndIterators.pdf
├── 13-GeneratorsAndIterators_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 14-ContextManagers.html
├── 14-ContextManagers.ipynb
├── 14-ContextManagers.pdf
├── 14-ContextManagers
├── logger.py
├── logger2.py
├── xml-gen.py
└── xml-gen2.py
├── 14-ContextManagers_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 15-Threading
├── atomic_log.py
├── condition.py
├── event.py
├── lock1.py
├── lock2.py
├── print_time.py
├── queue.py
├── sem1.py
├── threading1.py
├── threading2.py
├── threading3.py
├── threadlocal.py
├── timer.py
└── timer2.py
├── 16-Multiprocessing
├── atomic_log.py
├── lock1.py
├── print_time.py
├── processing1.py
├── processing2.py
├── queue.py
└── shared_memory.py
├── 17-Subprocess.html
├── 17-Subprocess.ipynb
├── 17-Subprocess.pdf
├── 17-Subprocess
├── run_command.py
└── run_pipeline.py
├── 17-Subprocess_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── 18-Virtualenv
├── MyDistutilsProject
│ ├── MANIFEST
│ ├── mydistutilsproject
│ │ └── __init__.py
│ ├── setup.py
│ └── test-script
├── MySetuptoolsProject
│ ├── mysetuptoolsproject
│ │ └── __init__.py
│ ├── setup.cfg
│ └── setup.py
└── virtualenv.py
├── 19-Testing
├── directory.py
├── simple_math.py
├── test1.py
├── test2.py
├── test3.py
├── test4.py
├── test5.py
├── test6.py
├── test7.py
├── test8.py
├── test9.py
├── test_directory.py
└── testa.py
├── 20-MoreModules.html
├── 20-MoreModules.ipynb
├── 20-MoreModules.pdf
├── 20-MoreModules_files
├── MathJax.js
├── base.css
├── boilerplate.css
├── codemirror.css
├── default.css
├── ipython.css
├── jquery-wijmo.css
├── layout.css
├── markdown.css
├── notebook.css
├── prettify.css
├── renderedhtml.css
└── rst.css
├── ClassNotes.pdf
├── CodeExamples.pdf
├── FastTrackToPython 20140522.key
├── Data
│ ├── 200340373-1-small-103.jpg
│ ├── Synapp logo - Color-169.png
│ ├── Synapp logo - Color-small-170.png
│ ├── mt0@2x-146.jpg
│ ├── mt10@2x-156.jpg
│ ├── mt11@2x-157.jpg
│ ├── mt12@2x-158.jpg
│ ├── mt13@2x-159.jpg
│ ├── mt1@2x-147.jpg
│ ├── mt2@2x-148.jpg
│ ├── mt3@2x-149.jpg
│ ├── mt4@2x-150.jpg
│ ├── mt5@2x-151.jpg
│ ├── mt6@2x-152.jpg
│ ├── mt7@2x-153.jpg
│ ├── mt8@2x-154.jpg
│ ├── mt9@2x-155.jpg
│ ├── pasted-image-177.jpg
│ ├── pasted-image-192.jpg
│ ├── pasted-image-small-193.jpg
│ ├── st0-104.jpg
│ ├── st1-195.jpg
│ ├── st13-117.jpg
│ ├── st14-118.jpg
│ ├── st15-119.jpg
│ ├── st16-120.jpg
│ ├── st18-122.jpg
│ ├── st19-123.jpg
│ ├── st2-106.jpg
│ ├── st2-107.jpg
│ ├── st2-116.jpg
│ ├── st2-397.jpg
│ ├── st20-124.jpg
│ ├── st20-398.jpg
│ ├── st21-125.jpg
│ ├── st22-126.jpg
│ ├── st23-127.jpg
│ ├── st24-128.jpg
│ ├── st25-129.jpg
│ ├── st26-130.jpg
│ ├── st27-131.jpg
│ ├── st28-132.jpg
│ ├── st29-133.jpg
│ ├── st3-280.jpg
│ ├── st30-134.jpg
│ ├── st31-135.jpg
│ ├── st32-136.jpg
│ ├── st33-137.jpg
│ ├── st34-138.jpg
│ ├── st35-139.jpg
│ ├── st36-140.jpg
│ ├── st37-141.jpg
│ ├── st38-142.jpg
│ ├── st39-143.jpg
│ ├── st4-109.jpg
│ ├── st40-144.jpg
│ ├── st41-145.jpg
│ ├── st5-112.jpg
│ ├── st5-113.jpg
│ ├── st5-115.jpg
│ ├── st6-110.jpg
│ ├── st6-111.jpg
│ ├── st6-114.jpg
│ ├── st6-396.jpg
│ └── st7-360.jpg
├── Index.zip
├── Metadata
│ ├── BuildVersionHistory.plist
│ ├── DocumentIdentifier
│ └── Properties.plist
├── preview-micro.jpg
├── preview-web.jpg
└── preview.jpg
├── FastTrackToPython.pdf
├── README.md
├── Vagrantfile
├── code.md
├── fabfile.py
├── friendly.css
├── index.html
├── index.md
├── index_files
└── bootstrap.css
├── mypdf.pdf
├── native.css
├── output.pdf
├── pdfmarks.ps
├── setup-environ.bash
└── test.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/01-BasicPythonSyntax.pdf
--------------------------------------------------------------------------------
/01-BasicPythonSyntax/hello.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | def sayhello(name):
3 | print 'Hello, ' + name
4 |
5 | def sayhello2(name):
6 | print 'Hello,', name # using ',' inserts a space
7 |
8 | def sayhello3(name):
9 | print 'Hello,', # no \n at end
10 | print name
11 |
12 | sayhello('FastTrack')
13 | sayhello2('FastTrack')
14 | sayhello3('FastTrack')
15 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax/reverse_list.py:
--------------------------------------------------------------------------------
1 | def reverse_list(lst):
2 | return lst[::-1]
3 |
4 | def reverse_list2(lst):
5 | lst.reverse()
6 | return lst
7 |
8 | def reverse_list3(lst):
9 | lst = list(reversed(lst))
10 | return lst
11 |
12 | print reverse_list([1,2,3])
13 | print reverse_list2([1,2,3])
14 | print reverse_list3([1,2,3])
15 |
16 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax/sum_even_values.py:
--------------------------------------------------------------------------------
1 | def sum_even_values(lst):
2 | result = 0
3 | lst1 = lst[::2]
4 | for element in lst1:
5 | result += element
6 | return result
7 |
8 | print sum_even_values([1,2,3])
9 | print sum_even_values([100, 200])
10 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax/sum_values.py:
--------------------------------------------------------------------------------
1 | def sum_values(lst):
2 | result = 0
3 | for element in lst:
4 | result += element
5 | return result
6 |
7 | print sum_values([1,2,3])
8 | print sum_values([100, 200])
9 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax/telephone_directory.py:
--------------------------------------------------------------------------------
1 | def add_number(directory, name, number):
2 | directory[name] = number
3 |
4 | def remove_number(directory, name):
5 | del directory[name]
6 |
7 | def lookup_number(directory, name):
8 | return directory[name]
9 |
10 | directory = {}
11 | add_number(directory, 'Rick', '404.452.5202')
12 | print lookup_number(directory, 'Rick')
13 | print directory
14 | remove_number(directory, 'Rick')
15 | print directory
16 | print '-----------'*5
17 |
18 | def remove_number_alt(directory, name):
19 | try:
20 | del directory[name]
21 | except KeyError:
22 | pass # ignore KeyError
23 |
24 | def lookup_number_alt(directory, name):
25 | try:
26 | return directory[name]
27 | except KeyError:
28 | return 'Undefined number'
29 |
30 | print "Nobody's number:", lookup_number_alt(directory, 'Nobody')
31 | remove_number_alt(directory, 'Nobody')
32 | print directory
33 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/01-BasicPythonSyntax_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/02-Builtins.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/02-Builtins.pdf
--------------------------------------------------------------------------------
/02-Builtins/ascii2str.py:
--------------------------------------------------------------------------------
1 | def ascii2str(lst):
2 | s = ''
3 | characters = map(chr, lst)
4 | for ch in characters:
5 | s += ch
6 | return s
7 |
8 | print ascii2str([80, 121, 116, 104, 111, 110, 32, 82, 117, 108, 101, 122])
9 |
10 | def ascii2str_alt(lst):
11 | characters = map(chr, lst)
12 | return ''.join(characters)
13 |
14 | print ascii2str_alt([82, 117, 98, 121, 32, 68, 114, 111, 111, 108, 122])
15 |
--------------------------------------------------------------------------------
/02-Builtins/make_dict.py:
--------------------------------------------------------------------------------
1 | def make_dict(keys, values):
2 | return dict(zip(keys, values))
3 |
4 | print make_dict(['Rick Copeland'], ['404.452.5202'])
5 |
--------------------------------------------------------------------------------
/02-Builtins_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/02-Builtins_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/02-Builtins_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/02-Builtins_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/02-Builtins_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/02-Builtins_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/02-Builtins_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/03-FileIO.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/03-FileIO.pdf
--------------------------------------------------------------------------------
/03-FileIO/print_file.py:
--------------------------------------------------------------------------------
1 | def print_file(fp):
2 | for line in fp:
3 | print line,
4 |
5 | fp = open('/etc/hosts')
6 | print_file(fp)
7 | fp.close()
8 |
9 | def print_file_line_numbers(fp):
10 | for index, line in enumerate(fp):
11 | print index + 1, line,
12 |
13 | fp = open('/etc/hosts')
14 | print_file_line_numbers(fp)
15 | fp.close()
16 |
17 |
--------------------------------------------------------------------------------
/03-FileIO_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/03-FileIO_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/03-FileIO_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/03-FileIO_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/03-FileIO_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/03-FileIO_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/03-FileIO_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/04-UsingModules.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/04-UsingModules.pdf
--------------------------------------------------------------------------------
/04-UsingModules/change_path.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | sys.path = []
4 |
5 | import Queue
6 |
--------------------------------------------------------------------------------
/04-UsingModules/convert_dt_to_ts.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | def dt_to_ts(dt):
4 | return time.mktime(dt.timetuple())
5 |
--------------------------------------------------------------------------------
/04-UsingModules/datetime_every_second.py:
--------------------------------------------------------------------------------
1 | import datetime
2 | import time
3 |
4 | while True:
5 | print datetime.datetime.now()
6 | time.sleep(1)
7 |
--------------------------------------------------------------------------------
/04-UsingModules/e_to_the_jpi.py:
--------------------------------------------------------------------------------
1 | import math
2 |
3 | print math.e ** (1j * math.pi)
4 |
5 |
6 | import cmath
7 |
8 | print cmath.exp(1j * cmath.pi)
9 |
--------------------------------------------------------------------------------
/04-UsingModules/print_file.py:
--------------------------------------------------------------------------------
1 | def print_file_line_numbers(fp):
2 | for index, line in enumerate(fp):
3 | print index + 1, line,
4 |
5 | import StringIO
6 |
7 | fp = StringIO.StringIO('''The quick
8 | brown fox
9 | jumped over
10 | the lazy dog''')
11 |
12 | print_file_line_numbers(fp)
13 |
14 |
15 |
--------------------------------------------------------------------------------
/04-UsingModules/print_file_debug.py:
--------------------------------------------------------------------------------
1 | def print_file_line_numbers(fp):
2 | import pdb; pdb.set_trace()
3 | for index, line in enumerate(fp):
4 | print index + 1, line,
5 |
6 | import StringIO
7 |
8 | fp = StringIO.StringIO('''The quick
9 | brown fox
10 | jumped over
11 | the lazy dog''')
12 |
13 | print_file_line_numbers(fp)
14 |
15 |
16 |
--------------------------------------------------------------------------------
/04-UsingModules/print_my_argv.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | print sys.argv
4 |
--------------------------------------------------------------------------------
/04-UsingModules/print_my_path.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import os.path
3 |
4 | print os.path.abspath(sys.argv[0])
5 |
--------------------------------------------------------------------------------
/04-UsingModules/time_every_second.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | while True:
4 | print time.time()
5 | time.sleep(1)
6 |
--------------------------------------------------------------------------------
/04-UsingModules_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/04-UsingModules_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/04-UsingModules_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/04-UsingModules_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/04-UsingModules_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/04-UsingModules_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/05-Strings.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/05-Strings.pdf
--------------------------------------------------------------------------------
/05-Strings/get_word_count.py:
--------------------------------------------------------------------------------
1 | import StringIO
2 |
3 | text = '''
4 | The quick brown fox jumped over the lazy dog.
5 | The dog was very lazy and the fox was quite quick.
6 | '''
7 |
8 | def isalpha(ch):
9 | return ch.isalpha()
10 |
11 | def get_words_count(fp):
12 | result = {}
13 | for line in fp:
14 | for word in line.split():
15 | word = filter(isalpha, word.lower())
16 | if word in result:
17 | result[word] += 1
18 | else:
19 | result[word] = 1
20 | return result
21 |
22 | print get_words_count(StringIO.StringIO(text))
23 |
--------------------------------------------------------------------------------
/05-Strings/get_words.py:
--------------------------------------------------------------------------------
1 | import StringIO
2 |
3 | text = '''
4 | The quick brown fox jumped over the lazy dog.
5 | The dog was very lazy and the fox was quite quick.
6 | '''
7 |
8 | def isalpha(ch):
9 | return ch.isalpha()
10 |
11 | def get_words(fp):
12 | result = []
13 | for line in fp:
14 | for word in line.split():
15 | word = word.lower()
16 | word = filter(isalpha, word)
17 | result.append(word)
18 | return result
19 |
20 | print get_words(StringIO.StringIO(text))
21 |
--------------------------------------------------------------------------------
/05-Strings/print_centered_words.py:
--------------------------------------------------------------------------------
1 | def print_centered_words(words):
2 | for word in words:
3 | print word.title().center(80)
4 |
5 | print_centered_words(['The', 'quick', 'brown', 'fox'])
6 |
--------------------------------------------------------------------------------
/05-Strings_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/05-Strings_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/05-Strings_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/05-Strings_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/05-Strings_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/05-Strings_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/05-Strings_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/06-Regex.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/06-Regex.pdf
--------------------------------------------------------------------------------
/06-Regex/regex_tests.py:
--------------------------------------------------------------------------------
1 | import re
2 | re_integer = re.compile(r'\d+')
3 |
4 | def find_integers(fp):
5 | result = []
6 | for line in fp:
7 | for match in re_integer.finditer(line):
8 | result.append(int(match.group(0)))
9 | return result
10 |
11 | text = '''The 42nd number in a list of integers starting at
12 | 0 is actually 41. It's a surprising result, but one that
13 | computer scientists have dealt with since the days of IBM mainframes.'''
14 |
15 | import StringIO
16 | print 'Integers:', find_integers(StringIO.StringIO(text))
17 |
18 | re_capword = re.compile(r"\b([A-Z][A-Za-z']*)")
19 | def find_capwords(fp):
20 | result = []
21 | for line in fp:
22 | for match in re_capword.finditer(line):
23 | result.append(match.group(1))
24 | return result
25 |
26 | print 'Capwords:', find_capwords(StringIO.StringIO(text))
27 |
28 | re_br = re.compile(r'
')
29 | def bad_html_to_xhtml(fp):
30 | result = []
31 | for line in fp:
32 | new_line = re_br.sub('
', line)
33 | result.append(new_line)
34 | return ''.join(result)
35 |
36 | print 'Bad html to xhtml:', bad_html_to_xhtml(StringIO.StringIO('''
37 |
38 | This works ok
39 |
40 |
'''))
41 |
--------------------------------------------------------------------------------
/06-Regex_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/06-Regex_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/06-Regex_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/06-Regex_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/06-Regex_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/06-Regex_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/06-Regex_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/06a-Packages/mypackage/__init__.py:
--------------------------------------------------------------------------------
1 | print 'importing mypackage'
2 | # import mysubpackage
3 |
--------------------------------------------------------------------------------
/06a-Packages/mypackage/mysubpackage/__init__.py:
--------------------------------------------------------------------------------
1 | print 'importing mypackage.mysubpackage'
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/06a-Packages/mypackage/mysubpackage/mymodule.py:
--------------------------------------------------------------------------------
1 | print 'importing mypackage.mysubpackage.mymodule'
2 |
--------------------------------------------------------------------------------
/06a-Packages/test1.py:
--------------------------------------------------------------------------------
1 | import mypackage
2 |
3 | print mypackage
4 |
--------------------------------------------------------------------------------
/06a-Packages/test2.py:
--------------------------------------------------------------------------------
1 | import mypackage.mysubpackage
2 |
3 | print 'mypackage is', mypackage
4 | print 'mypackage.mysubpackage is', mypackage.mysubpackage
5 |
--------------------------------------------------------------------------------
/06a-Packages/test3.py:
--------------------------------------------------------------------------------
1 | from mypackage.mysubpackage import mymodule
2 |
3 | print 'mymodule is', mymodule
4 |
--------------------------------------------------------------------------------
/07-Functions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/07-Functions.pdf
--------------------------------------------------------------------------------
/07-Functions/log_function.py:
--------------------------------------------------------------------------------
1 | def log(format, *args, **kwargs):
2 | if args:
3 | print format % args
4 | else:
5 | print format % kwargs
6 |
7 | if __name__ == '__main__':
8 | log('The pair is (%r,%r)', 1, 2)
9 | log('The value of a is %(a)r', a='foo')
10 | log('The value of a is %(a)r', **{'a': 'foo'})
11 |
12 | log('This does not have any arguments')
13 |
--------------------------------------------------------------------------------
/07-Functions_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/07-Functions_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/07-Functions_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/07-Functions_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/07-Functions_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/07-Functions_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/07-Functions_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/08-AdvancedFunctions.pdf
--------------------------------------------------------------------------------
/08-AdvancedFunctions/myfilter.py:
--------------------------------------------------------------------------------
1 | def myfilter(function, sequence):
2 | result = []
3 | for item in sequence:
4 | if function(item):
5 | result.append(item)
6 | return result
7 |
8 | print myfilter(lambda x: x%2==0, range(10))
9 | print myfilter(lambda x: x%2==1, range(10))
10 |
11 | def myfilter(function, sequence1, sequence2):
12 | result = []
13 | for item1, item2 in zip(sequence1, sequence2):
14 | if function(item1, item2):
15 | result.append((item1, item2))
16 | return result
17 |
18 | def myfilter(function, *sequences):
19 | result = []
20 | for items in zip(*sequences):
21 | if function(*items):
22 | result.append(items)
23 | return result
24 |
25 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions/postorder.py:
--------------------------------------------------------------------------------
1 | mytree = ('root',
2 | ('child-L',
3 | ('child-LL', (), ()),
4 | ('child-LR', (), ())),
5 | ('child-R',
6 | ('child-RL', (), ()),
7 | ('child-RR', (), ())))
8 |
9 | def postorder_tree_map(function, node, level=0):
10 | value, left, right = node
11 | result = []
12 | if left:
13 | result.extend(postorder_tree_map(function, left, level+1))
14 | if right:
15 | result.extend( postorder_tree_map(function, right, level+1))
16 | result.append(function(level, value))
17 | return result
18 |
19 | def print_node(level, value):
20 | print (' ' * level) + repr(value)
21 | return value
22 |
23 | print postorder_tree_map(print_node, mytree)
24 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/08-AdvancedFunctions_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/09-Logging.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/09-Logging.pdf
--------------------------------------------------------------------------------
/09-Logging/fileconfig.ini:
--------------------------------------------------------------------------------
1 | [loggers]
2 | keys = root, mylogger
3 |
4 | [handlers]
5 | keys = stream, file, http
6 |
7 | [formatters]
8 | keys = basic, precise
9 |
10 | [logger_root]
11 | level = DEBUG
12 | handlers = stream
13 |
14 | [logger_mylogger]
15 | qualname = mylogger
16 | level = INFO
17 | handlers = stream, file, http
18 | propagate = 0
19 |
20 | [handler_stream]
21 | class = StreamHandler
22 | formatter = basic
23 | args = (sys.stderr,)
24 |
25 | [handler_file]
26 | class = handlers.WatchedFileHandler
27 | args = ('/tmp/log_file.log','w')
28 | formatter = precise
29 |
30 | [handler_http]
31 | class = handlers.HTTPHandler
32 | args = ('localhost:9022', '/log', 'GET')
33 | formatter = precise
34 |
35 | [formatter_basic]
36 | format = %(message)s
37 |
38 | [formatter_precise]
39 | format = %(asctime)s %(levelname)-8s %(name)-15s %(message)s
40 | datefmt = %Y-%m-%d %H:%M:%S
41 |
--------------------------------------------------------------------------------
/09-Logging/log_example.py:
--------------------------------------------------------------------------------
1 | import logging.config
2 |
3 | logging.basicConfig(
4 | level=logging.INFO,
5 | format='%(pathname)s:%(lineno)s %(levelname)s %(levelname)-8s %(name)-15s %(message)s'
6 | )
7 | log = logging.getLogger()
8 | log.info('Log here')
9 |
10 | log.info("And here")
11 |
--------------------------------------------------------------------------------
/09-Logging/log_file_config.py:
--------------------------------------------------------------------------------
1 | import logging.config
2 |
3 | logging.config.fileConfig('09-Logging/fileconfig.ini')
4 |
5 | root = logging.getLogger()
6 | mylogger = logging.getLogger('mylogger')
7 |
8 | root.error('Info from root')
9 | mylogger.error('Info from mylogger')
10 |
--------------------------------------------------------------------------------
/09-Logging_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/09-Logging_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/09-Logging_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/09-Logging_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/09-Logging_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/09-Logging_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/10-OOP1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/10-OOP1.pdf
--------------------------------------------------------------------------------
/10-OOP1/directory.py:
--------------------------------------------------------------------------------
1 | class Directory(object):
2 |
3 | def __init__(self):
4 | self._directory = {}
5 |
6 | def add_number(self, name, number):
7 | self._directory[name] = number
8 |
9 | def remove_number(self, name):
10 | self._directory.pop(name, None)
11 |
12 | def lookup_number(self, name):
13 | return self._directory.get(name, '<>')
14 |
15 | def print_directory(self):
16 | print 'Begin directory'
17 | print self._directory
18 | for name, number in self._directory.items():
19 | print ' %s: %s' % (name, number)
20 | print 'End directory'
21 |
22 | d = Directory()
23 | d.add_number('Rick', '404.452.5202')
24 | print 'Rick has number', d.lookup_number('Rick')
25 | d.print_directory()
26 | print
27 | d.remove_number('Rick')
28 | d.print_directory()
29 | print
30 | print 'Rick has number', d.lookup_number('Rick')
31 | print
32 | d.remove_number('Rick')
33 |
34 |
--------------------------------------------------------------------------------
/10-OOP1_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/10-OOP1_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/10-OOP1_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/10-OOP1_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/10-OOP1_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/10-OOP1_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/10-OOP1_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/11-OOP2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/11-OOP2.pdf
--------------------------------------------------------------------------------
/11-OOP2/directory-1.py:
--------------------------------------------------------------------------------
1 | class Directory(object):
2 |
3 | def __init__(self):
4 | self._directory = {}
5 |
6 | def add_number(self, name, number):
7 | self._directory[name] = number
8 |
9 | def remove_number(self, name):
10 | del self._directory[name]
11 |
12 | def lookup_number(self, name):
13 | return self._directory[name]
14 |
15 | def __getitem__(self, name):
16 | return self.lookup_number(name)
17 |
18 | def __setitem__(self, name, number):
19 | self.add_number(name, number)
20 |
21 | def __delitem__(self, name):
22 | self.remove_number(name)
23 |
24 | def __repr__(self):
25 | l = ['']
26 | for name, number in self._directory.items():
27 | l.append(' %s: %s' % (name, number))
28 | l.append('')
29 | return '\n'.join(l)
30 |
31 | d = Directory()
32 | d['Rick'] = '404.452.5202'
33 | print "Rick's number is", d['Rick']
34 | print d
35 | del d['Rick']
36 | print d
37 |
38 |
--------------------------------------------------------------------------------
/11-OOP2_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/11-OOP2_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/11-OOP2_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/11-OOP2_files/ipython.css:
--------------------------------------------------------------------------------
1 |
2 |
3 | .cm-s-ipython span.cm-keyword {color: #008000; font-weight: bold;}
4 | .cm-s-ipython span.cm-number {color: #000080;}
5 | .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
6 | .cm-s-ipython span.cm-meta {color: #AA22FF;}
7 | .cm-s-ipython span.cm-comment {color: #408080; font-style: italic;}
8 | .cm-s-ipython span.cm-string {color: #BA2121;}
9 | .cm-s-ipython span.cm-error {color: #f00;}
10 | .cm-s-ipython span.cm-builtin {color: #008000;}
11 | .cm-s-ipython span.cm-variable {color: #000000;}
12 |
13 | /* These classes are not currently used in the python.js mode */
14 |
15 | /*.cm-s-ipython span.cm-atom {color: #219;}*/
16 | /*.cm-s-ipython span.cm-def {color: #00f;}*/
17 | /*.cm-s-ipython span.cm-variable-2 {color: #05a;}*/
18 | /*.cm-s-ipython span.cm-variable-3 {color: #0a5;}*/
19 | /*.cm-s-ipython span.cm-property {color: black;}*/
20 | /*.cm-s-ipython span.cm-qualifier {color: #555;}*/
21 | /*.cm-s-ipython span.cm-bracket {color: #cc7;}*/
22 | /*.cm-s-ipython span.cm-tag {color: #170;}*/
23 | /*.cm-s-ipython span.cm-attribute {color: #00c;}*/
24 |
25 | /* These are the old styles for our pre-themed version */
26 |
27 | /*span.py-delimiter {color: #666666;}*/
28 | /*span.py-special {color: #666666;}*/
29 | /*span.py-operator {color: #AA22FF; font-weight: bold;}*/
30 | /*span.py-keyword {color: #008000; font-weight: bold;}*/
31 | /*span.py-number {color: #666666;}*/
32 | /*span.py-identifier {color: #000000;}*/
33 | /*span.py-func {color: #000000;}*/
34 | /*span.py-type {color: #008000;}*/
35 | /*span.py-decorator {color: #AA22FF;}*/
36 | /*span.py-comment {color: #408080; font-style: italic;}*/
37 | /*span.py-string {color: #BA2121;}*/
38 | /*span.py-bytes {color: #BA2121;}*/
39 | /*span.py-raw {color: #BA2121;}*/
40 | /*span.py-unicode {color: #BA2121;}*/
41 |
--------------------------------------------------------------------------------
/11-OOP2_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/11-OOP2_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/11-OOP2_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/12-Decorators.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/12-Decorators.pdf
--------------------------------------------------------------------------------
/12-Decorators/log_function_calls.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | logging.basicConfig()
4 |
5 | class log_call(object):
6 |
7 | def __init__(self, logger, level=logging.INFO):
8 | self._logger = logger
9 | self._level = level
10 |
11 | def __call__(self, function):
12 | def wrapper(*args, **kwargs):
13 | self._logger.log(
14 | self._level, 'Enter %s(*%r, **%r)',
15 | function, args, kwargs)
16 | result = function(*args, **kwargs)
17 | self._logger.log(
18 | self._level, 'Exit %s => %r', function, result)
19 | return result
20 | return wrapper
21 |
22 | def log_call_alt(logger, level=logging.INFO):
23 | def decorator(function):
24 | def wrapper(*args, **kwargs):
25 | logger.log(
26 | level, 'Enter %s(*%r, **%r)',
27 | function, args, kwargs)
28 | result = function(*args, **kwargs)
29 | logger.log(
30 | level, 'Exit %s => %r', function, result)
31 | return result
32 | return wrapper
33 | return decorator
34 |
35 | @log_call(logging.getLogger('mylogger'), logging.ERROR)
36 | def will_log_to_error(a, b):
37 | return a + b
38 |
39 | @log_call_alt(logging.getLogger('mylogger'), logging.ERROR)
40 | def will_log_to_error_2(a, b):
41 | return a + b
42 |
43 | print will_log_to_error(1, 2)
44 | print will_log_to_error_2(3, 4)
45 |
--------------------------------------------------------------------------------
/12-Decorators/read-only-property.py:
--------------------------------------------------------------------------------
1 | class MyClass(object):
2 |
3 | def __init__(self, a):
4 | self._a = a
5 |
6 | @property
7 | def a(self):
8 | return self._a
9 |
10 | x = MyClass('avalue')
11 | print x.a
12 | x.a = 'bvalue'
13 |
--------------------------------------------------------------------------------
/12-Decorators/with_file.py:
--------------------------------------------------------------------------------
1 | class with_file(object):
2 |
3 | def __init__(self, *open_args):
4 | self._open_args = open_args
5 |
6 | def __call__(self, function):
7 | def wrapper(*args, **kwargs):
8 | fp = open(*self._open_args)
9 | try:
10 | return function(fp, *args, **kwargs)
11 | finally:
12 | fp.close()
13 | return wrapper
14 |
15 | def with_file_alt(*open_args):
16 | def decorator(function):
17 | def wrapper(*args, **kwargs):
18 | fp = open(*open_args)
19 | try:
20 | return function(fp, *args, **kwargs)
21 | finally:
22 | fp.close()
23 | return wrapper
24 | return decorator
25 |
26 | @with_file('/etc/hosts')
27 | def print_file(fp):
28 | for i, line in enumerate(fp):
29 | print '%.4d: %s' % (i+1, line.rstrip())
30 |
31 | @with_file_alt('/etc/hosts')
32 | def print_file_2(fp):
33 | for i, line in enumerate(fp):
34 | print '%.4d: %s' % (i+1, line.rstrip())
35 |
36 |
37 | print_file()
38 | print_file_2()
39 |
--------------------------------------------------------------------------------
/12-Decorators_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/12-Decorators_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/12-Decorators_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/12-Decorators_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/12-Decorators_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/12-Decorators_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/13-Generators/tree-print.py:
--------------------------------------------------------------------------------
1 | mytree = ('root',
2 | ('child-L',
3 | ('child-LL', (), ()),
4 | ('child-LR', (), ())),
5 | ('child-R',
6 | ('child-RL', (), ()),
7 | ('child-RR', (), ())))
8 |
9 | def postorder_tree_iter(node, level=0):
10 | if node:
11 | value, left, right = node
12 | for child_level, child_value in postorder_tree_iter(
13 | left, level+1):
14 | yield child_level, child_value
15 | for child_level, child_value in postorder_tree_iter(
16 | right, level+1):
17 | yield child_level, child_value
18 | yield level, value
19 |
20 | for level, value in postorder_tree_iter(mytree):
21 | print ' ' * level, value
22 |
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/13-GeneratorsAndIterators.pdf
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/13-GeneratorsAndIterators_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/14-ContextManagers.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/14-ContextManagers.pdf
--------------------------------------------------------------------------------
/14-ContextManagers/logger.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | logging.basicConfig()
4 |
5 | class log_block(object):
6 |
7 | def __init__(self, logger, level=logging.INFO):
8 | self._logger = logger
9 | self._level = level
10 |
11 | def __enter__(self):
12 | self._logger.log(self._level, 'Enter')
13 |
14 | def __exit__(self, ex_type, ex_value, ex_tb):
15 | if ex_type is None:
16 | self._logger.log(self._level, 'Exit (no exception)')
17 | else:
18 | self._logger.log(self._level, 'Exit (with exception %s)', ex_type)
19 | return True
20 |
21 | print 'This is before the with statement'
22 |
23 | with log_block(logging.getLogger('mylogger'), logging.ERROR):
24 | print 'Now inside the block'
25 | print 'still inside block'
26 |
27 | with log_block(logging.getLogger('mylogger'), logging.ERROR):
28 | print 'Now inside the 2nd block'
29 | print 'still inside 2nd block'
30 | raise ValueError
31 |
32 | def log_decorator(logger, level=logging.INFO):
33 | '''Just for fun'''
34 | def decorator(function):
35 | def wrapper(*args, **kwargs):
36 | with log_block(logger, level):
37 | return function(*args, **kwargs)
38 | return wrapper
39 | return decorator
40 |
--------------------------------------------------------------------------------
/14-ContextManagers/logger2.py:
--------------------------------------------------------------------------------
1 | import logging
2 | from contextlib import contextmanager
3 |
4 | logging.basicConfig()
5 |
6 | @contextmanager
7 | def log_block(logger, level=logging.INFO):
8 | logger.log(level, 'Enter')
9 | try:
10 | yield
11 | except:
12 | logger.log(level, 'Exit (with exception)')
13 | else:
14 | logger.log(level, 'Exit (no exception)')
15 |
16 |
17 | print 'This is before the with statement'
18 |
19 | with log_block(logging.getLogger('mylogger'), logging.ERROR):
20 | print 'Now inside the block'
21 | print 'still inside block'
22 |
23 | with log_block(logging.getLogger('mylogger'), logging.ERROR):
24 | print 'Now inside the 2nd block'
25 | print 'still inside 2nd block'
26 | raise ValueError
27 |
--------------------------------------------------------------------------------
/14-ContextManagers/xml-gen.py:
--------------------------------------------------------------------------------
1 | class node(object):
2 |
3 | def __init__(self, name):
4 | self.name = name
5 |
6 | def __enter__(self):
7 | print '<%s>' % self.name
8 |
9 | def __exit__(self, ex_type, ex_value, ex_tb):
10 | print '%s>' % self.name
11 |
12 | with node('html'):
13 | with node('body'):
14 | with node('h1'):
15 | print 'Page Title'
16 |
17 |
--------------------------------------------------------------------------------
/14-ContextManagers/xml-gen2.py:
--------------------------------------------------------------------------------
1 | from contextlib import contextmanager
2 |
3 | # class contextmanager(object):
4 |
5 | # def __init__(self, generator):
6 | # self._generator = generator
7 |
8 | # def __enter__(self):
9 | # return self._generator.next()
10 |
11 | # def __exit__(self, ex_type, ex_value, ex_tb):
12 | # try:
13 | # self._generator.next()
14 | # except StopIteration:
15 | # return
16 |
17 | @contextmanager
18 | def node(name):
19 | print '<%s>' % name
20 | yield None
21 | print '%s>' % name
22 |
23 | htmlnode = node('html')
24 | bodynode = node('body')
25 | h1node = node('h1')
26 |
27 | with htmlnode:
28 | with bodynode:
29 | with h1node:
30 | print 'Page title'
31 |
32 | with node('html'):
33 | with node('body'):
34 | with node('h1'):
35 | print 'Page Title'
36 |
37 |
--------------------------------------------------------------------------------
/14-ContextManagers_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/14-ContextManagers_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/14-ContextManagers_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/14-ContextManagers_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/14-ContextManagers_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/14-ContextManagers_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/15-Threading/atomic_log.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import threading
3 |
4 | log_mutex = threading.Lock()
5 |
6 | def log(message, *args):
7 | with log_mutex:
8 | slow_log(message, *args)
9 |
10 | def slow_log(message, *args):
11 | message = message % args
12 | for ch in message:
13 | sys.stdout.write(ch)
14 | sys.stdout.flush()
15 | sys.stdout.write('\n')
16 | sys.stdout.flush()
17 |
18 | def target(x):
19 | for y in range(4):
20 | log('(x,y) is (%d, %d)',x,y)
21 |
22 | threads = [ threading.Thread(target=target, args=(x,))
23 | for x in range(4) ]
24 |
25 | for t in threads:
26 | t.start()
27 |
--------------------------------------------------------------------------------
/15-Threading/condition.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | import threading
4 |
5 | thread_to_run = None
6 |
7 | # Set logger to just use threadname
8 | logging.basicConfig(
9 | level=logging.INFO,
10 | format='%(threadName)s: %(message)s')
11 |
12 | log = logging.getLogger()
13 |
14 | cond = threading.Condition()
15 |
16 | def worker(y):
17 | global thread_to_run
18 | with cond:
19 | while thread_to_run != y:
20 | cond.wait()
21 | log.info('Running thread %d', y)
22 | time.sleep(0.5)
23 | log.info('Now done')
24 | thread_to_run = None
25 | cond.notify_all()
26 |
27 | def coordinator(num_threads):
28 | global thread_to_run
29 | for x in range(num_threads):
30 | with cond:
31 | while thread_to_run is not None:
32 | cond.wait()
33 | thread_to_run = x
34 | cond.notify_all()
35 |
36 | workers = [ threading.Thread(target=worker, args=(x,))
37 | for x in range(10) ]
38 | for t in workers: t.start()
39 |
40 | coordinator(10)
41 |
--------------------------------------------------------------------------------
/15-Threading/event.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | ev = threading.Event()
12 |
13 | def timer():
14 | log.info('Timer running')
15 | ev.set()
16 |
17 | def target():
18 | log.info('Target waiting')
19 | ev.wait()
20 | log.info('Target running')
21 | ev.clear()
22 |
23 | t1 = threading.Thread(target=target)
24 | t1.start()
25 |
26 | t2 = threading.Timer(3, timer)
27 | t2.start()
28 |
--------------------------------------------------------------------------------
/15-Threading/lock1.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | lock = threading.Lock()
12 |
13 | def thread_target(y):
14 | lock.acquire()
15 | log.info('Enter')
16 | for item in range(y):
17 | log.info('%s', item)
18 | log.info('Exit')
19 | lock.release()
20 |
21 | threads = [ threading.Thread(target=thread_target, args=(4,))
22 | for x in range(4) ]
23 |
24 | log.info('Starting threads')
25 | for i, t in enumerate(threads):
26 | log.info('Starting thread %d', i)
27 | t.start()
28 | log.info('All threads started')
29 |
--------------------------------------------------------------------------------
/15-Threading/lock2.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | lock = threading.Lock()
12 |
13 | def thread_target(y):
14 | with lock:
15 | log.info('Enter')
16 | for item in range(y):
17 | log.info('%s', item)
18 | log.info('Exit')
19 |
20 | threads = [ threading.Thread(target=thread_target, args=(4,))
21 | for x in range(4) ]
22 |
23 | log.info('Starting threads')
24 | for i, t in enumerate(threads):
25 | log.info('Starting thread %d', i)
26 | t.start()
27 | log.info('All threads started')
28 |
--------------------------------------------------------------------------------
/15-Threading/print_time.py:
--------------------------------------------------------------------------------
1 | import time
2 | import threading
3 |
4 | def print_time():
5 | while True:
6 | print time.ctime()
7 | time.sleep(1)
8 |
9 |
10 | t = threading.Thread(target=print_time)
11 | t.setDaemon(True)
12 | t.start()
13 |
14 | time.sleep(10)
15 |
--------------------------------------------------------------------------------
/15-Threading/queue.py:
--------------------------------------------------------------------------------
1 | import time
2 | import Queue
3 | import logging
4 | import threading
5 |
6 | logging.basicConfig(
7 | level=logging.INFO,
8 | format='%(threadName)s: %(message)s')
9 |
10 | log = logging.getLogger()
11 |
12 | q = Queue.Queue()
13 |
14 | def producer():
15 | for x in range(10):
16 | time.sleep(0.5)
17 | log.info('>>> %s', x)
18 | q.put(x)
19 |
20 | def consumer():
21 | while True:
22 | x = q.get()
23 | log.info('<<< %s', x)
24 |
25 | t_producer = threading.Thread(target=producer)
26 | t_consumer = threading.Thread(target=consumer)
27 | t_consumer.setDaemon(True)
28 |
29 | t_producer.start()
30 | time.sleep(2)
31 | t_consumer.start()
32 |
--------------------------------------------------------------------------------
/15-Threading/sem1.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | import threading
4 |
5 | # Set logger to just use threadname
6 | logging.basicConfig(
7 | level=logging.INFO,
8 | format='%(threadName)s: %(message)s')
9 |
10 | log = logging.getLogger()
11 |
12 | sem = threading.Semaphore(4)
13 |
14 | def thread_target(y):
15 | with sem:
16 | log.info('Enter')
17 | time.sleep(1)
18 | log.info('Exit')
19 |
20 | threads = [ threading.Thread(target=thread_target, args=(4,))
21 | for x in range(10) ]
22 |
23 | for i, t in enumerate(threads):
24 | t.start()
25 |
--------------------------------------------------------------------------------
/15-Threading/threading1.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | logging.basicConfig(
5 | level=logging.INFO)
6 |
7 | log = logging.getLogger('main')
8 |
9 | def thread_target(x, y):
10 | log = logging.getLogger('thread-%d' % x)
11 | log.info('Enter')
12 | for item in range(y):
13 | log.info('%s', item)
14 | log.info('Exit')
15 |
16 | threads = [ threading.Thread(target=thread_target, args=(x, 4))
17 | for x in range(4) ]
18 |
19 | log.info('Starting threads')
20 | for i, t in enumerate(threads):
21 | log.info('Starting thread %d', i)
22 | t.start()
23 | log.info('All threads started')
24 |
--------------------------------------------------------------------------------
/15-Threading/threading2.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | logging.basicConfig(
5 | level=logging.INFO)
6 |
7 | log = logging.getLogger('main')
8 |
9 | def thread_target(x, y):
10 | log = logging.getLogger('thread-%d' % x)
11 | log.info('Enter')
12 | for item in range(y):
13 | log.info('%s', item)
14 | log.info('Exit')
15 |
16 | threads = [ threading.Thread(target=thread_target, args=(x, 4))
17 | for x in range(4) ]
18 |
19 | log.info('Starting threads')
20 | for i, t in enumerate(threads):
21 | log.info('Starting thread %d', i)
22 | t.start()
23 | # Wait for thread to complete
24 | t.join()
25 | log.info('Joined thread %d', i)
26 | log.info('All threads started')
27 |
--------------------------------------------------------------------------------
/15-Threading/threading3.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | def thread_target(x, y):
12 | log.info('Enter')
13 | for item in range(y):
14 | log.info('%s', item)
15 | log.info('Exit')
16 |
17 | threads = [ threading.Thread(target=thread_target, args=(x,4))
18 | for x in range(4) ]
19 |
20 | log.info('Daemonizing threads')
21 | for i, t in enumerate(threads):
22 | t.setDaemon(True)
23 |
24 | log.info('Starting threads')
25 | for i, t in enumerate(threads):
26 | log.info('Starting thread %d', i)
27 | t.start()
28 | log.info('All threads started')
29 |
--------------------------------------------------------------------------------
/15-Threading/threadlocal.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | logging.basicConfig(
5 | level=logging.INFO,
6 | format='%(threadName)s: %(message)s')
7 |
8 | thread_local = threading.local()
9 | thread_local.name = 'Set in main thread'
10 |
11 | log = logging.getLogger()
12 |
13 | def target():
14 | thread_local.name = 'Set in target thread'
15 | log.info('thread_local.name = %s', thread_local.name)
16 |
17 | log.info('thread_local.name = %s', thread_local.name)
18 | t = threading.Thread(target=target)
19 | t.start()
20 | t.join()
21 | log.info('thread_local.name = %s', thread_local.name)
22 |
--------------------------------------------------------------------------------
/15-Threading/timer.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | def hello(x):
12 | log.info('Hello, %s', x)
13 |
14 | t = threading.Timer(5.0, hello, ('World',))
15 | t.start()
16 | log.info('Main program complete')
17 |
--------------------------------------------------------------------------------
/15-Threading/timer2.py:
--------------------------------------------------------------------------------
1 | import logging
2 | import threading
3 |
4 | # Set logger to just use threadname
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(threadName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | def hello(x):
12 | log.info('Hello, %s', x)
13 |
14 | t = threading.Timer(5.0, hello, ('World',))
15 | t.start()
16 | log.info('Main program complete')
17 | t.cancel()
18 |
--------------------------------------------------------------------------------
/16-Multiprocessing/atomic_log.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import threading
3 |
4 | log_mutex = threading.Lock()
5 |
6 | def log(message):
7 | with log_mutex:
8 | slow_log(message)
9 |
10 | def slow_log(message):
11 | for ch in message:
12 | sys.stdout.write(ch)
13 | sys.stdout.flush()
14 | sys.stdout.write('\n')
15 | sys.stdout.flush()
16 |
17 | def target(x):
18 | for y in range(4):
19 | log('(x,y) is (%d, %d)' % (x,y))
20 |
21 | threads = [ threading.Thread(target=target, args=(x,))
22 | for x in range(4) ]
23 |
24 | for t in threads:
25 | t.start()
26 |
--------------------------------------------------------------------------------
/16-Multiprocessing/lock1.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | import multiprocessing
4 |
5 | # Set logger to just use threadname
6 | logging.basicConfig(
7 | level=logging.INFO,
8 | format='%(processName)s: %(message)s')
9 |
10 | log = logging.getLogger()
11 |
12 | lock = multiprocessing.Lock()
13 |
14 | def target(y):
15 | with lock:
16 | log.info('Enter')
17 | for item in range(y):
18 | time.sleep(0.1)
19 | log.info('%s', item)
20 | log.info('Exit')
21 |
22 | procs = [ multiprocessing.Process(target=target, args=(4,))
23 | for x in range(4) ]
24 |
25 | log.info('Starting procs')
26 | for i, t in enumerate(procs):
27 | log.info('Starting proc %d', i)
28 | t.start()
29 | log.info('All procs started')
30 |
--------------------------------------------------------------------------------
/16-Multiprocessing/print_time.py:
--------------------------------------------------------------------------------
1 | import time
2 | import multiprocessing
3 |
4 | def print_time():
5 | while True:
6 | print time.ctime()
7 | time.sleep(1)
8 |
9 | def main():
10 | t = multiprocessing.Process(target=print_time)
11 | t.start()
12 | time.sleep(10)
13 | t.terminate()
14 |
15 |
16 | if __name__ == '__main__':
17 | main()
18 |
--------------------------------------------------------------------------------
/16-Multiprocessing/processing1.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | import multiprocessing
4 |
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(processName)s (%(process)s): %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | def main():
12 | procs = [ multiprocessing.Process(target=target, args=(x, 4))
13 | for x in range(4) ]
14 | log.info('Starting procs')
15 | for i, p in enumerate(procs):
16 | log.info('Starting process %d', i)
17 | p.start()
18 | log.info('All procs started')
19 |
20 | def target(x, y):
21 | log.info('Enter')
22 | for item in range(y):
23 | log.info('(%s,%s)', x, item)
24 | time.sleep(0.1)
25 | log.info('Exit')
26 |
27 | if __name__ == '__main__':
28 | main()
29 |
--------------------------------------------------------------------------------
/16-Multiprocessing/processing2.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | import multiprocessing
4 |
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(processName)s (%(process)s): %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | def main():
12 | procs = [ multiprocessing.Process(target=target, args=(x, 4))
13 | for x in range(4) ]
14 | log.info('Starting procs')
15 | for i, p in enumerate(procs):
16 | log.info('Starting process %d', i)
17 | p.start()
18 | p.join()
19 | log.info('All procs started')
20 |
21 | def target(x, y):
22 | log.info('Enter')
23 | for item in range(y):
24 | time.sleep(0.1)
25 | log.info('(%s,%s)', x, item)
26 | log.info('Exit')
27 |
28 | if __name__ == '__main__':
29 | main()
30 |
--------------------------------------------------------------------------------
/16-Multiprocessing/queue.py:
--------------------------------------------------------------------------------
1 | import time
2 | import logging
3 | from multiprocessing import Queue, Process
4 |
5 | logging.basicConfig(
6 | level=logging.INFO,
7 | format='%(processName)s: %(message)s')
8 |
9 | log = logging.getLogger()
10 |
11 | q = Queue()
12 |
13 | def producer():
14 | for x in range(10):
15 | time.sleep(0.5)
16 | log.info('>>> %s', x)
17 | q.put(x)
18 |
19 | def consumer():
20 | while True:
21 | x = q.get()
22 | log.info('<<< %s', x)
23 |
24 | p_producer = Process(target=producer)
25 | p_consumer = Process(target=consumer)
26 |
27 | p_producer.start()
28 | time.sleep(2)
29 | p_consumer.start()
30 | p_producer.join()
31 | time.sleep(0)
32 | p_consumer.terminate()
33 |
--------------------------------------------------------------------------------
/16-Multiprocessing/shared_memory.py:
--------------------------------------------------------------------------------
1 | import math
2 | import logging
3 | from multiprocessing import Process, Value, Array
4 |
5 | logging.basicConfig(level=logging.INFO)
6 |
7 | log = logging.getLogger()
8 |
9 | def main():
10 | num = Value('d', 0.0)
11 | arr = Array('i', range(10))
12 |
13 | log.info('Before process, num.value = %s', num.value)
14 | log.info('Before process, arr = %s', list(arr))
15 |
16 | p = Process(target=target, args=(num, arr))
17 | p.start()
18 | p.join()
19 |
20 | log.info('After process, num.value = %s', num.value)
21 | log.info('After process, arr = %s', list(arr))
22 |
23 | def target(num, arr):
24 | log.info('Running target function')
25 | num.value = math.pi
26 | for i, aval in enumerate(arr):
27 | arr[i] = -aval
28 |
29 | if __name__ == '__main__':
30 | main()
31 |
--------------------------------------------------------------------------------
/17-Subprocess.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/17-Subprocess.pdf
--------------------------------------------------------------------------------
/17-Subprocess/run_command.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 |
4 | for filename in os.listdir('.'):
5 | print subprocess.check_output(['stat', filename])
6 |
--------------------------------------------------------------------------------
/17-Subprocess/run_pipeline.py:
--------------------------------------------------------------------------------
1 | from subprocess import Popen, PIPE
2 |
3 | sp1 = Popen(['ls', '-laR'], stdout=PIPE)
4 | sp2 = Popen(['wc', '-l'], stdin=sp1.stdout, stdout=PIPE)
5 | stdout, stderr = sp2.communicate()
6 | print '%s lines' % stdout.strip()
7 |
--------------------------------------------------------------------------------
/17-Subprocess_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/17-Subprocess_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/17-Subprocess_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/17-Subprocess_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/17-Subprocess_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/17-Subprocess_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/18-Virtualenv/MyDistutilsProject/MANIFEST:
--------------------------------------------------------------------------------
1 | # file GENERATED by distutils, do NOT edit
2 | setup.py
3 | test-script
4 | mydistutilsproject/__init__.py
5 |
--------------------------------------------------------------------------------
/18-Virtualenv/MyDistutilsProject/mydistutilsproject/__init__.py:
--------------------------------------------------------------------------------
1 | #
2 | def foo():
3 | print 'bar'
4 |
--------------------------------------------------------------------------------
/18-Virtualenv/MyDistutilsProject/setup.py:
--------------------------------------------------------------------------------
1 | from distutils.core import setup
2 |
3 | version = '0.0'
4 |
5 | setup(name='MyDistutilsProject',
6 | version=version,
7 | description="",
8 | long_description="""\
9 | """,
10 | classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
11 | keywords='',
12 | author='',
13 | author_email='',
14 | url='',
15 | license='',
16 | packages=['mydistutilsproject'],
17 | include_package_data=True,
18 | zip_safe=False,
19 | scripts=['test-script'],
20 | install_requires=[
21 | # -*- Extra requirements: -*-
22 | ],
23 | )
24 |
--------------------------------------------------------------------------------
/18-Virtualenv/MyDistutilsProject/test-script:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | print 'This is a test script'
--------------------------------------------------------------------------------
/18-Virtualenv/MySetuptoolsProject/mysetuptoolsproject/__init__.py:
--------------------------------------------------------------------------------
1 | #
2 |
--------------------------------------------------------------------------------
/18-Virtualenv/MySetuptoolsProject/setup.cfg:
--------------------------------------------------------------------------------
1 | [egg_info]
2 | tag_build = dev
3 | tag_svn_revision = true
4 |
--------------------------------------------------------------------------------
/18-Virtualenv/MySetuptoolsProject/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 | import sys, os
3 |
4 | version = '0.0'
5 |
6 | setup(name='MySetuptoolsProject',
7 | version=version,
8 | description="",
9 | long_description="""\
10 | """,
11 | classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
12 | keywords='',
13 | author='',
14 | author_email='',
15 | url='',
16 | license='',
17 | packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
18 | include_package_data=True,
19 | zip_safe=False,
20 | install_requires=[
21 | # -*- Extra requirements: -*-
22 | ],
23 | entry_points="""
24 | # -*- Entry points: -*-
25 | """,
26 | )
27 |
--------------------------------------------------------------------------------
/19-Testing/directory.py:
--------------------------------------------------------------------------------
1 | class Directory(object):
2 |
3 | def __init__(self):
4 | self._directory = {}
5 |
6 | def add_number(self, name, number):
7 | self._directory[name] = number
8 |
9 | def remove_number(self, name):
10 | del self._directory[name]
11 |
12 | def lookup_number(self, name):
13 | return self._directory[name]
14 |
15 | def __repr__(self):
16 | l = ['']
17 | for name, number in self._directory.items():
18 | l.append(' %s: %s' % (name, number))
19 | l.append('')
20 | return '\n'.join(l)
21 |
22 |
--------------------------------------------------------------------------------
/19-Testing/simple_math.py:
--------------------------------------------------------------------------------
1 | def add(a, b):
2 | return a + b
3 |
4 | def subtract(a, b):
5 | return a - b
6 |
7 | def multiply(a, b):
8 | return a * b
9 |
10 | def divide(a, b):
11 | return a / b
12 |
--------------------------------------------------------------------------------
/19-Testing/test1.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | class MyTest(unittest.TestCase):
4 |
5 | def test_pass(self):
6 | pass
7 |
8 | if __name__ == '__main__':
9 | unittest.main()
10 |
--------------------------------------------------------------------------------
/19-Testing/test2.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | class MyTest(unittest.TestCase):
4 |
5 | def test_fail(self):
6 | assert False
7 |
8 | def test_fail_message(self):
9 | assert False, 'This is an assertion message'
10 |
11 | if __name__ == '__main__':
12 | unittest.main()
13 |
--------------------------------------------------------------------------------
/19-Testing/test3.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import simple_math
3 |
4 | class MyTest(unittest.TestCase):
5 |
6 | def test_one_and_one(self):
7 | self.assertEqual(simple_math.add(1, 1), 2)
8 |
9 | def test_one_and_one_fail(self):
10 | self.assertEqual(simple_math.add(1, 1), 4)
11 |
12 | def test_one_and_one_fail_assert(self):
13 | assert simple_math.add(1,1) == 4
14 |
15 | if __name__ == '__main__':
16 | unittest.main()
17 |
--------------------------------------------------------------------------------
/19-Testing/test4.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import simple_math
3 |
4 | class MyTest(unittest.TestCase):
5 |
6 | def test_one_and_one_alt(self):
7 | try:
8 | simple_math.divide(1,0)
9 | except ZeroDivisionError:
10 | pass
11 | else:
12 | raise AssertionError, 'Exception was not raised'
13 |
14 | def test_one_and_one(self):
15 | self.assertRaises(ZeroDivisionError, simple_math.divide, 1, 0)
16 |
17 |
18 | if __name__ == '__main__':
19 | unittest.main()
20 |
--------------------------------------------------------------------------------
/19-Testing/test5.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | class MyTest(unittest.TestCase):
4 |
5 | def test_pass(self):
6 | pass
7 |
8 | def test_fail(self):
9 | assert False
10 |
11 | def test_also_fail(self):
12 | raise AssertionError
13 |
14 | def test_error(self):
15 | raise ValueError
16 |
17 | if __name__ == '__main__':
18 | unittest.main()
19 |
--------------------------------------------------------------------------------
/19-Testing/test6.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from simple_math import add, subtract, multiply, divide
3 |
4 | class MyTest(unittest.TestCase):
5 |
6 | def setUp(self):
7 | self.x = 1
8 | self.y = 1
9 |
10 | def tearDown(self):
11 | pass
12 |
13 | def test_add(self):
14 | self.assertEqual(add(self.x, self.y), 2)
15 |
16 | def test_subtract(self):
17 | self.assertEqual(subtract(self.x, self.y), 0)
18 |
19 | def test_multiply(self):
20 | self.assertEqual(multiply(self.x, self.y), 1)
21 |
22 | def test_divide(self):
23 | self.assertEqual(divide(self.x, self.y), 1)
24 |
25 | if __name__ == '__main__':
26 | unittest.main()
27 |
--------------------------------------------------------------------------------
/19-Testing/test7.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | class MyTest(unittest.TestCase):
4 |
5 | def test_docstring(self):
6 | "This is a test docstring. It should say what's being tested."
7 | pass
8 |
9 | def test_no_docstring(self):
10 | pass
11 |
12 | def test_docstring_fail(self):
13 | "This is a test docstring. It should say what's being tested."
14 | assert False
15 |
16 | def test_no_docstring_fail(self):
17 | assert False
18 |
19 | if __name__ == '__main__':
20 | unittest.main()
21 |
--------------------------------------------------------------------------------
/19-Testing/test8.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import mock
3 |
4 | def echo_data(socket):
5 | data = socket.recv()
6 | socket.send(data)
7 |
8 | class MyTest(unittest.TestCase):
9 |
10 | def test_send_recv(self):
11 | socket = mock.Mock()
12 | socket.recv.return_value = 'Some data'
13 | echo_data(socket)
14 | socket.send.assert_called_with('Some data')
15 |
16 | if __name__ == '__main__':
17 | unittest.main()
18 |
--------------------------------------------------------------------------------
/19-Testing/test9.py:
--------------------------------------------------------------------------------
1 | import doctest
2 |
3 | def concat(values):
4 | '''Concatenate multiple strings
5 |
6 | >>> concat(['foo', 'bar', 'baz'])
7 | 'foobarbaz'
8 | >>> concat(['foo', ' bar ', 'baz'])
9 | 'foo bar baz'
10 | '''
11 | result = ''
12 | for value in values:
13 | result += value
14 | return result
15 |
16 | def average(values):
17 | """Computes the arithmetic mean of a list of numbers.
18 |
19 | >>> print average([20, 30, 70])
20 | 40.0
21 | """
22 | return sum(values, 0.0) / len(values)
23 |
24 | if __name__ == '__main__':
25 | doctest.testmod() # automatically validate the embedded tests
26 |
--------------------------------------------------------------------------------
/19-Testing/test_directory.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import directory
3 |
4 | class TestEmptyDirectory(unittest.TestCase):
5 |
6 | def setUp(self):
7 | self.d = directory.Directory()
8 |
9 | def test_add_number(self):
10 | self.d.add_number('name', '111.111.1111')
11 | self.assertEqual(
12 | self.d.lookup_number('name'),
13 | '111.111.1111')
14 |
15 | def test_lookup_unknown_number(self):
16 | self.assertRaises(KeyError, self.d.lookup_number, 'name')
17 |
18 | def test_remove_unknown_number(self):
19 | self.assertRaises(KeyError, self.d.remove_number, 'name')
20 |
21 | def test_repr_has_two_lines(self):
22 | d_repr = repr(self.d)
23 | self.assertEqual(len(d_repr.splitlines()), 2)
24 |
25 | class TestNonemptyDirectory(unittest.TestCase):
26 |
27 | def setUp(self):
28 | self.d = directory.Directory()
29 | self.d.add_number('name', '111.111.1111')
30 |
31 | def test_lookup_number(self):
32 | self.assertEqual(
33 | self.d.lookup_number('name'),
34 | '111.111.1111')
35 |
36 | def test_remove_number(self):
37 | self.d.remove_number('name')
38 | self.assertRaises(KeyError, self.d.lookup_number, 'name')
39 |
40 | def test_repr_has_three_lines(self):
41 | d_repr = repr(self.d)
42 | self.assertEqual(len(d_repr.splitlines()), 3)
43 |
44 | if __name__ == '__main__':
45 | unittest.main()
46 |
--------------------------------------------------------------------------------
/19-Testing/testa.py:
--------------------------------------------------------------------------------
1 | import doctest
2 |
3 | def average(values):
4 | """Computes the arithmetic mean of a list of numbers.
5 |
6 | >>> print average([20, 30, 70])
7 | 40.0
8 | """
9 | return sum(values, 0.0) / len(values)
10 |
11 | if __name__ == '__main__':
12 | doctest.testmod() # automatically validate the embedded tests
13 |
--------------------------------------------------------------------------------
/20-MoreModules.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/20-MoreModules.pdf
--------------------------------------------------------------------------------
/20-MoreModules_files/base.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Primary styles
3 | *
4 | * Author: IPython Development Team
5 | */
6 |
7 |
8 | body {
9 | background-color: white;
10 | /* This makes sure that the body covers the entire window and needs to
11 | be in a different element than the display: box in wrapper below */
12 | position: absolute;
13 | left: 0px;
14 | right: 0px;
15 | top: 0px;
16 | bottom: 0px;
17 | overflow: hidden;
18 | }
19 |
20 |
21 | div#header {
22 | /* Initially hidden to prevent FLOUC */
23 | display: none;
24 | position: relative;
25 | height: 40px;
26 | padding: 5px;
27 | margin: 0px;
28 | width: 100%;
29 | }
30 |
31 | span#ipython_notebook {
32 | position: absolute;
33 | padding: 2px 2px 2px 5px;
34 | }
35 |
36 | span#ipython_notebook h1 img {
37 | font-family: Verdana, "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
38 | height: 24px;
39 | text-decoration:none;
40 | display: inline;
41 | color: black;
42 | }
43 |
44 | div#main_app {
45 | /* Initially hidden to prevent FLOUC */
46 | display: none;
47 | width: 100%;
48 | position: relative;
49 | }
50 |
51 | .ui-button .ui-button-text {
52 | padding: 0.2em 0.8em;
53 | font-size: 77%;
54 | }
55 |
56 | span#login_widget {
57 | float: right;
58 | }
59 |
60 | /* generic class for hidden objects */
61 | .hidden {
62 | display: none;
63 | }
64 |
--------------------------------------------------------------------------------
/20-MoreModules_files/codemirror.css:
--------------------------------------------------------------------------------
1 | .CodeMirror {
2 | line-height: 1em;
3 | font-family: monospace;
4 | }
5 |
6 | .CodeMirror-scroll {
7 | overflow: auto;
8 | height: 300px;
9 | /* This is needed to prevent an IE[67] bug where the scrolled content
10 | is visible outside of the scrolling box. */
11 | position: relative;
12 | }
13 |
14 | .CodeMirror-gutter {
15 | position: absolute; left: 0; top: 0;
16 | z-index: 10;
17 | background-color: #f7f7f7;
18 | border-right: 1px solid #eee;
19 | min-width: 2em;
20 | height: 100%;
21 | }
22 | .CodeMirror-gutter-text {
23 | color: #aaa;
24 | text-align: right;
25 | padding: .4em .2em .4em .4em;
26 | }
27 | .CodeMirror-lines {
28 | padding: .4em;
29 | }
30 |
31 | .CodeMirror pre {
32 | -moz-border-radius: 0;
33 | -webkit-border-radius: 0;
34 | -o-border-radius: 0;
35 | border-radius: 0;
36 | border-width: 0; margin: 0; padding: 0; background: transparent;
37 | font-family: inherit;
38 | font-size: inherit;
39 | padding: 0; margin: 0;
40 | white-space: pre;
41 | word-wrap: normal;
42 | }
43 |
44 | .CodeMirror textarea {
45 | font-family: inherit !important;
46 | font-size: inherit !important;
47 | }
48 |
49 | .CodeMirror-cursor {
50 | z-index: 10;
51 | position: absolute;
52 | visibility: hidden;
53 | border-left: 1px solid black !important;
54 | }
55 | .CodeMirror-focused .CodeMirror-cursor {
56 | visibility: visible;
57 | }
58 |
59 | span.CodeMirror-selected {
60 | background: #ccc !important;
61 | color: HighlightText !important;
62 | }
63 | .CodeMirror-focused span.CodeMirror-selected {
64 | background: Highlight !important;
65 | }
66 |
67 | .CodeMirror-matchingbracket {color: #0f0 !important;}
68 | .CodeMirror-nonmatchingbracket {color: #f22 !important;}
69 |
--------------------------------------------------------------------------------
/20-MoreModules_files/default.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-keyword {color: #708;}
2 | .cm-s-default span.cm-atom {color: #219;}
3 | .cm-s-default span.cm-number {color: #164;}
4 | .cm-s-default span.cm-def {color: #00f;}
5 | .cm-s-default span.cm-variable {color: black;}
6 | .cm-s-default span.cm-variable-2 {color: #05a;}
7 | .cm-s-default span.cm-variable-3 {color: #0a5;}
8 | .cm-s-default span.cm-property {color: black;}
9 | .cm-s-default span.cm-operator {color: black;}
10 | .cm-s-default span.cm-comment {color: #a50;}
11 | .cm-s-default span.cm-string {color: #a11;}
12 | .cm-s-default span.cm-string-2 {color: #f50;}
13 | .cm-s-default span.cm-meta {color: #555;}
14 | .cm-s-default span.cm-error {color: #f00;}
15 | .cm-s-default span.cm-qualifier {color: #555;}
16 | .cm-s-default span.cm-builtin {color: #30a;}
17 | .cm-s-default span.cm-bracket {color: #cc7;}
18 | .cm-s-default span.cm-tag {color: #170;}
19 | .cm-s-default span.cm-attribute {color: #00c;}
20 |
--------------------------------------------------------------------------------
/20-MoreModules_files/markdown.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-header {color: #2f2f4f; font-weight:bold;}
2 | .cm-s-default span.cm-code {color: #666;}
3 | .cm-s-default span.cm-quote {color: #090;}
4 | .cm-s-default span.cm-list {color: #a50;}
5 | .cm-s-default span.cm-hr {color: #999;}
6 | .cm-s-default span.cm-linktext {color: #00c; text-decoration: underline;}
7 | .cm-s-default span.cm-linkhref {color: #00c;}
8 | .cm-s-default span.cm-em {font-style: italic;}
9 | .cm-s-default span.cm-strong {font-weight: bold;}
10 | .cm-s-default span.cm-emstrong {font-style: italic; font-weight: bold;}
11 |
--------------------------------------------------------------------------------
/20-MoreModules_files/prettify.css:
--------------------------------------------------------------------------------
1 | .pln{
2 | color:#000
3 | }
4 |
5 | @media screen{
6 | .str{
7 | color:#BA2121;
8 | }.kwd{
9 | color:#008000;
10 | font-weight: bold;
11 | }.com{
12 | color:#408080;
13 | font-style: italic;
14 | }.typ{
15 | color:#606
16 | }.lit{
17 | color:#666666;
18 | }.pun,.opn,.clo{
19 | }.tag{
20 | color:#008
21 | }.atn{
22 | color:#606
23 | }.atv{
24 | color:#080
25 | }.dec,.var{
26 | color:#606
27 | }.fun{
28 | color:red
29 | }
30 | }
31 |
32 | pre.prettyprint{
33 | padding:2px;
34 | border:1px solid #888
35 | }
36 |
37 | ol.linenums{
38 | margin-top:0;
39 | margin-bottom:0
40 | }
41 |
42 | li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{
43 | list-style-type:none
44 | }
45 |
46 | li.L1,li.L3,li.L5,li.L7,li.L9{
47 | background:#eee
48 | }
--------------------------------------------------------------------------------
/20-MoreModules_files/rst.css:
--------------------------------------------------------------------------------
1 | .cm-s-default span.cm-emphasis {
2 | font-style: italic;
3 | }
4 |
5 | .cm-s-default span.cm-strong {
6 | font-weight: bold;
7 | }
8 |
9 | .cm-s-default span.cm-interpreted {
10 | color: #33cc66;
11 | }
12 |
13 | .cm-s-default span.cm-inline {
14 | color: #3399cc;
15 | }
16 |
17 | .cm-s-default span.cm-role {
18 | color: #666699;
19 | }
20 |
21 | .cm-s-default span.cm-list {
22 | color: #cc0099;
23 | font-weight: bold;
24 | }
25 |
26 | .cm-s-default span.cm-body {
27 | color: #6699cc;
28 | }
29 |
30 | .cm-s-default span.cm-verbatim {
31 | color: #3366ff;
32 | }
33 |
34 | .cm-s-default span.cm-comment {
35 | color: #aa7700;
36 | }
37 |
38 | .cm-s-default span.cm-directive {
39 | font-weight: bold;
40 | color: #3399ff;
41 | }
42 |
43 | .cm-s-default span.cm-hyperlink {
44 | font-weight: bold;
45 | color: #3366ff;
46 | }
47 |
48 | .cm-s-default span.cm-footnote {
49 | font-weight: bold;
50 | color: #3333ff;
51 | }
52 |
53 | .cm-s-default span.cm-citation {
54 | font-weight: bold;
55 | color: #3300ff;
56 | }
57 |
58 | .cm-s-default span.cm-replacement {
59 | color: #9933cc;
60 | }
61 |
62 | .cm-s-default span.cm-section {
63 | font-weight: bold;
64 | color: #cc0099;
65 | }
66 |
67 | .cm-s-default span.cm-directive-marker {
68 | font-weight: bold;
69 | color: #3399ff;
70 | }
71 |
72 | .cm-s-default span.cm-verbatim-marker {
73 | font-weight: bold;
74 | color: #9900ff;
75 | }
76 |
--------------------------------------------------------------------------------
/ClassNotes.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/ClassNotes.pdf
--------------------------------------------------------------------------------
/CodeExamples.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/CodeExamples.pdf
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/200340373-1-small-103.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/200340373-1-small-103.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/Synapp logo - Color-169.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/Synapp logo - Color-169.png
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/Synapp logo - Color-small-170.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/Synapp logo - Color-small-170.png
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt0@2x-146.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt0@2x-146.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt10@2x-156.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt10@2x-156.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt11@2x-157.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt11@2x-157.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt12@2x-158.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt12@2x-158.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt13@2x-159.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt13@2x-159.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt1@2x-147.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt1@2x-147.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt2@2x-148.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt2@2x-148.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt3@2x-149.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt3@2x-149.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt4@2x-150.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt4@2x-150.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt5@2x-151.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt5@2x-151.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt6@2x-152.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt6@2x-152.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt7@2x-153.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt7@2x-153.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt8@2x-154.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt8@2x-154.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/mt9@2x-155.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/mt9@2x-155.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/pasted-image-177.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/pasted-image-177.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/pasted-image-192.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/pasted-image-192.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/pasted-image-small-193.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/pasted-image-small-193.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st0-104.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st0-104.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st1-195.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st1-195.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st13-117.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st13-117.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st14-118.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st14-118.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st15-119.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st15-119.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st16-120.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st16-120.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st18-122.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st18-122.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st19-123.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st19-123.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st2-106.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st2-106.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st2-107.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st2-107.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st2-116.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st2-116.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st2-397.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st2-397.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st20-124.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st20-124.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st20-398.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st20-398.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st21-125.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st21-125.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st22-126.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st22-126.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st23-127.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st23-127.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st24-128.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st24-128.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st25-129.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st25-129.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st26-130.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st26-130.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st27-131.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st27-131.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st28-132.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st28-132.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st29-133.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st29-133.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st3-280.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st3-280.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st30-134.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st30-134.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st31-135.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st31-135.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st32-136.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st32-136.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st33-137.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st33-137.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st34-138.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st34-138.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st35-139.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st35-139.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st36-140.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st36-140.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st37-141.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st37-141.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st38-142.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st38-142.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st39-143.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st39-143.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st4-109.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st4-109.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st40-144.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st40-144.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st41-145.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st41-145.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st5-112.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st5-112.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st5-113.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st5-113.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st5-115.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st5-115.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st6-110.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st6-110.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st6-111.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st6-111.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st6-114.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st6-114.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st6-396.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st6-396.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Data/st7-360.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Data/st7-360.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Index.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Index.zip
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Metadata/BuildVersionHistory.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | local build-Jun 29 2012
6 | local build-Oct 16 2012
7 | M6.2-1861-1
8 |
9 |
10 |
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Metadata/DocumentIdentifier:
--------------------------------------------------------------------------------
1 | EF07B04E-78A1-4CBF-A823-54CE3769307A
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/Metadata/Properties.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/Metadata/Properties.plist
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/preview-micro.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/preview-micro.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/preview-web.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/preview-web.jpg
--------------------------------------------------------------------------------
/FastTrackToPython 20140522.key/preview.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython 20140522.key/preview.jpg
--------------------------------------------------------------------------------
/FastTrackToPython.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/FastTrackToPython.pdf
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fast Track to Python
2 |
3 | This is the home of the Fast Track to Python class files.
4 |
5 | ## Setup Instructions
6 |
7 | My examples will all be running in an Ubuntu virtual machine managed by Vagrant.
8 | If you want to have the exact same environment as I'm running (same version of
9 | Python, including IPython and the IPython notebook), you'll want to install the following:
10 |
11 | - [VirtualBox](https://www.virtualbox.org/)
12 | - [Vagrant 1.6.2](http://www.vagrantup.com/)
13 |
14 | Once you have these, you'll want to clone this repository and run a couple of commands:
15 |
16 | ~~~~
17 | git clone https://github.com/rick446/fasttrack-python.git
18 | cd fasttrack-python
19 | vagrant up # This imports and boots the virtual machine
20 | vagrant ssh # This logs you into the virtual machine
21 |
22 | vagrant@precise64~$ ./src/fasttrack-python/setup-environ.bash
23 | vagrant@precise64~$ exit
24 | ~~~~
25 |
26 | ## Recordings
27 |
28 | The videos will be posted here as they become available.
29 |
30 | - [Session 1](https://www.youtube.com/watch?v=CfbjnC_oL3M)
31 | - [Session 2](https://www.youtube.com/watch?v=FjwKuVQnF4c)
32 | - [Session 3](https://www.youtube.com/watch?v=zsdzvTv4qdk)
33 | - [Session 4](https://www.youtube.com/watch?v=iya4_KHKuYQ)
34 | - [Session 5](https://www.youtube.com/watch?v=b-7bdyb2F1c) Sorry, missing the screenshare :-(
--------------------------------------------------------------------------------
/fabfile.py:
--------------------------------------------------------------------------------
1 | from cStringIO import StringIO
2 |
3 | import codecs
4 |
5 | import markdown
6 | from path import path as pathpy
7 | from fabric.api import *
8 | from fabric.contrib.console import confirm
9 |
10 | env.user = 'wan_admin'
11 | env.hosts = [ 'arborian.com' ]
12 | env.forward_agent = True
13 |
14 | def upload(name):
15 | with codecs.open(name + '.md', mode='r', encoding='utf-8') as fp:
16 | lines = fp.readlines()
17 | text = ''.join(lines)
18 | html = markdown.markdown(text, [ 'extra', 'codehilite' ])
19 | sio = StringIO(html.encode('utf-8'))
20 | put(sio, '~/class.arborian.com/fasttrack-python/%s.html' % name)
21 | put(StringIO('''
22 |
23 |
24 |
25 |
26 |
27 |
34 |
35 |
36 |
37 |
38 | ''' % name), '~/class.arborian.com/fasttrack-python/%s.shtml' % name)
39 |
40 | def upload_html():
41 | for htmlfile in pathpy('.').glob('*.html'):
42 | print htmlfile.basename()
43 | put(htmlfile, '~/class.arborian.com/fasttrack-python/%s' % htmlfile.basename())
44 |
45 |
--------------------------------------------------------------------------------
/index.md:
--------------------------------------------------------------------------------
1 | # Fast Track to Python
2 |
3 | - [Slides][slides]
4 | - [Code][code] [(archive of all code examples)][archive]
5 |
6 | ## Day 1 notes
7 |
8 | - [Basic Python Syntax][01-basic-syntax]
9 | - [Builtin Functions][02-builtins]
10 | - [File I/O][03-fileio]
11 | - [Using Modules][04-modules]
12 | - [Strings][05-strings]
13 | - [Regular Expressions][06-regex]
14 |
15 | ## Day 2 notes
16 |
17 | - [Python Functions][07-functions]
18 | - [Advanced Python Functions][08-advanced-functions]
19 | - [Logging in Python][09-logging]
20 | - [Object Oriented Programming (I)][10-oop1]
21 | - [Object Oriented Programming (II)][11-oop2]
22 | - [Python Decorators][12-decorators]
23 | - [Generators and Iterators][13-generators]
24 | - [Context Managers][14-context]
25 |
26 | ## Day 3 notes
27 | - [Using Subprocesses][17-subprocess]
28 | - [Other Modules and Builtins][20-moremods]
29 |
30 | [slides]: ./FastTrackToPython.pdf
31 | [code]: ./code/fasttracktopython/
32 | [archive]: ./code/CodeExamples.tar.gz
33 | [01-basic-syntax]: ./01-BasicPythonSyntax.html
34 | [02-builtins]: ./02-Builtins.html
35 | [03-fileio]: ./03-FileIO.html
36 | [04-modules]: ./04-UsingModules.html
37 | [05-strings]: ./05-Strings.html
38 | [06-regex]: ./06-Regex.html
39 | [07-functions]: ./07-Functions.html
40 | [08-advanced-functions]: ./08-AdvancedFunctions.html
41 | [09-logging]: ./09-Logging.html
42 | [10-oop1]: ./10-OOP1.html
43 | [11-oop2]: ./11-OOP2.html
44 | [12-decorators]: ./12-Decorators.html
45 | [13-generators]: ./13-GeneratorsAndIterators.html
46 | [14-context]: ./14-ContextManagers.html
47 | [17-subprocess]: ./17-Subprocess.html
48 | [20-moremods]: ./20-MoreModules.html
49 |
--------------------------------------------------------------------------------
/mypdf.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/mypdf.pdf
--------------------------------------------------------------------------------
/output.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/output.pdf
--------------------------------------------------------------------------------
/pdfmarks.ps:
--------------------------------------------------------------------------------
1 | [/Page 1 /View [/XYZ null null null] /Title (Basic Python Syntax) /OUT pdfmark
2 | [/Page 11 /View [/XYZ null null null] /Title (Builtins) /OUT pdfmark
3 | [/Page 19 /View [/XYZ null null null] /Title (File I/O) /OUT pdfmark
4 | [/Page 22 /View [/XYZ null null null] /Title (Using Modules) /OUT pdfmark
5 | [/Page 34 /View [/XYZ null null null] /Title (Strings) /OUT pdfmark
6 | [/Page 39 /View [/XYZ null null null] /Title (Regular Expressions) /OUT pdfmark
7 | [/Page 43 /View [/XYZ null null null] /Title (Functions) /OUT pdfmark
8 | [/Page 46 /View [/XYZ null null null] /Title (Advanced Functions) /OUT pdfmark
9 | [/Page 52 /View [/XYZ null null null] /Title (Object Oriented Programming I) /OUT pdfmark
10 | [/Page 54 /View [/XYZ null null null] /Title (Object Oriented Programming II) /OUT pdfmark
11 | [/Page 59 /View [/XYZ null null null] /Title (Decorators) /OUT pdfmark
12 | [/Page 64 /View [/XYZ null null null] /Title (Generators and Iterators) /OUT pdfmark
13 | [/Page 68 /View [/XYZ null null null] /Title (Context Managers) /OUT pdfmark
14 | [/Page 72 /View [/XYZ null null null] /Title (Subprocess Module) /OUT pdfmark
15 | [/Page 76 /View [/XYZ null null null] /Title (More Modules and Builtins) /OUT pdfmark
16 |
17 |
18 |
--------------------------------------------------------------------------------
/setup-environ.bash:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | sudo apt-get update
5 | sudo apt-get install -y python-virtualenv python-dev libzmq-dev
6 | virtualenv env
7 | echo "source ~/env/bin/activate" >> .bashrc
8 | source ~/env/bin/activate
9 | pip install ipython[notebook]
10 |
--------------------------------------------------------------------------------
/test.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rick446/fasttrack-python/cb4cafebbd04e9b66353fec4919f9cd0e161e84e/test.pdf
--------------------------------------------------------------------------------