Convert list/tuple of arguments into just arguments I am using a library that specifically needs me to provide arguments as strings one by one. However, different combinations are possible. Right now I am using a bunch of elif:

def get_all_users(times=False, groups=False, ips=False):
    """Get a list of all users online"""
    if times and groups and ips:
        return ts3conn.exec_("clientlist", "times", "groups", "ips")
    elif times and groups:
        return ts3conn.exec_("clientlist", "times", "groups")
    elif times and ips:
        return ts3conn.exec_("clientlist", "times", "ips")
    elif groups and ips:
        return ts3conn.exec_("clientlist", "groups", "ips")
    elif times:
        return ts3conn.exec_("clientlist", "times")
    elif groups:
        return ts3conn.exec_("clientlist", "groups")
    elif ips:
        return ts3conn.exec_("clientlist", "ip")
    else:
        return ts3conn.exec_("clientlist")


But I am wondering if this could be improved.

NOTE: I tried if I could use tuples but it won't work:

stuff = (times, groups, ips)
return ts3conn.exec_("clientlist", stuff)
&gt;&gt;&gt; TypeError: can only concatenate str (not "tuple") to str


Update:
Library is at: https://github.com/benediktschmitt/py-ts3/blob/v2/ts3/query_builder.py  

The code raises error on function compile:

for option in options:
    res += " -" + option
You could use itertools.compress in combination with the tuple

def get_all_users(times=False, groups=False, ips=False):
    """Get a list of all users online"""
    arguments = ("clientlist", "times", "groups", "ips")
    selectors = (True, times, groups, ips)

    return ts3conn.exec_(*itertools.compress(arguments , selectors))


or in python 3.6+, using the retained insertion order of dicts (earlier versions can use an collections.ordereddict

def get_all_users(times=False, groups=False, ips=False):
    """Get a list of all users online"""
    arguments = {
        "clientlist": True,
        "times": times,
        "groups" : groups, 
        "ips": ips,
    }
    return ts3conn.exec_(*(key for key, value in arguments.items() if value))