Basic Python

itertools.islice, chain, isinstance

Naranjito 2021. 5. 25. 12:32
  • itertools.islice

islice(iterable, start, stop, step)

Iterate Slice, selectively prints the values mentioned in its iterable container passed as an argument.

for i in islice(range(20),1,10,3):
    print(i)
>>>
1
4
7

 

  • chain

chain('ABC', 'DEF') --> A B C D E F

from itertools import chain 
country=['korea','japan','usa']
capi=['seoul','tokyo','new']
c=chain(country,capi)
next(c)
>>>
korea

 

  • isinstance

It returns True if the specified object is of the specified type, otherwise False.

isinstance(object, type)​
isinstance(5,int)
>>>
True