Is this proper behavior for a capturing regexp?

```
In [1]: import re
In [2]: r = re.compile(r'()(foo)()')
In [3]: r.match('foo').groups()
Out[5]: ('', 'foo', '')
```

FYI I'm abusing this so I can get a consistent amount of `.groups()` on a `match()`. Sue me.

#Python #regexps

@mdione I see nothing wrong here.

You could do (this_will_not_match)? instead of () to prove that it's legit, but I would stick with ()

@mdione can you also not just `len(r.match(‘foo’).groups())` and then do conditional logic with the len return?

Only reason why I would suggest that is what you’re doing visually looks strange and might be hard to remember why you were even doing it in the future. I say this as someone who has done this to themselves plenty lol

@elebertus oh, yes, but leave a big comment when I do crap like this :)
@mdione If you're using it to compatibly index into different expressions' matches, you could try named groups instead. I think that'd be easier to read.

@chrysn yeah, no, not even my hack fixed it. The truth is, it was something like `(?:(moo)(foo)(bar)(quux)|()(foo)()())`, but when calling `match().groups()` I would either get:

`['moo', 'foo', 'bar', 'quux', None, None, None, None]` or
`[None, None, None, None, '', 'foo', '', '']`

instead of

`['moo', 'foo', 'bar', 'quux']` or
`['', 'foo', '', '']`

as I expected. The resulting code was even worse :)