I can't understand the way babel works (or, more precisely, doesn't) in the following example. The command \sujet is supposed to create a new command named \sujeti, which in turn is supposed to print the 4th argument of \sujet.
This seems to be quite the case except that 1) the punctuation, which should be French thanks to babel, is wrong (no space before '!'); 2) there is no way to use the \verb command in the content of \sujet.
Here is a minimal example:
\documentclass{article}
\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}
\RequirePackage[french]{babel}
\newcommand\addindex[4][]{% #2 as name of var, #3 as index and #4 as content
\csname#1def\expandafter\endcsname\csname #2\roman{#3}\endcsname{#4}%
}
\newcounter{num_sujet}
\newcommand{\sujet}[1]{%
\stepcounter{num_sujet}
\addindex{sujet}{num_sujet}{#1\par}
\par
}
\sujet{%
Test! %\verb/there should be a space before '!', and \verb doesn't seem to work/
}
\begin{document}
\sujeti
\end{document}
Any help or explanation on what is going on would be very welcome.

\begin{docuemnt]so the!in the preamble will not be active and get french spacing – David Carlisle Sep 11 '16 at 14:49\newccommand{\sujet}definition is missing two%as it is it adds two space tokens each time it is used. – David Carlisle Sep 11 '16 at 14:50