pat = re.compile(r' A(\d+)')
lst = re.findall(pat, "= A1 A2 A3 A4")
This returns a list, and in your example you showed a tuple. I presume a list will work for you, but of course you can always do:
t = tuple(lst)
The answer I just gave doesn't actually check for the = in the input string. If you need to do that, you can always use two patterns and two steps:
pat0 = re.compile(r'=(?: A\d+)+')
pat1 = re.compile(r' A(\d+)')
m = pat0.search("= A1 A2 A3 A4")
if not m:
print("input string not what was expected")
else:
s = m.group(0)
lst = re.findall(pat, s)
EDIT: Code that handles your func() example:
s_code = "func(cmd, param1, param2, param3, param4)"
pat_recognize_args = re.compile(r'func\(cmd([^)]*)\)')
pat_parse_args = re.compile(r'[, ]+([^, ]+)')
m = pat_recognize_args.search(s_code)
if m:
s = m.group(1)
lst = re.findall(pat_parse_args, s)
When I ran the above code, lst was set to: ['param1', 'param2', 'param3', 'param4']
pat_recognize_args looks for the literal string func with a literal ( (which is backslash-escaped in the pattern so re won't try to use it to start a match group), then the literal string cmd, and then a match group that matches anything up to a literal ) character; then the match group is closed with a ) and a literal ) is there to match the actual ) that finishes the function call. After this pattern matches, the match object will have group 1 set to just the interesting arguments from the function call.
So next we set s = m.group(1) and then have re.findall() pull out the arguments for us.