[CentralOH] 2015-07-18 道場 Scribbles 落書/惡文? July 31 Sprints; combat; minio; bash list; relativity; $* & "$@"; olp; pep8 mla; py.test; varargs; 3rd Man; flash

jep200404 at columbus.rr.com jep200404 at columbus.rr.com
Sat Jul 18 20:02:19 CEST 2015

We will likely combine with Friday sprints of PyOhio on July 31.

CodeCombat - Learn how to code by playing a game


script foo: list variables in bash

    [test at dojo ~]$ cat array.sh 

    function showfoo()
        echo "$@"
        echo "len(foo) = ${#foo[@]}"
        for arg in "${foo[@]}"; do
            echo "foo[$i] = '$arg'"
            i=`expr $i + 1`

    showfoo before declare
    declare -a foo
    showfoo after declare

    foo[0]='hello world'
    showfoo after first assignment
    foo[1]='bacon spam'
    showfoo after second assignment
    foo[${#foo[@]}]='appended another'
    showfoo after third assignment
    foo[${#foo[@]}]='and appended another'
    showfoo after fourth assignment
    [test at dojo ~]$ ./array.sh 
    before declare
    len(foo) = 0
    after declare
    len(foo) = 0
    after first assignment
    len(foo) = 1
    foo[0] = 'hello world'
    after second assignment
    len(foo) = 2
    foo[0] = 'hello world'
    foo[1] = 'bacon spam'
    after third assignment
    len(foo) = 3
    foo[0] = 'hello world'
    foo[1] = 'bacon spam'
    foo[2] = 'appended another'
    after fourth assignment
    len(foo) = 4
    foo[0] = 'hello world'
    foo[1] = 'bacon spam'
    foo[2] = 'appended another'
    foo[3] = 'and appended another'
    [test at dojo ~]$ 

General Relativity in Python

Bourne Shell: $* versus "$@"

    [test at dojo 1]$ ll
    total 4
    -rwxr-x---. 1 test jep 222 Jul 16 19:53 starat.sh
    [test at dojo 1]$ head -50 -v starat.sh 
    ==> starat.sh <==

    echo "There are $# arguments."
    echo '$* yields the following'
    for arg in $*; do
        echo "    arg is '$arg'"
    echo '"$@" yields the following'
    for arg in "$@"; do
        echo "    arg is '$arg'"
    [test at dojo 1]$ ./starat.sh 'spam' 'hello world' 'who am i'
    There are 3 arguments.

    $* yields the following
        arg is 'spam'
        arg is 'hello'
        arg is 'world'
        arg is 'who'
        arg is 'am'
        arg is 'i'

    "$@" yields the following
        arg is 'spam'
        arg is 'hello world'
        arg is 'who am i'
    [test at dojo 1]$ 

our lady of peace festival

What Is MLA Style?
MLA http://www.mla.org/style

Mostly did refactoring.
Tried to add TDD at end. Did not work. 
Maybe issues with environment on Macbook.
virtualenv env -p `which python3`
    py.test -f . was very unhappy complaining about not having permissions for 
    Adobe Flash stuff (that we were not trying to use)
virtualenv env -p `which python3` --no-site-packages
    py.test -f . was much happier
Afterwards, realized that tuple was a bad name for a variable.

Varargs unpacking: pass arbitrarily many positional or keyword arguments
Start with "Arbitrary Argument Examples"
page 534 of Learning Python 5th edition.

The Third Man

Adobe released the security update for the Linux version of their Flash player.
download flash for linux

More information about the CentralOH mailing list