Skip to content
Snippets Groups Projects

Filter empty and None values in dict

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Bruno Duyé
    Edited
    snippetfile1.txt 255 B
    import toolz
    
    def filter_none_and_empty(_dict):
        """Remove None and empty values in dict
        >>> filter_none_and_empty({'a': 'a', 'none': None, 'empty': ''})
        {'a': 'a'}
        """
        return toolz.valfilter(lambda e: e is not None and e != '', _dict)
    • darsh bhatt @darshbhatt ·

      Linux® is an open source working framework (OS). A working framework is the product that straightforwardly deals with a framework's equipment and assets, similar to CPU, memory, and capacity. The OS sits among applications and equipment and makes the associations between the entirety of your product and the actual assets that accomplish the work.

      Linux Course in pune

    0% or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment