\documentclass{article}

\usepackage[active,tightpage]{preview}
\usepackage{listings}
\PreviewEnvironment{lstlisting}

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

% http://tex.stackexchange.com/questions/34896/coloring-digits-with-the-listings-package
\makeatletter
\newcommand{\ProcessDigit}[1]
{%
  \ifnum\lst@mode=\lst@Pmode\relax%
   {\digitstyle #1}%
  \else
    #1%
  \fi
}
\makeatother
\lstset{literate=%
    {0}{{{\ProcessDigit{0}}}}1
    {1}{{{\ProcessDigit{1}}}}1
    {2}{{{\ProcessDigit{2}}}}1
    {3}{{{\ProcessDigit{3}}}}1
    {4}{{{\ProcessDigit{4}}}}1
    {5}{{{\ProcessDigit{5}}}}1
    {6}{{{\ProcessDigit{6}}}}1
    {7}{{{\ProcessDigit{7}}}}1
    {8}{{{\ProcessDigit{8}}}}1
    {9}{{{\ProcessDigit{9}}}}1
    {<=}{{\(\leq\)}}1,
    morestring=[b]",
    morestring=[b]',
    morecomment=[l]//,
}



\lstset{
  language=Python,
  showstringspaces=false,
  basicstyle=\ttfamily\small,
  commentstyle=\itshape\color{OliveGreen},
  keywordstyle=\bfseries, % needs different \ttdefault
  stringstyle=\color{Goldenrod},
  identifierstyle=\color{black},
  emph=[1]{Point,Line,Bbox},
  emphstyle=[1]{\color{Red}},
}

\definecolor{poster-dark-blue}{HTML}{2222AA}
\newcommand\digitstyle{\color{poster-dark-blue}}

\begin{document}

% >>> from grass.pygrass.vector.geometry import Point, Line

\begin{lstlisting}
# create a point
>>> point = Point()
>>> point.x = 150.65
>>> point.y = 368.50
>>> point
>>> Point(150.650000, 368.500000)
# distance to another point
>>> point.distance(Point(160.2, 372.6))
10.39290623454286
# conversion to Well-known text (WKT)
>>> point.get_wkt()
'POINT(150.650000 368.500000)'
# bounding box of a line
>>> line = Line([(5, 12), (6, 13), (4, 19)])
>>> line.bbox()
Bbox(19.0, 12.0, 6.0, 4.0)
\end{lstlisting}
\end{document}  