First page Back Continue Last page Summary Graphics

Example Python Program

  • import string
  • def printNames(eric): print "Parameter: %(erik)" % locals()
  • class Nothing:
  • def printValue(value): print value
  • def set(self, value): self.value = value
  • def tryToDoSomething(self, value):
  • try:
  • import string
  • if not value:
  • raise RuntimeError, "Hey, there's no value"
  • printNames("eric", "neal", 'michele')
  • except:
  • traceback.print_exc()
  • def setGlobal(value=None):
  • print 'MetaSlash value is:', metaslash
  • metaslash = value
  • useless = Nothing(5)
  • print 'a useless value is:', useless.valeu

    Notes: