Multiple set unions along with list comprehension

Viewed 75

I am trying to understand this code:

edit_two_set = set()
edit_two_set = set.union(*[edit_two_set.union(edit_one_letter(w, allow_switches)) for w in one])

Here one is a set of strings. allow_switches is True. edit_one_letter takes in one word and makes either one character insertion, deletion or one switch of corresponding characters.

I understand:

[edit_two_set.union(edit_one_letter(w, allow_switches)) for w in one]

is performing a list comprehension in which for every word in one we make one character edit and then take the union of the resulting set with the previous set.

I am mainly stuck at trying to understand what:

set.union(*[])

is doing? Thanks!

1 Answers
Related