import pywikibot
from pywikibot import pagegenerators as pg

to_move='P802'
move_to='P3342'

def wd_sparql_query(spq):
   generator=pg.WikidataSPARQLPageGenerator(spq,site=pywikibot.Site('wikidata','wikidata'))
   for wd in generator:
     try:
       wd.get(get_redirect=True)
       yield wd
     except:
       pass

site = pywikibot.Site('wikidata','wikidata')           #Geef aan naar welke site je wilt schrijven
repo = site.data_repository()                     #voor ophalen wikidata-items adhv Qxxxx

def move_one_item(wd):
  if (not(to_move in wd.claims)): return  
  for claim in wd.claims[to_move]:
    for src in claim.getSources():
      for x in src:  
        print('\n---------------\n',x)
  print(1/0)
    
#wd=pywikibot.ItemPage(repo,'Q719942')    #has source
wd=pywikibot.ItemPage(repo,'Q18654792') #has multiple sources
wd.get(get_redirect=True)
move_one_item(wd)
print('Klaar')
---------------
 P248

---------------
 P854

---------------
 P813
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-12-d098bf82b4c5> in <module>
     28 wd=pywikibot.ItemPage(repo,'Q18654792') #has multiple sources
     29 wd.get(get_redirect=True)
---> 30 move_one_item(wd)
     31 print('Klaar')

<ipython-input-12-d098bf82b4c5> in move_one_item(wd)
     23       for x in src:
     24         print('\n---------------\n',x)
---> 25   print(1/0)
     26 
     27 #wd=pywikibot.ItemPage(repo,'Q719942')    #has source

ZeroDivisionError: division by zero