Select to view content in your preferred language

Python "group" object in Item properties dictionary ?

1511
1
10-29-2018 01:33 AM
HugoBouckaert1
Occasional Contributor

Hi 

I want to find out which AGOL groups particular objects belong to, and in doing so seem to have come across a python  "group" object within a dictionary, which is difficult to access. I looked it up and the only "group type" object in python I find reference to is h5py "group" objects, but that is not it.

So this is what I am trying to do: I have an AGOL item, and I want to know what AGOL groups this item belongs to. This information can be found when calling "shared_with", which returns a dictionary: 

print (item.shared_with)

This returns:  

{'everyone': False, 'org': False, 'groups': [<Group title:"Group name" owner:some_user>]}

I thought that what is (within the dictionary) in the list i.e. between [  and  ] is a string i.e I though that this is a string:

<Group title:"Group name" owner:some_user>   

But when I use some string functions on it, like split, it complains that this is not a string object:

AttributeError: 'Group' object has no attribute 'split'

(I know the use of the term "group" is confusing here, I am looking for AGOL groups and the name 'group' also appears in what is returned between < >), but what I think is what is between < > is  also some sort of a python "group" object.)  

So whatever is between <   and   >  is a python "group" object? To be honest I have never heard of it and googling does not help either. Anyone knows what kind of object this is and how to access it? It is not a string, that's for sure.    

 

Thanks

Hugo 

0 Kudos
1 Reply
by Anonymous User
Not applicable

A Group in the ArcGIS API for Python is a class that represents a group in ArcGIS Online/Portal. The documentation for it is available here: arcgis.gis module — arcgis 1.5.0 documentation.

So you are seeing list of Group objects.

You can access different properties such as the title by group.title.