<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def publish(idx=None):
 """Publish packaged distributions to pypi index"""

    if idx is None:
        idx = ''
    else:
        idx = '-r ' + idx
    run('python setup.py register {}'.format(idx))
    run('twine upload {} dist/*.whl dist/*.egg dist/*.tar.gz'.format(idx))