#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/

"""A tiny Python program to check that Python is working.
Try running this program from the command line like this:
  python hello.py
  python hello.py Alice
That should print:
  Hello World -or- Hello Alice
Try changing the 'Hello' to 'Howdy' and run again.
Once you have that working, you're ready for class -- you can edit
and run Python code; now you just need to learn Python!
"""

import sys
import os
import commands

def List(dir):
  cmd = 'ls -l ' + dir
  (status, output) = commands.getstatusoutput(cmd)
  print 'about to do this:', cmd
  return
  if status:
    print sys.stderr('there was an error:'), output
    sys.exit(1)
  print status, output

def Cat(filename):
 try:
  f = open(filename)
  text = f.read() 
  print '---', filename
  print text
 except IOError:
  print 'IOError', filename

#  filenames = os.listdir(dir)
#  for filename in filenames: 
    #path = os.path.join(dir, filename)
    #print path
    ##print os.path.abspath(path)
    ##print os.path.abspath(filename)
#  print filenames


# Define a main() function that prints a little greeting.

def Hello(name):
  if name == 'Alice' or name == 'Nick':
    name = name + '????'
  else:
    DoesNotExist(name)
  name = name + '!!!!!'
  print 'Hello', name


def Catt(filename):
  f = open(filename, 'r')
  #for line in f: print  line,
  
  #lines = f.readlines()
  #print lines
   
  text = f.read()
  print text

  f.close()

def main():
#  Hello(sys.argv[1])
#  Cat (sys.argv[1])
#   List (sys.argv[1])

  args = sys.argv[1:]
  for arg in args: Cat(arg)

## def main():
  # Get the name from the command line, using 'World' as a fallback.
##  if len(sys.argv) >= 2:
##    name = sys.argv[1]
##  else:
##    name = 'World'
##  print 'Hello', name

# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
  main()

#!/usr/bin/python -tt
# Copyright 2010 Google Inc.
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

# Google's Python Class
# http://code.google.com/edu/languages/google-python-class/

"""A tiny Python program to check that Python is working.
Try running this program from the command line like this:
  python hello.py
  python hello.py Alice
That should print:
  Hello World -or- Hello Alice
Try changing the 'Hello' to 'Howdy' and run again.
Once you have that working, you're ready for class -- you can edit
and run Python code; now you just need to learn Python!
"""

import sys
import os
import commands

def List(dir):
  cmd = 'ls -l ' + dir
  (status, output) = commands.getstatusoutput(cmd)
  print 'about to do this:', cmd
  return
  if status:
    print sys.stderr('there was an error:'), output
    sys.exit(1)
  print status, output

def Cat(filename):
 try:
  f = open(filename)
  text = f.read() 
  print '---', filename
  print text
 except IOError:
  print 'IOError', filename

#  filenames = os.listdir(dir)
#  for filename in filenames: 
    #path = os.path.join(dir, filename)
    #print path
    ##print os.path.abspath(path)
    ##print os.path.abspath(filename)
#  print filenames


# Define a main() function that prints a little greeting.

def Hello(name):
  if name == 'Alice' or name == 'Nick':
    name = name + '????'
  else:
    DoesNotExist(name)
  name = name + '!!!!!'
  print 'Hello', name


def Catt(filename):
  f = open(filename, 'r')
  #for line in f: print  line,
  
  #lines = f.readlines()
  #print lines
   
  text = f.read()
  print text

  f.close()

def main():
#  Hello(sys.argv[1])
#  Cat (sys.argv[1])
#   List (sys.argv[1])

  args = sys.argv[1:]
  for arg in args: Cat(arg)

## def main():
  # Get the name from the command line, using 'World' as a fallback.
##  if len(sys.argv) >= 2:
##    name = sys.argv[1]
##  else:
##    name = 'World'
##  print 'Hello', name

# This is the standard boilerplate that calls the main() function.
if __name__ == '__main__':
  main()

#!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 # Google's Python Class # http://code.google.com/edu/languages/google-python-class/ A tiny Python program to check that Python is working. Try running this program from the command line like this:   python hello.py   python hello.py Alice That should print:   Hello World -or- Hello Alice Try changing the 'Hello' to 'Howdy' and run again. Once you have that working, you're ready for class -- you can edit and run Python code; now you just need to learn Python! #  filenames = os.listdir(dir) #  for filename in filenames: #path = os.path.join(dir, filename) #print path ##print os.path.abspath(path) ##print os.path.abspath(filename) #  print filenames # Define a main() function that prints a little greeting. #for line in f: print  line, #lines = f.readlines() #print lines #  Hello(sys.argv[1]) #  Cat (sys.argv[1]) #   List (sys.argv[1]) ## def main(): # Get the name from the command line, using 'World' as a fallback. ##  if len(sys.argv) >= 2: ##    name = sys.argv[1] ##  else: ##    name = 'World' ##  print 'Hello', name # This is the standard boilerplate that calls the main() function.