Python‎ > ‎operator‎ > ‎

operator.length_hint()

http://www.adilwaseem.com/

Definition
Returns with the length of iterable items. 

Syntax
Operator.length_hint()

Parameters
objective
iterable

Examples
operator.length_hint(list)
The method returns with the length of interable.
 >>>import operator
>>> list=[101,102,103,104,105]
>>> operator.length_hint(list)
5
>>> len(x)
5

operator.length_hint(set)
The return is:
 >>>import operator
>>> set={2,5,6,7,8,8}
>>> operator.length_hint(set)
5
>>> x={2,5,6,7,8}
>>> operator.length_hint(x)
5
>>> len(x)
5

operator.length_hint(tuple)
The method return with length of string tuple.
 >>>import operator
>>> tuple=("Python", "Research", "Centre")
>>> operator.length_hint(tuple)
3
>>> len(x)
3

__eq__
The equality test is performed.
 >>>import operator
>>> x=("Python", "Research", "Centre")
>>> y={2,1,4,5,9,10,6}
>>> operator.length_hint(x).__eq__(3)
True
>>> operator.length_hint(y).__eq__(8)
False
>>> 

Comments