Using \only on a block - beamer

I don't see your problem. I built this MWE:

\documentclass{beamer}
\usetheme{CambridgeUS}

\begin{document}

\begin{frame}{Title of this frame}
% first block appears at first
\only<1>{
    \begin{block}{First block}
    Hello
    \end{block}
}
% first block disappears and the second appears
\only<2>{
    \begin{block}{Second block}
    Hello again
    \end{block}
}

\end{frame}

\end{document}

getting these two frames:

enter image description here

enter image description here

As you can see, the frame number is always the same and the second block appears after the first one, that is not more visible.

Edit

After you posted your MWE I got your problem. Maybe my solution will not completely satisfy you, but it works.

First: the option fragile is needed anyway. Secondly, since I noticed that the code occupies more or less the whole frame (even setting the font size smaller), I decided in my solution to put it outside the itemize environment.

This is the new MWE:

\documentclass{beamer}
\usetheme{CambridgeUS}

\usepackage[french]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{moreverb}
\usepackage{listings}
\lstset{basicstyle={\footnotesize}}
\begin{document}

\begin{frame}[fragile]{Creation des outils principaux}
  % - Le titre doit résumer le transparent dans un langage compréhensible
  %   par tous ceux qui ne suivront rien de ce qu'il y a sur ce transparent.
\begin{itemize}
\item<1-> Recuperation des donnees entrées dans le terminal
\end{itemize}
\begin{exampleblock}{Opt Parse}<2>
\begin{lstlisting}[firstnumber=0]
import optparse
def parser():
    parser = optparse.OptionParser(        description = "Dessinateur de fonctions")
    parser.add_option('-o', type=str, action = "store",
                        default="out.ppm", dest="filename",
                        help='filename. Default : out.ppm')
    return parser.parse_args()
if __name__ == '__main__':
    (opts, args) = parser()
\end{lstlisting}
\end{exampleblock}

\end{frame}
\end{document}

The result is shown in the following two frames:

enter image description here

enter image description here

Notice that the key point is having inserted <1-> to the item and <2> for the exampleblock. In this way the sentence of the item is still visible when the exampleblock appears.


A variant of Claudio's answer can be obtained by modifying the action specifications of the block environment, as explained in the Beamer User Guide for version 3.50 in Section 9.6.3.:

\documentclass{beamer}
\usetheme{CambridgeUS}

\begin{document}

\begin{frame}{Title of this frame}
% first block appears at first
\begin{block}<only@1>{First block} % <-- note the "only@" here...
    Hello
\end{block}
% first block disappears and the second appears
\begin{block}<only@2>{Second block} % <-- and here
    Hello again
\end{block}

\end{frame}

\end{document}