import html
def make_tagged(text, tag):
return '<{0}>{1}</{0}>'.format(tag, html.escape(text))
def repeat(what, count, separator) : return ((what + separator)*count)[:-len(separator)]
import functools
def statically_typed(*types, return_type=None):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
if len(args) > len(types):
raise ValueError('too many arguments')
elif len(args) < len(types):
raise ValueError('too few arguments')
for i, (type_, arg) in enumerate(zip(types, args)):
if not isinstance(type_, arg):
raise ValueError('argument {} must be of type {}'.format(i, type_.__name__))
result = func(*args, **kwargs)
if return_type is not None and not isinstance(result, return_type):
raise ValueError('return value must be of type {}'.format(return_type.__name__))
return wrapper
return decorator
@statically_typed(str, str, return_type=str)
def make_tagged(text, tag):
return '<{0}>{1}</{0}>'.format(tag, html.escape(text))
@statically_typed(str, int, str)
def repeat(what, count, separator):
return ((what + separator)*count)[:-len(separator)]
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有