Dlaczego generator zwraca zawsze tę samą wartość po wywołaniu printa zamiast następnej?
from bs4 import BeautifulSoup as Bs
#func returns all rows with all products from xml file
def get_rows():
try:
with open('solgar.xml', encoding='utf-8') as f:
data = f.read()
bs_data = Bs(data, "xml")
b_rows = bs_data.find_all('Row')[2:]
except:
print("There's something wrong with the xml file.")
return b_rows
#func generates a single product
def get_cells(rows):
try:
for row in rows.copy():
yield row.find('Cell')
except TypeError:
print("Are you sure rows are in bs4 type?")
quit()
def main():
rows = get_rows()
print(next(get_cells(rows)))
print(next(get_cells(rows)))
print(next(get_cells(rows)))
if __name__ == '__main__':
main()