import pywikibot as bot
from pywikibot import pagegenerators as pg

site = bot.Site('wikidata', 'wikidata')

with open('query_parens.rq', 'r') as query_file:
    QUERY = query_file.read().replace('\n', '')
    print(QUERY)

for item in generator:
try:
    item_dict = item.get()
    itemID = item.getID()
except bot.IsRedirectPage:
    pass
try:
    label = item_dict['labels']['en']
    print(label)