Forum Archive

Getting people from a group in contacts api

wjshea

Hi, I’m trying to get a list of people from a group.

def test_get_contacts_from_group_name():
    groupName = "Mail List Test"

    groups = contacts.get_all_groups()
    for group in groups:
        if (groupName == group.name):
            members_group = contacts.get_group(group.id)
            print(members_group)
            members_group.get_all_people()
            #for member in members_group:
            #   print (member.address)

        else:
            print('-1') 

Group does not have a member called get_all_members. Are there away to get members from a group?

Thanks

wjshea

I figured it out...

There is a method on group called get_all_members. I must have missed in when reviewing the docs.

Phuket2

@wjshea, i was doing something with contacts yesterday. I found just doing print(help(contacts)) was very useful.