(*range( ) and (*( for in range( )) and unpack range valuesiterable in unpack generator expression values this applies to dictionaries and views too (though dict values is also list in xand order is arbitrary when passing values by position) dict( ='bob' ='dev' = ) {' ''dev'' ' ' ''bob' ( ='bob' ='dev' = normal keywords bobdevand (**dunpack dictkey=value bobdevand (*dunpack keys iterator bcand (* values()unpack view iteratoriterable in dev and bob because the built-in print function in prints all its variable number of argumentsthis also makes the following three forms equivalent--the latter using to unpack the results forced from generator expression (though the second also creates list of return valuesand the first may leave your cursor at the end of the output line in some shellsbut not in the idle gui)for in 'spam'print( upper()end=' list(print( upper()end='for in 'spam' [nonenonenonenoneprint(*( upper(for in 'spam') see for an additional example that unpacks file' lines by iterator into arguments previewuser-defined iterables in classes although beyond the scope of this it is also possible to implement arbitrary user-defined generator objects with classes that conform to the iteration protocol such classes define special __iter__ method run by the iter built-in functionwhich in turn returns an object having __next__ method (next in xrun by the next built-in functionclass someiterabledef __init__)def __next__)on iter()return self or supplemental object on next()coded hereor in another class as the prior section suggestedthese classes usually return their objects directly for single-iteration behavioror supplemental object with scan-specific state for multiplescan support comprehensions and generations