[Tex/LaTex] How to highlight Python syntax in LaTeX Listings \lstinputlistings command


I am using package listings to import my Python source code into my LaTeX document. I use the command \lstinputlistings. I have a Python source like

class MyClass(Yourclass):
    def __init__(self, my, yours):
        bla bla bla...

What should I write in my \lstset command in order to highlight words MyClass, __init__ etc.?
I wouldn't want to write any word I want to be highlighted. I tried using moredelims=[s][\color{teal}]{class}{(} inside lstset but it doesn't work.

Best Answer

I'd consider running your code through pygments to generate the latex, probably using the minted package. You can get some details here https://stackoverflow.com/questions/1966425/source-code-highlighting-in-latex#1985330 .