Handle either a list or single integer as an argument

后端 未结 6 879
萌比男神i
萌比男神i 2020-12-05 01:59

A function should select rows in a table based on the row name (column 2 in this case). It should be able to take either a single name or a list of names as arguments and ha

6条回答
  •  孤城傲影
    2020-12-05 02:23

    A simple wrapper could do, to handle list or single object case

      def wrap_list(val):
        if type(val) is list:
          return val
        return [val] 
    

提交回复
热议问题