zoukankan      html  css  js  c++  java
  • python


    class Utc(tzinfo):
        "provide a tz concrete class"
        def __init__(self, offset = 0):
            self._offset = offset
        def utcoffset(self, dt):
            return timedelta(hours=self._offset)
        def tzname(self, dt):
            return "UTC +%s" % self._offset
        def dst(self, dt):
            return timedelta(hours=self._offset)

    def curry(x, argc=None):
        if argc is None:
            argc = x.func_code.co_argcount
        def p(*a):
            if len(a) == argc:
                return x(*a)
            def q(*b):
                return x(*(a + b))
            return curry(q, argc - len(a))
        return p
    
    @curry
    def myfun(a,b,c):
        print '%d-%d-%d' % (a,b,c)
    
    
    
    myfun(11,22,33)
    myfun(44,55)(66)
    myfun(77)(88)(99)
    http://www.cnblogs.com/goodspeed/archive/2011/11/07/python_tzinfo.html
    https://mtomassoli.wordpress.com/2012/03/18/currying-in-python/
  • 相关阅读:
    CentOS 7 安装java 环境
    CentOS 7 替换网易yum 源
    九度:题目1553:时钟
    Maximum Subarray
    职场细节
    poj2524 Ubiquitous Religions
    九度 1526:朋友圈
    程序载入
    设备管理
    操作系统系列
  • 原文地址:https://www.cnblogs.com/jvava/p/4875305.html
Copyright © 2011-2022 走看看