class documentation

A list of str with search/find functionality.

Method __call__ alias to find
Method __init__ Undocumented
Method find return entries that match all substrs.
Method find_indices same as find but returns indices instead of names
Method print print the result of find(*substrs) with indices.
Property as_string return space separated string concatenation surrounded by spaces.
Property found StrList of elements found during the last call to find.
Instance Variable _names_found Undocumented
def __call__(self, *substrs):

alias to find

def find(self, *substrs):

return entries that match all substrs.

This method serves for interactive exploration of available entries and may be aliased to the shortcut of calling the instance itself.

When given several substrs arguments the results match each substring (AND search, an OR can be simply achieved by appending the result of two finds). Upper/lower case is ignored.

When given a single substrs argument, it may be

  • a list of matching substrings, used as several substrings as above
  • an index of type int
  • a list of indices

A single substring matches either if an entry contains the substring or if the substring matches as regular expression, where "." matches any single character and ".*" matches any number >= 0 of characters.

>>> from cocopp.toolsdivers import StrList
>>> s = StrList(['abc', 'bcd', 'cde', ' cde'])
>>> s('bc')  # all strings with a 'bc'
['abc', 'bcd']
>>> s('a', 'b')  # all strings with an 'a' AND 'b'
['abc']
>>> s(['a', 'b'])  # the same
['abc']
>>> s('.c')  # regex 'c' as second char
['bcd', ' cde']
>>> s('.*c')  # regex 'c' preceded with any sequence
['abc', 'bcd', 'cde', ' cde']

Details: The list of matching names is stored in found.

def find_indices(self, *substrs):

same as find but returns indices instead of names

def print(self, *substrs):

print the result of find(*substrs) with indices.

Details: does not change found and returns None.

@property
as_string =

return space separated string concatenation surrounded by spaces.

To get only the recently found items use found.as_string instead of as_string.

@property
found =

StrList of elements found during the last call to find.

_names_found =

Undocumented