Python: How to check if a nested list is essentially empty? -


What is the most powerful way of check if list (a elements With the lists, the nested list is essentially empty ? What do I mean by the empty space that there can be elements in the list, but these are also empty lists.

for example For all the following lists should be positive for the emptiness:

 [blist = [alist] # [[]] clist = [alist, alist, alist] # [[] , [], []] List = [blist] # [[[]]]  

< P> If you do not have to iterate through lists, then simple is simple, something like this will work:

  def empty_put (input_list): "" "values ​​in nested lists Iterated through iterated. "" "" Input_list for item: if not (Item, list) or empty_tag (item): The wrong return refund is true  

However, it would be best to exclude the recurring frequency that you might most probably know from somewhere else That is, it does not give any element, so if the mechanism of movements changes, then you need to apply the change to one place. For example, when you need to support arbitrarily nested intertals, or nested decates.

  DF Flaton (input_list): "" Repeat iterated through values ​​in the nested list. " For the item in the "input_ list": If the use of the iStance (item, list): # that you need, then use the situation where the child needs to mirror: produce the item: child_item yield: yield item Def is_items (seq): "" "Checks to have an item with an iterator." "" If there is no_times (flatten (my_list)) then return (1 for cc in cc): Return  

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -