2015-05-27 41 views
1

我看到了在龍捲風中設置定義的兩種方法。tornado.options.define使用部分和不使用partial有什麼區別?

import tornado.options 
def define_web(hidden=False): 

    define = partial(tornado.options.define, group='Web', hidden=hidden) 
    define('thread', False, type=bool, 
     help='threading') 

,並沒有使用部分

from tornado.options import options, define 

def define_web(hidden=False): 
    define('thread', False, type=bool, 
     help='threading') 

所以我想知道有什麼區別,什麼是使用諧音

回答

0

partial讓你一次指定某些參數,並反覆使用它們的優勢。在你的第一個例子中,thread選項有group="Web", hidden=hidden,而在第二個例子中,不使用這些參數。

相關問題