Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

create a generator from a list

data = [1,23,46,9,2]
#creates a generator object
data_gen = (y for y in data)

# creates a list iterator object
data_iter = iter(data)

# both can be used with next()

next(data_gen) 
# or
next(data_iter)
Comment

PREVIOUS NEXT
Code Example
Python :: sort dict by value python 3 
Python :: how to connect wifi using python 
Python :: python insertion sort 
Python :: python num perfect squares 
Python :: pyplot width 
Python :: jinja macro import 
Python :: python create env ubuntu 
Python :: python classes 
Python :: how to urllib3 
Python :: add system path python jupytre 
Python :: pd.read_excel 
Python :: copyfile pyhon 
Python :: get input from user in python 
Python :: df to csv 
Python :: error command errored out with exit status 1 face_recognition 
Python :: how to change plot size in matplotlib 
Python :: print boolean in python 
Python :: python bitwise operators 
Python :: read binary image python 
Python :: Import "whitenoise.django" could not be resolved 
Python :: pychamrfind and replace 
Python :: select a range of rows in pandas dataframe 
Python :: shutdown flask server with request 
Python :: How to do train test split in keras Imagedatagenerator 
Python :: NumPy unique Example Get the counts of each unique value 
Python :: python date to timestamp 
Python :: python infinity 
Python :: python logging into two different files 
Python :: reportlab python draw line 
Python :: python list splicing 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =