[Courses] [python] Lesson 8: Extras

Leslie leslie.brothers at verizon.net
Fri Aug 12 03:56:09 UTC 2011


re: Homework for Lesson 8
	I decided to do a very simple exercise to practice optional arguments
and subprocess.
-Leslie


import subprocess

class Bird:
	location = ''
	tax_name = ''
	def __init__(self, name, location="unknown", tax_name="unknown"):
		self.name = name
		self.location = location
		self.tax_name = tax_name
		print "The bird's name is",name+"."		
		print "Its habitat is",location+"."
		print "Its taxonomic name is",tax_name+".\n"

Bird("oriole", "California", "Icterus parisorum")
Bird("indigo bunting", location="Mexico")
print "Wait a moment.."
p = subprocess.Popen(["sleep", "5"])
p.wait()
print "OK, now we're done with birds!"



More information about the Courses mailing list