本文整理匯總了Python中pages.Page.head方法的典型用法代碼示例。如果您正苦於以下問題:Python Page.head方法的具體用法?Python Page.head怎麽用?Python Page.head使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pages.Page
的用法示例。
在下文中一共展示了Page.head方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from pages import Page [as 別名]
# 或者: from pages.Page import head [as 別名]
def get(self):
p = Page() # p instantiates the class Page
c = Course() # c does the same for the class Course
# Object for Pebble Beach
pebble = Course()
pebble.name = "Pebble Beach"
pebble.yardage = 6828
pebble.course_rating = 75.5 # this attribute is set to private in the contructor but with the getter-setter I am able to set the variable
pebble.par = 72
pebble.slope = 145
pebble.calc_rating()
pebble.bogey_rating = pebble.bogey_rating
# Object for Bethpage Black
bethpage = Course()
bethpage.name = "Bethpage Black"
bethpage.yardage = 7386
bethpage.course_rating = 78.1
bethpage.par = 72
bethpage.slope = 152
bethpage.calc_rating()
print bethpage.bogey_rating
# Object for TPC Sawgrass
sawgrass = Course()
sawgrass.name = "TPC Sawgrass"
sawgrass.yardage = 7215
sawgrass.course_rating = 76.8
sawgrass.par = 72
sawgrass.slope = 155
sawgrass.calc_rating()
print sawgrass.bogey_rating
# Object for Shinecock Hills
shinnecock = Course()
shinnecock.name = "Shinnecock Hills"
shinnecock.yardage = 6781
shinnecock.course_rating = 74.7
shinnecock.par = 72
shinnecock.slope = 140
shinnecock.calc_rating()
print shinnecock.bogey_rating
# Object for Winged Foot
winged = Course()
winged.name = "Winged Foot"
winged.yardage = 7258
winged.course_rating = 76.1
winged.par = 72
winged.slope = 145
winged.calc_rating()
print winged.bogey_rating
# Object for Whistling Straits
straits = Course()
straits.name = "Whistling Straits"
straits.yardage = 7362
straits.course_rating = 77.2
straits.par = 72
straits.slope = 152
straits.calc_rating()
print straits.bogey_rating
p.head = '''
<!doctype html>
<body>
'''
print c.name[0]
# This is a really neat way to dynamically acess and use the objects
if self.request.GET:
p.get_name = self.request.GET['name'] # uses the to dynamically fill the image tag
course = self.request.GET['name'] # gets the click info
c = locals()[course] # refers c to the object course
p.course = c # lets pages.py have access to c
#both of the next lines print depending on conditional result
print "line 88"
print c
self.response.write(p.page_result())
else:
self.response.write(p.print_page())