Python __builtin__.filter() Examples

The following are 30 code examples of __builtin__.filter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module __builtin__ , or try the search function .
Example #1
Source File: noniterators.py    From arissploit with GNU General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string
        
        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #2
Source File: noniterators.py    From telegram-robot-rss with Mozilla Public License 2.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string
        
        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #3
Source File: noniterators.py    From gimp-plugin-export-layers with GNU General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string
        
        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #4
Source File: noniterators.py    From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string
        
        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #5
Source File: pandas_py3k.py    From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 6 votes vote down vote up
def __and__(self, other):
        ''' Intersection is the minimum of corresponding counts.

        >>> Counter('abbb') & Counter('bcc')
        Counter({'b': 1})

        '''
        if not isinstance(other, Counter):
            return NotImplemented
        _min = min
        result = Counter()
        if len(self) < len(other):
            self, other = other, self
        for elem in filter(self.__contains__, other):
            newcount = _min(self[elem], other[elem])
            if newcount > 0:
                result[elem] = newcount
        return result 
Example #6
Source File: scanner.py    From ham2mon with GNU General Public License v3.0 6 votes vote down vote up
def update_priority(self):
        """Updates priority channels
        """
        # Clear the priority channels
        self.priority_channels = []

        # Process priority file if it was provided
        if self.priority_file_name != "":
            # Open file, split to list, remove empty strings
            with open(self.priority_file_name) as priority_file:
                lines = priority_file.read().splitlines()
                priority_file.close()
                lines = __builtin__.filter(None, lines)
            # Convert to baseband frequencies, round, and append if within BW
            for freq in lines:
                bb_freq = float(freq) - self.center_freq
                bb_freq = round(bb_freq/self.channel_spacing)*\
                                        self.channel_spacing
                if abs(bb_freq) <= self.samp_rate/2.0:
                    self.priority_channels.append(bb_freq)
                else:
                    pass
        else:
            pass 
Example #7
Source File: noniterators.py    From deepWordBug with Apache License 2.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string
        
        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #8
Source File: __init__.py    From Computable with MIT License 6 votes vote down vote up
def __and__(self, other):
        """Intersection is the minimum of corresponding counts.

        >>> Counter('abbb') & Counter('bcc')
        Counter({'b': 1})

        """
        if not isinstance(other, Counter):
            return NotImplemented
        _min = min
        result = Counter()
        if len(self) < len(other):
            self, other = other, self
        for elem in filter(self.__contains__, other):
            newcount = _min(self[elem], other[elem])
            if newcount > 0:
                result[elem] = newcount
        return result 
Example #9
Source File: noniterators.py    From addon with GNU General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string

        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #10
Source File: noniterators.py    From Tautulli with GNU General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string

        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #11
Source File: noniterators.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string

        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #12
Source File: noniterators.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string

        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #13
Source File: noniterators.py    From misp42splunk with GNU Lesser General Public License v3.0 6 votes vote down vote up
def oldfilter(*args):
        """
        filter(function or None, sequence) -> list, tuple, or string

        Return those items of sequence for which function(item) is true.
        If function is None, return the items that are true.  If sequence
        is a tuple or string, return the same type, else return a list.
        """
        mytype = type(args[1])
        if isinstance(args[1], basestring):
            return mytype().join(builtins.filter(*args))
        elif isinstance(args[1], (tuple, list)):
            return mytype(builtins.filter(*args))
        else:
            # Fall back to list. Is this the right thing to do?
            return list(builtins.filter(*args))

    # This is surprisingly difficult to get right. For example, the
    # solutions here fail with the test cases in the docstring below:
    # http://stackoverflow.com/questions/8072755/ 
Example #14
Source File: __coconut__.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        return "filter(%r, %r)" % (self.func, self.iter) 
Example #15
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __repr__(self):
        return "filter(%r, %r)" % (self.func, self.iter) 
Example #16
Source File: compatibility_utils.py    From fb2mobi with MIT License 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #17
Source File: setup.py    From pyprover with Apache License 2.0 5 votes vote down vote up
def __new__(cls, function, iterable):
        new_filter = _coconut.filter.__new__(cls, function, iterable)
        new_filter.func = function
        new_filter.iter = iterable
        return new_filter 
Example #18
Source File: __init__.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #19
Source File: python.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #20
Source File: __init__.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #21
Source File: __init__.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #22
Source File: __init__.py    From gimp-plugin-export-layers with GNU General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #23
Source File: __init__.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #24
Source File: __init__.py    From arissploit with GNU General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #25
Source File: __init__.py    From Tautulli with GNU General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #26
Source File: __init__.py    From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #27
Source File: __init__.py    From verge3d-blender-addon with GNU General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #28
Source File: pandas_py3k.py    From kgsgo-dataset-preprocessor with Mozilla Public License 2.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #29
Source File: __init__.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs)) 
Example #30
Source File: __init__.py    From misp42splunk with GNU Lesser General Public License v3.0 5 votes vote down vote up
def lfilter(*args, **kwargs):
        return list(filter(*args, **kwargs))