大多数pythonic样式用于具有多个参数的函数调用

时间:2018-05-13 18:39:00

标签: python

哪个更像Pythonic:

第一种方式:

clipboard.set_with_owner (
    clipboard_targets,
    (clipboard, selection_data, info, user_data_or_owner) => {
    print ("clipboard get_func called\n");
    var w = user_data_or_owner as Window;
    File[] files = { w.get_selected_file () };

    switch ( info ) {
        case ClipboardProtocol.TEXT_URI_LIST:
            print ("Received: ");
            string[] uris = {};
            foreach ( var file in files ) {
                print (file.get_uri ());
                print ("\n");
                uris += file.get_uri ();
            }
            selection_data.set_uris (uris);
            break; 

第二种方式:

    self.partitions.append(
        Partition(
            self.current.bottom, self.current.lower, boundary))

1 个答案:

答案 0 :(得分:2)

在我看来,都不是。通常没有理由不将这种逻辑分成两个步骤:

part_obj = Partition(self.current.upper, self.current.top, boundary)
self.partitions.append(part_obj)