class StrList(list):
Known subclasses: cocopp.archiving.COCODataArchive
, cocopp.archiving.ListOfArchives
, cocopp.archiving.RemoteListOfArchives
Constructor: StrList(list_or_str)
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 |
same as find but returns indices instead of names |
Method | print |
print the result of find(*substrs) with indices. |
Property | as |
return space separated string concatenation surrounded by spaces. |
Property | found |
StrList of elements found during the last call to find . |
Instance Variable | _names |
Undocumented |
cocopp.archiving.COCODataArchive
, cocopp.archiving.ListOfArchives
, cocopp.archiving.RemoteListOfArchives
Undocumented
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
.