These two lines of code are almost the same. May I suggest the following?
```python
gen_args = [tab, user, course, active_page]
if tab['type'] == "courseware":
    gen_args.append(request)
tabs.extend(gen(*gen_args))
```