It appears that you have 2 things you want to learn:
- Using Python for Security Testing
- Security Testing
You can understand how those things conflict. Python is a tool to help you accomplish a task. If you do not understand the task, then the tool will not be helpful.
Scapy is a wonderful python-based tool that will help you understand basic traffic concepts.
Twill is a python-based tool for web application testing.
But first, understand what you hope to accomplish with the tools. Know what xss is first before you throw a tool at a site. Once you know what xss is, it becomes easy for someone who knows python scripting to write their own tools. The benefit of pre-made tools is that you benefit from the experience of others.
To learn more about Security Testing, you can look at DVWA or Mutillidae. For a more complete collection of tools and targets, try out the Web Security Dojo.