cocopp.toolsdivers.StrList(list)
class documentationcocopp.toolsdivers
(View In Hierarchy)
str
with search/find functionality.Method | __init__ | Undocumented |
Method | as_string | return space separated string concatenation surrounded by spaces. |
Method | found | StrList of elements found during the last call to find . |
Method | __call__ | alias to find |
Method | find | return entries that match all substrs . |
Method | find_indices | same as find but returns indices instead of names |
Method | print the result of find(*substrs) with indices. |
return space separated string concatenation surrounded by spaces.
To get only the recently found items use found.as_string instead of as_string.
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
type
int
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
.