Python‎ > ‎operator‎ > ‎

operator.getitem()

http://www.adilwaseem.com/

Return
Add item to the iterable.

Syntax
operator.getitem(a,b)
__getitem__

Parameters
a=list
b=number

Import module
Importing module is required in the Shell window and the Editor window.

Examples
The method return with item.
 >>> a=["Python", "Lake","2014"]
>>> operator.getitem(a,2)
'2014'
>>> a=[2,4,8,16]
>>> operator.getitem(a,3)
16

operator.__getitem__(a,b)
The method return the same value as operator.getitem(a,b).
>>> a=[2,4,8,16]
>>> operator.getitem(a,3)
16
>>> operator.__getitem__(a,2)
8


a[b]
The method also perform the same function.
 >>> a=[2,4,8,16]
>>> operator.__getitem__(a,2)
8
>>> a[2]
8
>>> a[3]
16

Comments