# Listings package does not return the expected output

So I was trying to use the listings package for LyX in order to create something as following:

After some research (link) I saw a suggestion to do the following steps:

In settings->LaTeX Preamble I added the following code:

\usepackage{listings}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}


Then I created a TeX box and added the following code:

\L {
\lstset{
tabsize=3,
rulesepcolor=\color{gray},
xleftmargin=20pt,
framexleftmargin=15pt,
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
showstringspaces=false,
basicstyle=\footnotesize,
emphstyle={\color{magenta}}
}
\begin{lstlisting}
def some_function(parameter):
a_random_number = parameter - 10
print "some random string" + str(a_random_number)
# And a random comment!
if __name__ == '__main__'
print 'Hello Latex Listings package'
some_function(20)
\end{lstlisting}
}


Please notice that I use L{} because my LyX is defined RTL (to support hebrew).

I compile with pdflatex and get the following output:

What should I add/change in order to get the expected output? I don't really care about the highlight per language.