As i was trying to find something interesting to write as a comment, i came across this generation of an object(?). This happened also in Professor Spognardi's lecture, but he said that we will be studying these in the future. What I wanted to ask are some tricks for not showing this, and maybe a simple explanation. Thank you!
P.S. i came across this when converting a list of lists into a tuple of tuples and when I wanted to create, given a tuple, its reverse of reversed elements:
list_of_lists=[[1,2],[7,8],["Italy","France"]]
tuple_of_tuples = (tuple(element) for element in list_of_lists)
print("The converted tuple of tuples : ", tuple_of_tuples)
# <generator object <genexpr> at ... >
-
t1=((1,2),(3,4),(5,6))
t2=reversed([tuple(reversed(list(element))) for element in t1])
print(t2)
# <list_reverseiterator object at ... >
P.P.S. I know how to resolve these problems, just divide both of them into more lines of code, I just wanted to know why writing it like this is not possible
P.S. i came across this when converting a list of lists into a tuple of tuples and when I wanted to create, given a tuple, its reverse of reversed elements:
list_of_lists=[[1,2],[7,8],["Italy","France"]]
tuple_of_tuples = (tuple(element) for element in list_of_lists)
print("The converted tuple of tuples : ", tuple_of_tuples)
# <generator object <genexpr> at ... >
-
t1=((1,2),(3,4),(5,6))
t2=reversed([tuple(reversed(list(element))) for element in t1])
print(t2)
# <list_reverseiterator object at ... >
P.P.S. I know how to resolve these problems, just divide both of them into more lines of code, I just wanted to know why writing it like this is not possible