Python repeat generator

Is there an easier way to do the following?

(set() for _ in itertools.repeat(None)) 

Note that it differs from itertools.repeat(set()) , since the latter constructs the given object only once.

+5
source share
1 answer

You can do

 iter(set, None) 

which causes the given caller until it returns None (which it will not).

+7
source

Source: https://habr.com/ru/post/1200906/


All Articles