LPTHW Exercise 13-14: Parameters, Unpacking, Variables, Prompting and Passing

Learn Python the Hard Way by Zed Shaw .: Add extra libraries or modules of code to a program using import and supply arguments to a Python script on the command line using argv.

The textwrap module enables indenting a block quote for cleaner code but moving to left-margin at print() time:

import sys
import textwrap

script, firstName, lastName = sys.argv

message = """
    (O< .: Learn Python The Hard Way
    (/)_
    """
print(message)
print('{} {} ' + ', author of' + '.' * 10).format(firstName, lastName)
print(textwrap.dedent(message))

Output:

$ python e13.2.py Zed Shaw

    (O< .: Learn Python The Hard Way
    (/)_

Zed Shaw , author of..........

(O< .: Learn Python The Hard Way
(/)_

$

More • pythonprogramming