looking for a signature based intrusion based code in python
I'm going to write don't do this. To maintain speed, almost all networking is done in C or maybe, C++. It's rarely done in something like Python.
Python for quick things like the systems program shown or for prototyping C programs, and C for programs where the time taken to process information matters more.
I'm sure you googled this like https://www.google.com/search?q=signature+based+packet+inspection+system+using+python but if you want to create this, my advice is to get into compiled languages.