class symbol_universe_iterator¶
Iterator over all the symbols ( symbol ) in a project .
Initialize with project.symbols().
Use as you would any other Python iterator. For example:
# set up project proj, then...
for e in proj.symbols()):
print('symbol: ', e)
symbol_universe_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
symbol_universe_iterator Details¶
-
class
cs.symbol_universe_iterator¶ Iterator over all the symbols (
symbol) in aproject.-
__eq__(other)¶ Iterator equality.
Parameters: other ( symbol_universe_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> symu_iterA = project.current().symbols() >>> symu_iterB = project.current().symbols() >>> symu_iterA == symu_iterB True >>> for sym in symu_iterA: ... if 'j' in sym.name().lower(): ... break ... >>> symu_iterA == symu_iterB False
-
__iter__()¶ Get the iterator object.
Return type: symbol_universe_iteratorReturns: self.>>> for sym in project.current().symbols(): # iteration managed by symbol_universe_iterator.__iter__() ... # and symbol_universe_iterator.__next__() ... if sym.is_string() and sym.get_compunit().is_user(): ... print(sym, sym.represented_string()) ... #string1 bar #string0 foo
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( symbol_universe_iterator) – The iterator to compare against.Return type: bool Returns: Falseif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> symu_iterA = project.current().symbols() >>> symu_iterB = project.current().symbols() >>> symu_iterA != symu_iterB False >>> for sym in symu_iterA: ... if 'j' in sym.name().lower(): ... break ... >>> symu_iterA != symu_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: symbolReturns: The element at the current iterator position. Raises: StopIteration- Side effects: Modifies
self.
The typical use is implicit:
>>> for item in myiter: ... (do something to item)
>>> for sym in project.current().symbols(): # iteration managed by symbol_universe_iterator.__iter__() ... # and symbol_universe_iterator.__next__() ... if sym.is_string() and sym.get_compunit().is_user(): ... print(sym, sym.represented_string()) ... #string1 bar #string0 foo
- Side effects: Modifies
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> syms = project.current().symbols() >>> repr(syms) '<cs.symbol_universe_iterator begin>'
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> syms = project.current().symbols() >>> str(syms) '<cs.symbol_universe_iterator begin>'
-
at_end()¶ Check: is the iterator at the end of the structure?
Return type: bool Returns: Trueif the iterator is at the end of the structure (there are no more elements to iterate over),Falseotherwise.>>> syms = project.current().symbols() >>> syms.at_end() False
-