I would like to get auto-completion on my python scripts also in the arguments.
I had never really understood how the bash_completion worked (for arguments), but aft
Bash "completion" really is great. And easy for programs written in Python....
I think this is just what you want: optcomplete: Shell Completion Self-Generator for Python. It is available, e.g., as the "python-optcomplete" package in Ubuntu.
You insert a few lines in your python program, and the user (one time) runs the bash "complete" program to tell bash how to complete the arguments:
complete -F _optcomplete <program>
and now the user has completion! By default it gives simple completion on program options. See the example for how to customize how completion works for a particular option. It is beautifully written, and easy to extend to handle sub-commands, alternate completion options, etc.!
Update:
For completion in zsh (for both optparse and argparse) see genzshcomp 0.3.1 : Python Package Index
As noted by @englebip, we still need something similar for the new argparse module, introduced in Python 2.7 and 3.2, since optparse is now deprecated.
Here is the discussion on moving in that direction:
See also this background on how it is done: How does argparse (and the deprecated optparse) respond to 'tab' keypress after python program name, in bash? - Stack Overflow
Shameless self-promotion: https://github.com/kislyuk/argcomplete
argcomplete provides bash completion for argparse.