import pywikibot

def create_bavarian_politician(name):
    """
    Creates a new entry in test.wikdata.org
    :return: 
    """
    site = pywikibot.Site("wikidata", "wikidata")
    repo = site.data_repository()

    data = {
        'labels': {
            'en': {
                'language': 'en',
                'value': name,
            },
            'de': {
                'language': 'de',
                'value': name,
            }
        }
    }
    item = pywikibot.ItemPage(site)
    
    claim = pywikibot.Claim(repo, u'P39')
    target = pywikibot.ItemPage(repo, u"Q17586301")
    claim.setTarget(target)
    item.editEntity(data)

    item.addClaim(claim)
    
create_bavarian_politician("Florian Hölzl")
Sleeping for 9.7 seconds, 2016-12-03 20:51:03
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-866b74e88213> in <module>()
     33 
     34 
---> 35 create_bavarian_politician("Florian Hölzl")

<ipython-input-20-866b74e88213> in create_bavarian_politician(name)
     29     item.editEntity(data)
     30 
---> 31     item.addClaim(claim)
     32 
     33 

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in addClaim(self, claim, bot, **kwargs)
   4069         @type bot: bool
   4070         """
-> 4071         self.repo.addClaim(self, claim, bot=bot, **kwargs)
   4072         claim.on_item = self
   4073 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in callee(self, *args, **kwargs)
   1328             else:
   1329                 raise Exception("Not implemented")
-> 1330             return fn(self, *args, **kwargs)
   1331 
   1332         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in addClaim(self, item, claim, bot, summary)
   7292         claim.snak = data['claim']['id']
   7293         # Update the item
-> 7294         if claim.getID() in item.claims:
   7295             item.claims[claim.getID()].append(claim)
   7296         else:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __getattribute__(self, name)
   3419                 'WikibasePage.lastrevid', 'latest_revision_id', 2)
   3420             name = '_revid'
-> 3421         return super(WikibasePage, self).__getattribute__(name)
   3422 
   3423     def __setattr__(self, attr, value):

AttributeError: 'ItemPage' object has no attribute 'claims'