# “Improper alphabetic constant” with listings customized

When I attempt to compile my Beamer slides (very much trimmed-down code below), I encounter the following error:

! Improper alphabetic constant.
\relax
l.1 \begin{python}


The Beamer slides code contains listings syntax highlighting customizations and is shown below. What might be going wrong?

\documentclass{article}

\usepackage{listings}
\newcommand\pythonstyle{\lstset{
language=Python,
otherkeywords={self,},
}}
\lstnewenvironment{python}[1][]{
\pythonstyle
\lstset{#1}
}{}

\begin{document}

\begin{python}
import multiprocessing
\end{python}

\end{document}

• Thank you for posting a working example! At the same time, much of your code does not seem to be relevant to the question you're asking here. Please limit the example to only the code required for your issue to appear. You can have a look at this guide for how to prune your code for this purpose. – user36296 Nov 29 '16 at 20:43
• Could you please try minimizing the code? – egreg Nov 29 '16 at 20:48

After removing the 90% or more of your code that was completely irrelevant, we are left with the following chunk that is broken:

\documentclass{article}

\usepackage{listings}
\newcommand\pythonstyle{\lstset{
language=Python,
otherkeywords={self,},
}}
\lstnewenvironment{python}[1][]{
\pythonstyle
\lstset{#1}
}{}

\begin{document}

\begin{python}
import multiprocessing
\end{python}

\end{document}


Commenting out the line otherkeywords={self,}, makes the problem go away, so a reasonable guess is that the problem is the comma after self. Sure enough deleting the comma fixes the problem.

• @samcarter Luckily binary search is pretty fast. – Hood Chatham Nov 29 '16 at 23:56