本文整理汇总了Python中string.Template.init方法的典型用法代码示例。如果您正苦于以下问题:Python Template.init方法的具体用法?Python Template.init怎么用?Python Template.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类string.Template
的用法示例。
在下文中一共展示了Template.init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from string import Template [as 别名]
# 或者: from string.Template import init [as 别名]
print ("m1.members =", m1.members)
print ("m2.members =", m2.members)
class Filter:
def init(self):
self.blocked = []
def filter(self, sequence):
return [x for x in sequence if x not in self.blocked]
class SPAMFilter(Filter):
def init(self):
self.blocked = ['SPAM']
f = Filter()
f.init()
print ("f.filter([1,2,3]) =", f.filter([1,2,3]))
s = SPAMFilter()
s.init()
print (s.filter(['SPAM', 'SPAM', 'SPAM', 'SPAM', 'eggs', 'bacon', 'SPAM']))
# investigate Inheritance
# is subclass?
print (issubclass(SPAMFilter, Filter))
print (issubclass(Filter, SPAMFilter))
# is baseclass?
print (SPAMFilter.__bases__)
print (Filter.__bases__)
# is instance?
s = SPAMFilter()
print (isinstance(s, Filter))
print (isinstance(s, str))
# belong to class?
print (s.__class__)