AFUL

Exemple

 contents contents next

#!/usr/bin/python

'''hello.py: le programme 'Hello world' bien connu.

Usage: hello.py [-h] [--help] [nom_de_personne]+
'''

import sys, getopt

def usage():
  'Print usage doc and exit.'
  print __doc__
  sys.exit()

try:
  optlist, arglist = getopt.getopt(
    sys.argv[1:], 'h', ['help'])
except:
  usage()
 
for option in optlist:
  if option[0] in ['-h', '--help']:
    usage()
if arglist:
  for arg in arglist:
    print 'Hello %s!' % arg
else:
  print "Hello world!"


Stéfane Fermigier

Transparent n. 7