#!/usr/bin/python3
import pywikibot

SANDBOX = "Q4115189"
DOB = "P569"


def get_value_of_property(q_number, property_id, site):
    results = []
    item = pywikibot.ItemPage(site, q_number)
    print(item.getID())
    if item.exists() and item.claims.get(property_id):
        for claim in item.claims.get(property_id):
            target = claim.getTarget()
            if isinstance(target, pywikibot.ItemPage):
                target = target.getID()
            results.append(target)
    return results

site = pywikibot.Site("wikidata", "wikidata")

dates_in_item = get_value_of_property(SANDBOX, DOB, site)
for d in dates_in_item:
    print(type(d))
Q4115189
<class 'pywikibot.WbTime'>