[CentralOH] 2014-11-21 道場 Scribbles 落書/惡文?

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Tue Nov 25 01:17:35 CET 2014


Need to come up with a list of stuff for beginners.

    Where to start to learn Python.
    How to install it, especially for Microsoft Windows.
    What other tools and practices are good to have and do.
        virtualenv (and/or conda?)
        editors that are designed to be fast to use without using a mouse
            vim or emacs!!!
                For windows, which version of emacs should one use?
        version control:
            git (slam dunk!)
            mercurial is good also, but git just dominates mindshare
            Subversion (aka SVN) is a difficult, awkward, and limiting to use
                (watch: http://www.youtube.com/watch?v=4XpnKHJAok8)
                If SVN is a fait accompli where you work, then import the SVN
                repository in your private git repository, do your real work in
                git, then export some git versions to SVN respository. Someone
                else will have to fill in the details on how best to do that. 
        tmux or screen are handy
        ssh (or putty for Microsoft Windows)

It seems that a good way to learn Python is to get a quick start by using the
freebie on-line tutorials, then read Learning Python to fill in the gaps and
correct errors and bad advice. It seems that all the freebie on-line tutorials
have weaknesses. It can be good to study more than one of them at the same
time, to compare and contrast them. If you get stuck on one of them, try a
different tutorial. 

    Zed Shaw
    Learn Python The Hard Way
    http://learnpythonthehardway.org/

    How to Think Like a Computer Scientist
    http://openbookproject.net/thinkcs/python/english2e/
    http://interactivepython.org/courselib/static/thinkcspy/index.html

Then study Learning Python by Mark Lutz because it is comprehensive, has few
errors, and is gentle for beginners. Learning Python is careful to progress
incrementally from the simple to the complex, and is careful to not talk about
things that have not been defined, except in a few cases where they have to.
One could write a comprehensive book that is small, but it would be hard for
beginners to follow. To be comprehensive _and_ gentle, it is a HUGE book. The
huge size of the book intimidates people, especially beginners, but it should
not. It is huge _because_ it is gentle.

I have heard good things about Invent Your Own Computer Games with Python, 
but have no experience with it. It is not a substitute for Learning Python.
http://inventwithpython.com/

slice & dice: can insert into and delete from lists

    >>> a = list(range(5))
    >>> a
    [0, 1, 2, 3, 4]
    >>> a[2:4]
    [2, 3]
    >>> a[2:4] = []  # Deletes from middle of list.
    >>> a
    [0, 1, 4]
    >>> a[2:2]
    []
    >>> a[2:2] = ['hello', 'world']  # Inserts in middle list.
    >>> a
    [0, 1, 'hello', 'world', 4]  # Appends to end of list. (.append() is better)
    >>> a[5:5] = ['extra']
    >>> a
    [0, 1, 'hello', 'world', 4, 'extra']
    >>> a[0:0] = ['ante']  # Inserts at beginning.
    >>> a
    ['ante', 0, 1, 'hello', 'world', 4, 'extra']
    >>> 

    (I wonder how much of that reinvents what Jason did in a lightning talk 
    a few months ago.)

If one wants to start at 1 and do a loop n times, 
the common code pattern has a <= n test

    >>> def do_n_times_starting_at_one(n):
    ...     i = 1
    ...     while i <= n:
    ...         print i
    ...         i += 1
    ... 
    >>> do_n_times_starting_at_one(3)
    1
    2
    3
    >>> 

But starting at one, is usually _not_ what one wants to do in computers.

very common code pattern in many programming languages:

    loop executes n times
    first value is zero (NOT 1)
    last value in loop is n-1 (NOT n)
    test is < n.
        comparison is <, not <=
        compared value is n, not n-1
    next value is made at end of loop

    >>> def do_n_times(n):
    ...     i = 0
    ...     while i < n:
    ...         print i
    ...         i += 1
    ... 
    >>> do_n_times(3)
    0
    1
    2
    >>> 

A more Pythonic way of doing the above follows.

    >>> def do_n_times(n):
    ...     for i in range(n):
    ...         print i
    ... 
    >>> do_n_times(3)
    0
    1
    2
    >>> 

i is often used to index into data that one is going through.
However in Python, one can often go through data one thing at a time,
without have an index,
so one often does something like the following fake Python code:

    >>> def do_stuff(data_collection):
    ...     for thing in data_collection:
    ...         print thing
    ... 
    >>> do_stuff(['hello', 3.14159+2.71828j, True, 42])
    hello
    (3.14159+2.71828j)
    True
    42
    >>> 

http://www.vim.org/download.php#pc

Some people like sublime text much. It's proprietary.
wp:Sublime Text

Indent/unindent
    EMACS
        ^C>
        ^C<
    vim
        >>
        <<

Can yaml do ordered dicts? Yup. They be called "ordered maps" for YAML.
http://yaml.org/type/omap.html
http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml-mappings-as-ordereddicts

Compay Segundo - Buena Vista Social Club
youtube.com/watch?v=2h2fdZ6XpR8

Tech Talk: Linus Torvalds on git
http://www.youtube.com/watch?v=4XpnKHJAok8

tmux in cygwin

Important for TDD
The Clean Architecture in Python
http://pyvideo.org/video/2840/the-clean-architecture-in-python

Maybe conda is OK to use instead of virtualenv.
http://technicaldiscovery.blogspot.com/2013/12/why-i-promote-conda.html

wp:Ferrari 550

http://www.checkio.org/ (requires javascript)

https://github.com/pybokeh

Someone had a very cool way of teaching/playing with C++ by using
Ipython Notebook.

    %load_ext cpp stuff

http://www.hubspot.com/

>>> 'foo %(ptyhon)s bar' % {'ptyhon': 'hello', 'big': 9999, 'pi': 3.14159}
'foo hello bar'

One person likes:
Python Power!: The Comprehensive Guide - Python

http://www.meetup.com/Papers-We-Love-Columbus/events/189943332/
https://github.com/papers-we-love/papers-we-love
https://github.com/papers-we-love/papers-we-love/blob/master/design/out-of-the-tar-pit.pdf?raw=true

wp:CiviCRM
wp:Affero General Public License
wp:Bradley M. Kuhn

http://itrevolution.com/the-history-of-devops/

never sleeps
wp:Mechanical advantage
wp:Gear ratio
wp:Bicycle chain
wp:sprocket
wp:Rust (programming language)


More information about the CentralOH mailing list