Skip to content

How to get instance_of? #47

Answered by dahlia
JiyaoWei asked this question in Q&A
Discussion options

You must be logged in to vote

If you mean by the P31 property:

>>> from wikidata.client import Client
>>> client = Client()
>>> e = client.get('Q28865', load=True)
>>> e
<wikidata.entity.Entity Q28865 'Python'>
>>> instance_of = client.get('P31', load=True)
>>> instance_of
<wikidata.entity.Entity P31 'instance of'>
>>> types = e.getlist(instance_of)
>>> types
[<wikidata.entity.Entity Q899523>, <wikidata.entity.Entity Q1268980>, <wikidata.entity.Entity Q3839507>, <wikidata.entity.Entity Q187432>, <wikidata.entity.Entity Q12772052>, <wikidata.entity.Entity Q21562092>, <wikidata.entity.Entity Q1993334>, <wikidata.entity.Entity Q211496>, <wikidata.entity.Entity Q9143>, <wikidata.entity.Entity Q1004415>]
>>> for t in types:…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dahlia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #34 on August 04, 2022 17:28.