how to hide brackets and single quote?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

how to hide brackets and single quote?

Bento Dias de Carvalho
Hi,

How to hide the brackets and single quote from the output of data properties value from instances?

example:
for u in onto.Men.instances():
    print(u.hasFirstName, u.hasLastName)

output:
['Bento Dias'] ['de Carvalho']

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: how to hide brackets and single quote?

Jiba
Administrator
Hi,

Brackets are due to the fact that the property value is a list in Python. You can either declare the properties as functional in order to have a single value instead of a list, or you can simply take the first value of the list as follows:

    print(u.hasFirstName.first(), u.hasLastName.first())

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: how to hide brackets and single quote?

Bento Dias de Carvalho
Thanks Jiba.