%%
%% This is file `pythontex.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pythontex.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2012-2013 by Geoffrey M. Poore <gpoore@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pythontex}
    [2013/08/26 Version~0.12]

\newcommand{\pytx@packagename}{PythonTeX}
\newcommand{\pytx@packageversion}{v0.12}
\RequirePackage{fancyvrb}
\RequirePackage{etex}
\RequirePackage{etoolbox}
\RequirePackage{xstring}
\RequirePackage{pgfopts}
\RequirePackage{newfloat}
\RequirePackage{currfile}
\AtBeginDocument{\@ifpackageloaded{color}{}{\RequirePackage{xcolor}}}
\def\pytx@families{}
\pgfkeys{/PYTX/pkgopt/usefamily/.estore in=\pytx@families}
\def\pytx@opt@gobble{none}
\pgfkeys{/PYTX/pkgopt/gobble/.is choice}
\pgfkeys{/PYTX/pkgopt/gobble/none/.code=\def\pytx@opt@gobble{none}}
\pgfkeys{/PYTX/pkgopt/gobble/auto/.code=\def\pytx@opt@gobble{auto}}
\newbool{pytx@opt@beta}
\pgfkeys{/PYTX/pkgopt/beta/.default=true}
\pgfkeys{/PYTX/pkgopt/beta/.is choice}
\pgfkeys{/PYTX/pkgopt/beta/true/.code=\booltrue{pytx@opt@beta}}
\pgfkeys{/PYTX/pkgopt/beta/false/.code=\boolfalse{pytx@opt@beta}}
\def\pytx@opt@rerun{default}
\pgfkeys{/PYTX/pkgopt/runall/.default=true}
\pgfkeys{/PYTX/pkgopt/runall/.is choice}
\pgfkeys{/PYTX/pkgopt/runall/true/.code=\def\pytx@opt@rerun{always}}
\pgfkeys{/PYTX/pkgopt/runall/false/.code=\relax}
\pgfkeys{/PYTX/pkgopt/rerun/.is choice}
\pgfkeys{/PYTX/pkgopt/rerun/never/.code=\def\pytx@opt@rerun{never}}
\pgfkeys{/PYTX/pkgopt/rerun/modified/.code=\def\pytx@opt@rerun{modified}}
\pgfkeys{/PYTX/pkgopt/rerun/errors/.code=\def\pytx@opt@rerun{errors}}
\pgfkeys{/PYTX/pkgopt/rerun/warnings/.code=\def\pytx@opt@rerun{warnings}}
\pgfkeys{/PYTX/pkgopt/rerun/always/.code=\def\pytx@opt@rerun{always}}
\pgfkeys{/PYTX/pkgopt/rerun/all/.code=\def\pytx@opt@rerun{always}%
    \PackageWarning{\pytx@packagename}{rerun=all is deprecated; use rerun=always}}
\def\pytx@opt@hashdependencies{default}
\pgfkeys{/PYTX/pkgopt/hashdependencies/.is choice}
\pgfkeys{/PYTX/pkgopt/hashdependencies/.default=true}
\pgfkeys{/PYTX/pkgopt/hashdependencies/true/.code=\def\pytx@opt@hashdependencies{true}}
\pgfkeys{/PYTX/pkgopt/hashdependencies/false/.code=\def\pytx@opt@hashdependencies{false}}
\newbool{pytx@opt@autoprint}
\booltrue{pytx@opt@autoprint}
\pgfkeys{/PYTX/pkgopt/autoprint/.default=true}
\pgfkeys{/PYTX/pkgopt/autoprint/.is choice}
\pgfkeys{/PYTX/pkgopt/autoprint/true/.code=\booltrue{pytx@opt@autoprint}}
\pgfkeys{/PYTX/pkgopt/autoprint/false/.code=\boolfalse{pytx@opt@autoprint}}
\pgfkeys{/PYTX/pkgopt/autostdout/.default=true}
\pgfkeys{/PYTX/pkgopt/autostdout/.is choice}
\pgfkeys{/PYTX/pkgopt/autostdout/true/.code=\booltrue{pytx@opt@autoprint}}
\pgfkeys{/PYTX/pkgopt/autostdout/false/.code=\boolfalse{pytx@opt@autoprint}}
\newcommand{\setpythontexautoprint}[1]{%
    \Depythontex{cmd:setpythontexautoprint:m:n}%
    \ifstrequal{#1}{true}{\booltrue{pytx@opt@autoprint}}{}%
    \ifstrequal{#1}{false}{\boolfalse{pytx@opt@autoprint}}{}%
}
\newcommand{\setpythontexautostdout}[1]{%
    \Depythontex{cmd:setpythontexautostdout:m:n}%
    \ifstrequal{#1}{true}{\booltrue{pytx@opt@autoprint}}{}%
    \ifstrequal{#1}{false}{\boolfalse{pytx@opt@autoprint}}{}%
}
\newbool{pytx@opt@stdout}
\booltrue{pytx@opt@stdout}
\pgfkeys{/PYTX/pkgopt/debug/.code=\boolfalse{pytx@opt@stdout}}
\pgfkeys{/PYTX/pkgopt/stdout/.default=true}
\pgfkeys{/PYTX/pkgopt/stdout/.is choice}
\pgfkeys{/PYTX/pkgopt/stdout/true/.code=\booltrue{pytx@opt@stdout}%
    \PackageWarning{\pytx@packagename}{Option stdout is deprecated; use option debug}}
\pgfkeys{/PYTX/pkgopt/stdout/false/.code=\boolfalse{pytx@opt@stdout}%
    \PackageWarning{\pytx@packagename}{Option stdout is deprecated; use option debug}}
\pgfkeys{/PYTX/pkgopt/print/.default=true}
\pgfkeys{/PYTX/pkgopt/print/.is choice}
\pgfkeys{/PYTX/pkgopt/print/true/.code=\booltrue{pytx@opt@stdout}%
    \PackageWarning{\pytx@packagename}{Option print is deprecated; use option debug}}
\pgfkeys{/PYTX/pkgopt/print/false/.code=\boolfalse{pytx@opt@stdout}%
    \PackageWarning{\pytx@packagename}{Option print is deprecated; use option debug}}
\AtBeginDocument{%
    \ifbool{pytx@opt@stdout}{}{%
        \PackageWarning{\pytx@packagename}{Using package option debug}%
    }%
}
\newbool{pytx@opt@stderr}
\pgfkeys{/PYTX/pkgopt/makestderr/.default=true}
\pgfkeys{/PYTX/pkgopt/makestderr/.is choice}
\pgfkeys{/PYTX/pkgopt/makestderr/true/.code=\booltrue{pytx@opt@stderr}}
\pgfkeys{/PYTX/pkgopt/makestderr/false/.code=\boolfalse{pytx@opt@stderr}}
\pgfkeys{/PYTX/pkgopt/stderr/.default=true}
\pgfkeys{/PYTX/pkgopt/stderr/.is choice}
\pgfkeys{/PYTX/pkgopt/stderr/true/.code=\booltrue{pytx@opt@stderr}%
    \PackageWarning{\pytx@packagename}{Option stderr is deprecated; use option makestderr}}
\pgfkeys{/PYTX/pkgopt/stderr/false/.code=\boolfalse{pytx@opt@stderr}%
    \PackageWarning{\pytx@packagename}{Option stderr is deprecated; use option makestderr}}

\def\pytx@opt@stderrfilename{full}
\pgfkeys{/PYTX/pkgopt/stderrfilename/.default=full}
\pgfkeys{/PYTX/pkgopt/stderrfilename/.is choice}
\pgfkeys{/PYTX/pkgopt/stderrfilename/full/.code=\def\pytx@opt@stderrfilename{full}}
\pgfkeys{/PYTX/pkgopt/stderrfilename/session/.code=\def\pytx@opt@stderrfilename{session}}
\pgfkeys{/PYTX/pkgopt/stderrfilename/genericfile/.code=%
    \def\pytx@opt@stderrfilename{genericfile}}
\pgfkeys{/PYTX/pkgopt/stderrfilename/genericscript/.code=%
    \def\pytx@opt@stderrfilename{genericscript}}
\def\pytx@opt@pyfuture{default}
\pgfkeys{/PYTX/pkgopt/pyfuture/.is choice}
\pgfkeys{/PYTX/pkgopt/pyfuture/default/.code=\def\pytx@opt@pyfuture{default}}
\pgfkeys{/PYTX/pkgopt/pyfuture/all/.code=\def\pytx@opt@pyfuture{all}}
\pgfkeys{/PYTX/pkgopt/pyfuture/none/.code=\def\pytx@opt@pyfuture{none}}
\def\pytx@opt@pyconfuture{none}
\pgfkeys{/PYTX/pkgopt/pyconfuture/.is choice}
\pgfkeys{/PYTX/pkgopt/pyconfuture/default/.code=\def\pytx@opt@pyconfuture{default}}
\pgfkeys{/PYTX/pkgopt/pyconfuture/all/.code=\def\pytx@opt@pyconfuture{all}}
\pgfkeys{/PYTX/pkgopt/pyconfuture/none/.code=\def\pytx@opt@pyconfuture{none}}
\newbool{pytx@opt@upquote}
\booltrue{pytx@opt@upquote}
\pgfkeys{/PYTX/pkgopt/upquote/.default=true}
\pgfkeys{/PYTX/pkgopt/upquote/.is choice}
\pgfkeys{/PYTX/pkgopt/upquote/true/.code=\booltrue{pytx@opt@upquote}}
\pgfkeys{/PYTX/pkgopt/upquote/false/.code=\boolfalse{pytx@opt@upquote}}
\newbool{pytx@opt@fixlr}
\pgfkeys{/PYTX/pkgopt/fixlr/.default=true}
\pgfkeys{/PYTX/pkgopt/fixlr/.is choice}
\pgfkeys{/PYTX/pkgopt/fixlr/true/.code=\booltrue{pytx@opt@fixlr}}
\pgfkeys{/PYTX/pkgopt/fixlr/false/.code=\boolfalse{pytx@opt@fixlr}}
\def\pytx@opt@keeptemps{none}
\pgfkeys{/PYTX/pkgopt/keeptemps/.default=all}
\pgfkeys{/PYTX/pkgopt/keeptemps/.is choice}
\pgfkeys{/PYTX/pkgopt/keeptemps/all/.code=\def\pytx@opt@keeptemps{all}}
\pgfkeys{/PYTX/pkgopt/keeptemps/code/.code=\def\pytx@opt@keeptemps{code}}
\pgfkeys{/PYTX/pkgopt/keeptemps/none/.code=\def\pytx@opt@keeptemps{none}}
\newbool{pytx@opt@pygments}
\booltrue{pytx@opt@pygments}
\pgfkeys{/PYTX/pkgopt/prettyprinter/.is choice}
\pgfkeys{/PYTX/pkgopt/prettyprinter/pygments/.code=\booltrue{pytx@opt@pygments}}
\pgfkeys{/PYTX/pkgopt/prettyprinter/fancyvrb/.code=\boolfalse{pytx@opt@pygments}}
\pgfkeys{/PYTX/pkgopt/pygments/.default=true}
\pgfkeys{/PYTX/pkgopt/pygments/.is choice}
\pgfkeys{/PYTX/pkgopt/pygments/true/.code=\booltrue{pytx@opt@pygments}}
\pgfkeys{/PYTX/pkgopt/pygments/false/.code=\boolfalse{pytx@opt@pygments}}
\newbool{pytx@opt@pyginline}
\booltrue{pytx@opt@pyginline}
\pgfkeys{/PYTX/pkgopt/prettyprintinline/.default=true}
\pgfkeys{/PYTX/pkgopt/prettyprintinline/.is choice}
\pgfkeys{/PYTX/pkgopt/prettyprintinline/true/.code=\booltrue{pytx@opt@pyginline}}
\pgfkeys{/PYTX/pkgopt/prettyprintinline/false/.code=\boolfalse{pytx@opt@pyginline}}
\pgfkeys{/PYTX/pkgopt/pyginline/.default=true}
\pgfkeys{/PYTX/pkgopt/pyginline/.is choice}
\pgfkeys{/PYTX/pkgopt/pyginline/true/.code=\booltrue{pytx@opt@pyginline}}
\pgfkeys{/PYTX/pkgopt/pyginline/false/.code=\boolfalse{pytx@opt@pyginline}}
\def\pytx@pyglexer{}
\pgfkeys{/PYTX/pkgopt/pyglexer/.code=\def\pytx@pyglexer{#1}}
\def\pytx@pygopt{}
\pgfkeys{/PYTX/pkgopt/pygopt/.code=\def\pytx@pygopt{#1}}
\def\pytx@fvextfile{-1}
\pgfkeys{/PYTX/pkgopt/fvextfile/.default=25}
\pgfkeys{/PYTX/pkgopt/fvextfile/.code=\IfInteger{#1}{%
    \ifnum#1>0\relax
        \def\pytx@fvextfile{#1}%
    \else
        \PackageError{\pytx@packagename}{option fvextfile must be an integer > 0}{}%
    \fi}%
    {\PackageError{\pytx@packagename}{option fvextfile must be an integer > 0}{}}%
}
\def\pytx@opt@pyconbanner{none}
\pgfkeys{/PYTX/pkgopt/pyconbanner/.is choice}
\pgfkeys{/PYTX/pkgopt/pyconbanner/none/.code=\def\pytx@opt@pyconbanner{none}}
\pgfkeys{/PYTX/pkgopt/pyconbanner/standard/.code=\def\pytx@opt@pyconbanner{standard}}
\pgfkeys{/PYTX/pkgopt/pyconbanner/default/.code=\def\pytx@opt@pyconbanner{default}}
\pgfkeys{/PYTX/pkgopt/pyconbanner/pyversion/.code=\def\pytx@opt@pyconbanner{pyversion}}
\def\pytx@opt@pyconfilename{stdin}
\pgfkeys{/PYTX/pkgopt/pyconfilename/.is choice}
\pgfkeys{/PYTX/pkgopt/pyconfilename/stdin/.code=\def\pytx@opt@pyconfilename{stdin}}
\pgfkeys{/PYTX/pkgopt/pyconfilename/console/.code=\def\pytx@opt@pyconfilename{console}}
\newbool{pytx@opt@depythontex}
\pgfkeys{/PYTX/pkgopt/depythontex/.default=true}
\pgfkeys{/PYTX/pkgopt/depythontex/.is choice}
\pgfkeys{/PYTX/pkgopt/depythontex/true/.code=\booltrue{pytx@opt@depythontex}}
\pgfkeys{/PYTX/pkgopt/depythontex/false/.code=\boolfalse{pytx@opt@depythontex}}
\let\Depythontex\@gobble
\let\DepyFile\@gobble
\let\DepyMacro\@gobble
\let\DepyListing\@empty
\ProcessPgfPackageOptions{/PYTX/pkgopt}
\ifbool{pytx@opt@fixlr}{
    \IfStrEq{\detokenize\expandafter{\left}}{\detokenize{\left}}{
        \let\originalleft\left
        \let\originalright\right
        \renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
        \renewcommand{\right}{\aftergroup\egroup\originalright}
    }{}
}{}
\ifbool{pytx@opt@upquote}{\RequirePackage{upquote}}{}
\ifbool{pytx@opt@depythontex}{\boolfalse{pytx@opt@pygments}}{}
\def\pytx@CheckCounter#1{%
    \ifcsname c@#1\endcsname\else\newcounter{#1}\fi
}
\def\pytx@SVMCR#1{%
    \edef\pytx@tmp{\csname #1\endcsname}%
    \begingroup
    \endlinechar`\^^J
    \let\do\@makeother\dospecials
    \pytx@SVMCR@i}
\begingroup
\catcode`!=0
!catcode`!\=12
!long!gdef!pytx@SVMCR@i#1\endpytx@SVMCR^^J{%
    !endgroup
    !expandafter!gdef!pytx@tmp{%
        !expandafter!scantokens!expandafter{#1!empty}}%
}%
!endgroup
\expandafter\ifx\csname directlua\endcsname\relax\else
\def\pytx@SVMCR#1 {%
    \edef\pytx@tmp{\csname #1\endcsname}%
    \pytx@SVMCR@i}
\long\def\pytx@SVMCR@i#1\endpytx@SVMCR{%
    \expandafter\gdef\pytx@tmp{#1}%
}
\fi
\newcommand{\definepythontexcontext}[1]{%
    \def\pytx@SetContext{%
        \edef\pytx@context{#1}%
    }%
}
\definepythontexcontext{}
\@onlypreamble\definepythontexcontext
\newcommand{\restartpythontexsession}[1]{%
    \Depythontex{cmd:restartpythontexsession:m:n}%
    \def\pytx@SetGroup{%
        \edef\pytx@group{#1}%
    }%
    \def\pytx@SetGroupVerb{%
        \edef\pytx@group{#1verb}%
    }%
    \def\pytx@SetGroupCons{%
        \edef\pytx@group{#1cons}%
    }%
    \AtBeginDocument{%
        \pytx@SetGroup
        \IfSubStr{\pytx@group}{verb}{%
            \PackageError{\pytx@packagename}%
                {String "verb" is not allowed in \string\restartpythontexsession}%
                {Use \string\restartpythontexsession with a valid argument}}{}%
        \IfSubStr{\pytx@group}{cons}{%
            \PackageError{\pytx@packagename}%
                {String "cons" is not allowed in \string\restartpythontexsession}%
                {Use \string\restartpythontexsession with a valid argument}}{}%
    }%
}
\@onlypreamble\restartpythontexsession
\restartpythontexsession{default}
\StrSubstitute{\jobname}{ }{-}[\pytx@jobname]
\StrSubstitute{\pytx@jobname}{"}{}[\pytx@jobname]
\StrSubstitute{\pytx@jobname}{*}{-}[\pytx@jobname]
\newcommand{\setpythontexoutputdir}[1]{%
    \Depythontex{cmd:setpythontexoutputdir:m:n}%
    \def\pytx@outputdir{#1}}
\setpythontexoutputdir{pythontex-files-\pytx@jobname}
\AtBeginDocument{%
    \@ifpackageloaded{graphicx}{%
        \ifx\Ginput@path\@undefined
            \graphicspath{{\pytx@outputdir/}}%
        \else
            \g@addto@macro\Ginput@path{{\pytx@outputdir/}}%
        \fi
    }{}%
}
\@onlypreamble\setpythontexoutputdir
\newcommand{\setpythontexworkingdir}[1]{%
    \Depythontex{cmd:setpythontexworkingdir:m:n}%
    \def\pytx@workingdir{#1}%
}
\@onlypreamble\setpythontexworkingdir
\AtBeginDocument{%
    \ifcsname pytx@workingdir\endcsname\else
        %\setpythontexworkingdir{\pytx@outputdir}\fi Depythontex
        \let\pytx@workingdir\pytx@outputdir\fi
}
\newbool{pytx@usedpygments}
\AfterEndPreamble{%
    \ifbool{pytx@usedpygments}%
        {\InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxpyg}{}{}}{}%
}
\AtBeginDocument{%
    \makeatletter
    \InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxmcr}{}{}%
    \makeatother
}
\newwrite\pytx@codefile
\immediate\openout\pytx@codefile=\jobname.pytxcode
\edef\pytx@delimchar{\string#}
\edef\pytx@delim{=\string>PYTHONTEX\string#}
\edef\pytx@delimsettings{=\string>PYTHONTEX:SETTINGS\string#}
\AtEndDocument{%
    \immediate\write\pytx@codefile{\pytx@delimsettings}%
    \immediate\write\pytx@codefile{version=\pytx@packageversion}%
    \immediate\write\pytx@codefile{outputdir=\pytx@outputdir}%
    \immediate\write\pytx@codefile{workingdir=\pytx@workingdir}%
    \immediate\write\pytx@codefile{gobble=\pytx@opt@gobble}%
    \immediate\write\pytx@codefile{rerun=\pytx@opt@rerun}%
    \immediate\write\pytx@codefile{hashdependencies=\pytx@opt@hashdependencies}%
    \immediate\write\pytx@codefile{makestderr=\ifbool{pytx@opt@stderr}{true}{false}}%
    \immediate\write\pytx@codefile{stderrfilename=\pytx@opt@stderrfilename}%
    \immediate\write\pytx@codefile{keeptemps=\pytx@opt@keeptemps}%
    \immediate\write\pytx@codefile{pyfuture=\pytx@opt@pyfuture}%
    \immediate\write\pytx@codefile{pyconfuture=\pytx@opt@pyconfuture}%
    \immediate\write\pytx@codefile{pygments=\ifbool{pytx@opt@pygments}{true}{false}}%
    \immediate\write\pytx@codefile{pygglobal=:GLOBAL|\pytx@pyglexer|\pytx@pygopt}%
    \immediate\write\pytx@codefile{fvextfile=\pytx@fvextfile}%
    \immediate\write\pytx@codefile{pyconbanner=\pytx@opt@pyconbanner}%
    \immediate\write\pytx@codefile{pyconfilename=\pytx@opt@pyconfilename}%
    \immediate\write\pytx@codefile{depythontex=\ifbool{pytx@opt@depythontex}{true}{false}}%
}
\def\pytx@argsrun{}
\def\pytx@argspprint{}
\def\pytx@WriteCodefileInfo{%
    \ifcurrfile{\currfilebase}{\jobname}%
        {\let\pytx@currfile\@empty}{\let\pytx@currfile\currfilename}%
    \immediate\write\pytx@codefile{\pytx@delim\pytx@type\pytx@delimchar%
        \pytx@session\pytx@delimchar\pytx@group\pytx@delimchar%
        \arabic{\pytx@counter}\pytx@delimchar\pytx@cmd\pytx@delimchar%
        \pytx@context\pytx@delimchar\pytx@argsrun\pytx@delimchar%
        \pytx@argspprint\pytx@delimchar%
        \pytx@currfile\pytx@delimchar%
        \the\inputlineno\pytx@delimchar}%
}
\newcommand{\pytx@WriteCodefileInfoExt}[1][]{%
    \ifcurrfile{\currfilebase}{\jobname}%
            {\let\pytx@currfile\@empty}{\let\pytx@currfile\currfilename}%
    \immediate\write\pytx@codefile{\pytx@delim\pytx@type\pytx@delimchar%
        \pytx@session\pytx@delimchar\pytx@group\pytx@delimchar%
        0\pytx@delimchar\pytx@cmd\pytx@delimchar%
        \pytx@context\pytx@delimchar\pytx@argsrun\pytx@delimchar%
        \pytx@argspprint\pytx@delimchar%
        \pytx@currfile\pytx@delimchar%
        \the\inputlineno\pytx@delimchar#1}%
}
\newcommand{\setpythontexfv}[2][]{%
    \Depythontex{cmd:setpythontexfv:om:n}%
    \ifstrempty{#1}%
        {\gdef\pytx@fvsettings{#2}}%
        {\expandafter\gdef\csname pytx@fvsettings@#1\endcsname{#2}}%
}%
\setpythontexfv{tabsize=4}
\def\pytx@FVSet{%
    \expandafter\let\expandafter\pytx@fvsettings@@%
        \csname pytx@fvsettings@\pytx@type\endcsname
    \ifdefstring{\pytx@fvsettings@@}{}%
        {}%
        {\expandafter\fvset\expandafter{\pytx@fvsettings@@}}%
    \ifdefstring{\pytx@fvsettings}{}%
        {}%
        {\expandafter\fvset\expandafter{\pytx@fvsettings}}%
}

\newcounter{pytx@FancyVerbLineTemp}
\def\pytx@FVB@SaveVerbatim#1{%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \@bsphack
    \begingroup
    \FV@UseKeyValues
    \def\SaveVerbatim@Name{#1}%
    \def\FV@ProcessLine##1{%
        \expandafter\gdef\expandafter\FV@TheVerbatim\expandafter{%
        \FV@TheVerbatim\FV@StepLineNo\FV@ProcessLine{##1}}}%
    \gdef\FV@TheVerbatim{\FV@CodeLineNo=1}%
    \FV@Scan}
\def\pytx@FVE@SaveVerbatim{%
    \expandafter\global\expandafter\let
    \csname FV@SV@\SaveVerbatim@Name\endcsname\FV@TheVerbatim
    \endgroup\@esphack
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}}
\let\FVB@SaveVerbatim\pytx@FVB@SaveVerbatim
\let\FVE@SaveVerbatim\pytx@FVE@SaveVerbatim
\def\pytx@stdfile{}
\def\pytx@stdout@warntext{}
\def\pytx@FetchStdoutfile[#1][#2]#3{%
    \IfFileExists{\pytx@outputdir/#3.stdout}{%
        \ifstrempty{#1}{\input{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{verb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{verbatim}{\VerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}%
        \DepyFile{p:\pytx@outputdir/#3.stdout:mode=#1}%
    }%
    {\pytx@stdout@warntext
        \PackageWarning{\pytx@packagename}{Non-existent printed content}}%
}
\ifbool{pytx@opt@stdout}{}{\def\pytx@FetchStdoutfile[#1][#2]#3{}}
\AtBeginDocument{\def\pytx@stdout@warntext{\textbf{??~\pytx@packagename~??}}}
\def\stdoutpythontex{%
    \Depythontex{cmd:stdoutpythontex:oo:p}%
    \@ifnextchar[{\pytx@Stdout}{\pytx@Stdout[raw]}%
}
\def\pytx@Stdout[#1]{%
    \@ifnextchar[{\pytx@Stdout@i[#1]}{\pytx@Stdout@i[#1][]}%
}
\def\pytx@Stdout@i[#1][#2]{%
    \pytx@FetchStdoutfile[#1][#2]{\pytx@stdfile}%
}
\def\printpythontex{%
    \Depythontex{cmd:printpythontex:oo:p}%
    \@ifnextchar[{\pytx@Stdout}{\pytx@Stdout[raw]}%
}
\def\savestdoutpythontex{%
    \Depythontex{cmd:savestdoutpythontex:m:n}%
    \savestdoutpythontex@i
}
\def\savestdoutpythontex@i#1{%
    \ifcsname pytx@SVout@#1\endcsname
        \PackageError{\pytx@packagename}%
            {Attempt to save content using an already-defined name}%
            {Use a name that is not already defined}%
    \else
        \expandafter\edef\csname pytx@SVout@#1\endcsname{\pytx@stdfile}%
    \fi
}
\def\saveprintpythontex{%
    \Depythontex{cmd:saveprintpythontex:m:n}%
    \savestdoutpythontex@i
}
\def\usestdoutpythontex{%
    \Depythontex{cmd:usestdoutpythontex:oom:p}%
    \@ifnextchar[{\pytx@UseStdout}{\pytx@UseStdout[]}%
}
\def\pytx@UseStdout[#1]{%
    \@ifnextchar[{\pytx@UseStdout@i[#1]}{\pytx@UseStdout@i[#1][]}%
}
\def\pytx@UseStdout@i[#1][#2]#3{%
    \ifcsname pytx@SVout@#3\endcsname
        \pytx@FetchStdoutfile[#1][#2]{\csname pytx@SVout@#3\endcsname}%
    \else
        \textbf{??~\pytx@packagename~??}%
        \PackageWarning{\pytx@packagename}{Non-existent saved printed content}%
    \fi
}
\def\useprintpythontex{%
    \Depythontex{cmd:useprintpythontex:oom:p}%
    \@ifnextchar[{\pytx@UseStdout}{\pytx@UseStdout[]}%
}
\def\pytx@FetchStderrfile[#1][#2]#3{%
    \IfFileExists{\pytx@outputdir/#3.stderr}{%
        \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stderr}}{}%
        \ifstrempty{#1}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \ifstrequal{#1}{verb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \ifstrequal{#1}{verbatim}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \DepyFile{p:\pytx@outputdir/#3.stderr:mode=#1}%
    }%
    {\textbf{??~\pytx@packagename~??}%
        \PackageWarning{\pytx@packagename}{Non-existent stderr content}}%
}
\def\stderrpythontex{%
    \Depythontex{cmd:stderrpythontex:oo:p}%
    \@ifnextchar[{\pytx@Stderr}{\pytx@Stderr[verbatim]}%
}
\def\pytx@Stderr[#1]{%
    \@ifnextchar[{\pytx@Stderr@i[#1]}{\pytx@Stderr@i[#1][]}%
}
\def\pytx@Stderr@i[#1][#2]{%
    \pytx@FetchStderrfile[#1][#2]{\pytx@stdfile}%
}
\def\savestderrpythontex#1{%
    \Depythontex{cmd:savestderrpythontex:m:n}%
    \ifcsname pytx@SVerr@#1\endcsname
        \PackageError{\pytx@packagename}%
            {Attempt to save content using an already-defined name}%
            {Use a name that is not already defined}%
    \else
        \expandafter\edef\csname pytx@SVerr@#1\endcsname{\pytx@stdfile}%
    \fi
}
\def\usestderrpythontex{%
    \Depythontex{cmd:usestderrpythontex:oom:p}%
    \@ifnextchar[{\pytx@UseStderr}{\pytx@UseStderr[verb]}%
}
\def\pytx@UseStderr[#1]{%
    \@ifnextchar[{\pytx@UseStderr@i[#1]}{\pytx@UseStderr@i[#1][]}%
}
\def\pytx@UseStderr@i[#1][#2]#3{%
    \ifcsname pytx@SVerr@#3\endcsname
        \pytx@FetchStderrfile[#1][#2]{\csname pytx@SVerr@#3\endcsname}%
    \else
        \textbf{??~\pytx@packagename~??}%
        \PackageWarning{\pytx@packagename}{Non-existent saved stderr content}%
    \fi
}
\ifbool{pytx@opt@depythontex}{%
    \newwrite\pytx@depyfile
    \immediate\openout\pytx@depyfile=\jobname.depytx
}{}
\let\pytx@lexer\relax
\def\Depythontex@orig#1{%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX\pytx@delimchar#1:%
        \the\inputlineno:\ifx\pytx@lexer\relax\else\pytx@lexer\fi\pytx@delimchar}%
    \let\pytx@lexer\relax}
\ifbool{pytx@opt@depythontex}%
    {\let\Depythontex\Depythontex@orig}%
    {\let\Depythontex\@gobble}
\ifbool{pytx@opt@depythontex}{%
\AtEndDocument{%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX:SETTINGS\pytx@delimchar version=%
        \pytx@packageversion\pytx@delimchar}%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX:SETTINGS\pytx@delimchar macrofile=%
        \pytx@outputdir/\pytx@jobname.pytxmcr\pytx@delimchar}%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX:SETTINGS\pytx@delimchar outputdir=%
        \pytx@outputdir\pytx@delimchar}%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX:SETTINGS\pytx@delimchar graphicx=%
            \ifcsname graphicspath\endcsname true\else false\fi\pytx@delimchar}%
    \immediate\write\pytx@depyfile{=>DEPYTHONTEX:SETTINGS\pytx@delimchar gobble=%
            \pytx@opt@gobble\pytx@delimchar}%
}%
}{}
\def\DepyMacro@orig#1{%
    \immediate\write\pytx@depyfile{MACRO:#1}%
}
\ifbool{pytx@opt@depythontex}%
    {\let\DepyMacro\DepyMacro@orig}%
    {\let\DepyMacro\@gobble}

\def\DepyFile@orig#1{%
    \immediate\write\pytx@depyfile{FILE:#1}%
}%
\ifbool{pytx@opt@depythontex}%
    {\let\DepyFile\DepyFile@orig}%
    {\let\DepyFile\@gobble}
\newcommand{\pytx@DepyListing@write}{%
    \immediate\write\pytx@depyfile{LISTING:firstnumber=\arabic{FancyVerbLine}}%
}
\def\DepyListing@orig{%
    \let\oldFancyVerbLine\theFancyVerbLine
    \def\theFancyVerbLine{%
        \pytx@DepyListing@write
        \expandafter\gdef\expandafter\theFancyVerbLine\expandafter{\oldFancyVerbLine}%
        \theFancyVerbLine
    }%
}
\ifbool{pytx@opt@depythontex}%
    {\let\DepyListing\DepyListing@orig}%
    {\let\DepyListing\@empty}
\newcommand{\DepythontexOn}{%
    \let\Depythontex\Depythontex@orig
    \let\DepyMacro\DepyMacro@orig
    \let\DepyFile\DepyFile@orig
    \let\DepyListing\DepyListing@orig
}
\newcommand{\DepythontexOff}{%
    \let\Depythontex\@gobble
    \let\DepyMacro\@gobble
    \let\DepyFile\@gobble
    \let\DepyListing\@empty
}
\def\pytx@Inline{%
    \begingroup
    \let\do\@makeother\dospecials
    \catcode`\{=1
    \@ifnextchar[{\endgroup\pytx@InlineOarg}{\endgroup\pytx@InlineOarg[]}%
}%
\def\pytx@InlineOarg[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \begingroup
    \let\do\@makeother\dospecials
    \catcode`\{=1
    \catcode`\}=2
    \catcode`\ =\active
    \catcode`\^^I=\active
    \@ifnextchar\bgroup
        {\pytx@InlineMargBgroup}%
        {\catcode`\{=12
            \catcode`\}=12
            \pytx@InlineMargOther}%
}
\def\pytx@InlineMargOther#1{%
    \endgroup
    \ifstrequal{#1}{ }{%
        \PackageError{\pytx@packagename}%
            {The space character cannot be used as a delimiting character}%
            {Choose another delimiting character}}{}%
    \def\pytx@InlineMargOtherGet##1#1{\pytx@InlineMargBgroup{##1}}%
    \begingroup
    \let\do\@makeother\dospecials
    \pytx@InlineMargOtherGet
}
\def\pytx@InlineMargBgroup#1{%
    \endgroup
    \def\pytx@argdetok{\detokenize{#1}}%
    \def\pytx@arg{#1}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \pytx@InlineShow
    \pytx@InlineSave
    \pytx@InlinePrint
    \stepcounter{\pytx@counter}%
}%
\def\pytx@InlineShowFV{%
    \def\pytx@argretok{%
        \begingroup
        \everyeof{\noexpand}%
        \endlinechar-1\relax
        \let\do\@makeother\dospecials
        \catcode`\ =\active
        \catcode`\^^I=\active
        \expandafter\scantokens\expandafter{\pytx@arg}%
        \endgroup}%
    \begingroup
    \pytx@FVSet
    \FV@BeginVBox
    \frenchspacing
    \FV@SetupFont
    \FV@DefineWhiteSpace
    \FancyVerbDefineActive
    \FancyVerbFormatCom
    \FV@ObeyTabsInit
    \hbox{\FancyVerbFormatLine{\pytx@argretok}}%
    \FV@EndVBox
    \endgroup
}
\def\pytx@InlineShowPyg{%
    \begingroup
    \pytx@FVSet
    \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
        \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
        \BUseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
        \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \else
        \textbf{??}%
        \PackageWarning{\pytx@packagename}{Non-existent Pygments content}%
    \fi
    \endgroup
}
\def\pytx@InlineSaveCode{%
    \pytx@WriteCodefileInfo
    \immediate\write\pytx@codefile{\pytx@argdetok}%
}
\let\pytx@InlineAutoprint\@empty
\AtBeginDocument{
    \def\pytx@InlineAutoprint{%
        \ifbool{pytx@opt@autoprint}{%
            \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}%
                {\DepyFile{p:\pytx@outputdir/\pytx@stdfile.stdout}}{}}{}%
    }
    \ifbool{pytx@opt@stdout}{}{\let\pytx@InlineAutoprint\@empty}
}
\def\pytx@InlineMacroprint{%
    \edef\pytx@mcr{pytx@MCR@\pytx@type @\pytx@session @\pytx@group @\arabic{\pytx@counter}}%
    \ifcsname\pytx@mcr\endcsname
        \csname\pytx@mcr\endcsname
        \DepyMacro{p:\pytx@mcr}%
    \else
        \textbf{??}%
        \PackageWarning{\pytx@packagename}{Missing autoprint content}%
    \fi
}
\ifbool{pytx@opt@stdout}{}{\let\pytx@InlineMacroprint\@empty}
\def\pytx@InlineMacroprintFV{%
    \edef\pytx@mcr{pytx@\pytx@type @\pytx@session @\pytx@group @\arabic{\pytx@counter}}%
    \ifcsname FV@SV@\pytx@mcr\endcsname
        \BUseVerbatim{\pytx@mcr}%
        \DepyMacro{c:\pytx@mcr}%
    \else
        \textbf{??}%
        \PackageWarning{\pytx@packagename}{Missing autoprint content}%
    \fi
}
\ifbool{pytx@opt@stdout}{}{\let\pytx@InlineMacroprint\@empty}
\newcommand{\pytx@MakeInlinebFV}[1]{%
    \expandafter\newcommand\expandafter{\csname #1b\endcsname}{%
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{cmd:#1b:ov:c}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{b}%
        \pytx@SetContext
        \pytx@SetGroup
        \let\pytx@InlineShow\pytx@InlineShowFV
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\@empty
        \pytx@Inline
    }%
}%
\newcommand{\pytx@MakeInlinebPyg}[1]{%
    \expandafter\newcommand\expandafter{\csname #1b\endcsname}{%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{b}%
        \pytx@SetContext
        \pytx@SetGroup
        \let\pytx@InlineShow\pytx@InlineShowPyg
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\@empty
        \pytx@Inline
    }%
}%
\newcommand{\pytx@MakeInlinevFV}[1]{%
    \expandafter\newcommand\expandafter{\csname #1v\endcsname}{%
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{cmd:#1v:ov:c}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{v}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \let\pytx@InlineShow\pytx@InlineShowFV
        \let\pytx@InlineSave\@empty
        \let\pytx@InlinePrint\@empty
        \pytx@Inline
    }%
}%
\newcommand{\pytx@MakeInlinevPyg}[1]{%
    \expandafter\newcommand\expandafter{\csname #1v\endcsname}{%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{v}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \let\pytx@InlineShow\pytx@InlineShowPyg
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\@empty
        \pytx@Inline
    }%
}%
\newcommand{\pytx@MakeInlinecFV}[1]{%
    \expandafter\newcommand\expandafter{\csname #1c\endcsname}{%
        \Depythontex{cmd:#1c:ov:p}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{c}%
        \pytx@SetContext
        \pytx@SetGroup
        \let\pytx@InlineShow\@empty
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\pytx@InlineAutoprint
        \pytx@Inline
    }%
}%
\let\pytx@MakeInlinecPyg\pytx@MakeInlinecFV
\newcommand{\pytx@MakeInlineFV}[1]{%
    \expandafter\newcommand\expandafter{\csname #1\endcsname}{%
        \Depythontex{cmd:#1:ov:p}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{i}%
        \pytx@SetContext
        \pytx@SetGroup
        \let\pytx@InlineShow\@empty
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\pytx@InlineMacroprint
        \pytx@Inline
    }%
}%
\let\pytx@MakeInlinePyg\pytx@MakeInlineFV
\newcommand{\pytx@MakeInlineConsFV}[1]{%
    \expandafter\newcommand\expandafter{\csname #1\endcsname}{%
        \Depythontex{cmd:#1:ov:c}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{i}%
        \pytx@SetContext
        \pytx@SetGroup
        \let\pytx@InlineShow\@empty
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\pytx@InlineMacroprintFV
        \pytx@Inline
    }%
}%
\let\pytx@MakeInlineConsPyg\pytx@MakeInlineConsFV
\newcommand{\pythontexcustomc}[2][begin]{%
    \Depythontex{cmd:pythontexcustomc:omv:p}%
    \ifstrequal{#1}{begin}{}{%
        \ifstrequal{#1}{end}{}{\PackageError{\pytx@packagename}%
            {Invalid optional argument for \string\pythontexcustomc}{}
        }%
    }%
    \xdef\pytx@type{CC:#2:#1}%
    \edef\pytx@cmd{c}%
    \def\pytx@context{}%
    \def\pytx@group{none}%
    \let\pytx@InlineShow\@empty
    \let\pytx@InlineSave\pytx@InlineSaveCode
    \let\pytx@InlinePrint\@empty
    \pytx@Inline[none]%
}%
\def\setpythontexcustomcode#1{%
    \Depythontex{cmd:setpythontexcustomcode:mv:p}%
    \PackageWarning{\pytx@packagename}{The command
        \string\setpythontexcustomcode\space has been deprecated;
        use \string\pythontexcustomc\space or pythontexcustomcode instead}%
    \begingroup
    \let\do\@makeother\dospecials
    \catcode`\{=1
    \catcode`\}=2
    \catcode`\^^M=10\relax
    \pytx@SetCustomCode{#1}%
}
\long\def\pytx@SetCustomCode#1#2{%
    \endgroup
    \pythontexcustomc{#1}{pythontexcustomcode=[#2];
        exec('for expr in pythontexcustomcode: exec(expr)');
        del(pythontexcustomcode)}
}
\@onlypreamble\setpythontexcustomcode
\begingroup
\catcode`\^^M=\active
\gdef\pytx@FancyVerbGetLine#1^^M{%
    \@nil%
    \FV@CheckEnd{#1}%
    \ifx\@tempa\FV@EnvironName%
        \ifx\@tempb\FV@@@CheckEnd\else\FV@BadEndError\fi%
        \let\next\FV@EndScanning%
    \else%
        \def\FV@Line{#1}%
        \def\next{\FV@PreProcessLine\FV@GetLine}%
        \immediate\write\pytx@codefile{\detokenize{#1}}%
    \fi%
    \next}%
\endgroup
\newcommand{\pytx@MakeBlockFV}[1]{%
    \expandafter\newenvironment{#1block}{%
        \VerbatimEnvironment
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{env:#1block:oo|:c}%
        \DepyListing
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{block}%
        \pytx@SetContext
        \pytx@SetGroup
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginBlockEnvFV}{\endgroup\pytx@BeginBlockEnvFV[]}%
    }%
    {\end{Verbatim}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}
\def\pytx@BeginBlockEnvFV[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \edef\pytx@linecount{\pytx@counter @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@WriteCodefileInfo
    \let\FancyVerbGetLine\pytx@FancyVerbGetLine
    \pytx@FVSet
    \begin{Verbatim}%
}
\newcommand{\pytx@MakeVerbFV}[1]{%
    \expandafter\newenvironment{#1verbatim}{%
        \VerbatimEnvironment
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{env:#1verbatim:oo|:c}%
        \DepyListing
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{verbatim}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginVerbEnvFV}{\endgroup\pytx@BeginVerbEnvFV[]}%
    }%
    {\end{Verbatim}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}
\def\pytx@BeginVerbEnvFV[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \edef\pytx@linecount{\pytx@counter @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \begin{Verbatim}%
}
\newcommand{\pytx@MakePygEnv}[2]{%
    \expandafter\newenvironment{#1#2}{%
        \VerbatimEnvironment
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{#2}%
        \pytx@SetContext
        \ifstrequal{#2}{block}{\pytx@SetGroup}{}
        \ifstrequal{#2}{verbatim}{\pytx@SetGroupVerb}{}
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginEnvPyg}{\endgroup\pytx@BeginEnvPyg[]}%
    }%
    {\end{VerbatimOut}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
    \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
        \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
    \else
        \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.pygtex}{}%
            {\textbf{??~\pytx@packagename~??}%
                \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}%
    \fi
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}%
\def\pytx@BeginEnvPyg[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \edef\pytx@linecount{\pytx@counter @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \pytx@WriteCodefileInfo
    \begingroup
    \obeylines
    \@ifnextchar[{\endgroup\pytx@BeginEnvPyg@i}{\endgroup\pytx@BeginEnvPyg@i[]}%
}%
\def\pytx@BeginEnvPyg@i[#1]{%
    \def\pytx@fvopttmp{#1}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut
    \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut
    \begin{VerbatimOut}%
}%
\newcommand{\pytx@MakeBlockPyg}[1]{\pytx@MakePygEnv{#1}{block}}
\newcommand{\pytx@MakeVerbPyg}[1]{\pytx@MakePygEnv{#1}{verbatim}}
\def\pytx@WriteDetok#1{%
    \immediate\write\pytx@codefile{\detokenize{#1}}}%
\def\pytx@FVB@VerbatimOut{%
    \@bsphack
    \begingroup
    \let\FV@ProcessLine\pytx@WriteDetok
    \let\FV@FontScanPrep\relax
    \let\@noligs\relax
    \FV@Scan}%
\def\pytx@FVE@VerbatimOut{\endgroup\@esphack}%
\let\pytx@EnvAutoprint\@empty
\AtBeginDocument{
    \def\pytx@EnvAutoprint{%
        \ifbool{pytx@opt@autoprint}{%
            \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}%
                {\DepyFile{p:\pytx@outputdir/\pytx@stdfile.stdout}}{}}{}%
    }
    \ifbool{pytx@opt@stdout}{}{\let\pytx@EnvAutoprint\@empty}
}
\newcommand{\pytx@MakeCodeFV}[1]{%
    \expandafter\newenvironment{#1code}{%
        \VerbatimEnvironment
        \Depythontex{env:#1code:oo|:p}%
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{code}%
        \pytx@SetContext
        \pytx@SetGroup
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginCodeEnv}{\endgroup\pytx@BeginCodeEnv[]}%
    }%
    {\end{VerbatimOut}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \pytx@EnvAutoprint
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}%
\def\pytx@BeginCodeEnv[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \pytx@WriteCodefileInfo
    \begingroup
    \obeylines
    \@ifnextchar[{\endgroup\pytx@BeginCodeEnv@i}{\endgroup\pytx@BeginCodeEnv@i[]}%
}%
\def\pytx@BeginCodeEnv@i[#1]{%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut
    \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut
    \begin{VerbatimOut}%
}%
\let\pytx@MakeCodePyg\pytx@MakeCodeFV
\newenvironment{pythontexcustomcode}[2][begin]{%
    \VerbatimEnvironment
    \Depythontex{env:pythontexcustomcode:om:n}%
    \ifstrequal{#1}{begin}{}{%
        \ifstrequal{#1}{end}{}{\PackageError{\pytx@packagename}%
            {Invalid optional argument for pythontexcustomcode}{}
        }%
    }%
    \xdef\pytx@type{CC:#2:#1}%
    \edef\pytx@cmd{code}%
    \def\pytx@context{}%
    \def\pytx@group{none}%
    \pytx@BeginCodeEnv[none]}%
{\end{VerbatimOut}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
}%
\newcommand{\pytx@MakeConsFV}[2]{%
    \expandafter\newenvironment{#1#2}{%
        \VerbatimEnvironment
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{env:#1#2:oo|:c}%
        \DepyListing
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{console}%
        \pytx@SetContext
        \pytx@SetGroup
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginConsEnvFV}{\endgroup\pytx@BeginConsEnvFV[]}%
    }%
    {\end{VerbatimOut}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
    \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
        \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
        \DepyMacro{c:\pytx@counter @\arabic{\pytx@counter}}%
    \else
        \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.tex}%
            {\DepyFile{c:\pytx@outputdir/\pytx@stdfile.tex}}%
            {\textbf{??~\pytx@packagename~??}%
                \PackageWarning{\pytx@packagename}{Non-existent console content}}%
    \fi
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}
\def\pytx@BeginConsEnvFV[#1]{%
    \ifstrempty{#1}{\edef\pytx@session{default}}{\StrSubstitute{#1}{:}{-}[\pytx@session]}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \edef\pytx@linecount{\pytx@counter @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \pytx@WriteCodefileInfo
    \begingroup
    \obeylines
    \@ifnextchar[{\endgroup\pytx@BeginConsEnvFV@i}{\endgroup\pytx@BeginConsEnvFV@i[]}%
}%
\def\pytx@BeginConsEnvFV@i[#1]{%
    \def\pytx@fvopttmp{#1}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut
    \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut
    \begin{VerbatimOut}%
}%
\newcommand{\pytx@MakeConsPyg}[2]{%
    \expandafter\newenvironment{#1#2}{%
        \VerbatimEnvironment
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{env:#1#2:oo|:c}%
        \DepyListing
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{console}%
        \pytx@SetContext
        \pytx@SetGroup
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginConsEnvFV}{\endgroup\pytx@BeginConsEnvFV[]}%
    }%
    {\end{VerbatimOut}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
    \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
        \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
        \DepyMacro{c:\pytx@counter @\arabic{\pytx@counter}}%
    \else
        \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.pygtex}%
            {\DepyFile{c:\pytx@outputdir/\pytx@stdfile.pygtex}}%
            {\textbf{??~\pytx@packagename~??}%
                \PackageWarning{\pytx@packagename}{Non-existent console content}}%
    \fi
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}
\pgfkeys{
    /PYTX/family/.is family,
    /PYTX/family,
    prettyprinter/.estore in = \pytx@tmp@pprinter,
    pyglexer/.estore in = \pytx@tmp@pyglexer,
    pygopt/.estore in = \pytx@tmp@pygopt,
    console/.estore in = \pytx@tmp@console,
    default/.style = {prettyprinter=auto, pyglexer=text, pygopt={}, console=false}
}
\def\pytx@MakeFamilyFV#1{%
    \pytx@MakeInlinebFV{#1}%
    \pytx@MakeInlinevFV{#1}%
    \pytx@MakeInlineFV{#1}%
    \pytx@MakeBlockFV{#1}%
    \pytx@MakeVerbFV{#1}%
}
\def\pytx@MakeFamilyPyg#1{%
    \ifbool{pytx@opt@pyginline}%
        {\pytx@MakeInlinebPyg{#1}\pytx@MakeInlinevPyg{#1}}%
        {\pytx@MakeInlinebFV{#1}\pytx@MakeInlinevFV{#1}}%
    \pytx@MakeInlinePyg{#1}%
    \pytx@MakeBlockPyg{#1}%
    \pytx@MakeVerbPyg{#1}%
    \booltrue{pytx@usedpygments}%
    \AtEndDocument{\immediate\write\pytx@codefile{pygfamily=#1|%
        \csname pytx@pyglexer@#1\endcsname|%
        \csname pytx@pygopt@#1\endcsname}%
    }%
}
\def\pytx@MakeFamilyFVCons#1{%
    \pytx@MakeInlinevFV{#1}%
    \pytx@MakeInlineConsFV{#1}%
    \pytx@MakeConsFV{#1}{sole}%
    \pytx@MakeVerbFV{#1}%
}
\def\pytx@MakeFamilyPygCons#1{%
    \ifbool{pytx@opt@pyginline}%
        {\pytx@MakeInlinevPyg{#1}}%
        {\pytx@MakeInlinevFV{#1}}%
    \pytx@MakeInlineConsPyg{#1}%
    \pytx@MakeConsPyg{#1}{sole}%
    \pytx@MakeVerbPyg{#1}%
    \booltrue{pytx@usedpygments}%
    \AtEndDocument{\immediate\write\pytx@codefile{pygfamily=#1|%
        \csname pytx@pyglexer@#1\endcsname|%
        \csname pytx@pygopt@#1\endcsname}%
    }%
}
\newcommand{\makepythontexfamily}[2][]{%
    \IfBeginWith{#2}{PYG}%
        {\PackageError{\pytx@packagename}%
            {Attempt to create macros with reserved prefix PYG}{}}{}%
    \pgfkeys{/PYTX/family, default, #1}
    \expandafter\xdef\csname pytx@macroformatter@#2\endcsname{\pytx@tmp@pprinter}
    \expandafter\gdef\csname pytx@fvsettings@#2\endcsname{}
    \expandafter\xdef\csname pytx@pyglexer@#2\endcsname{\pytx@tmp@pyglexer}
    \expandafter\xdef\csname pytx@pygopt@#2\endcsname{\pytx@tmp@pygopt}
    \expandafter\xdef\csname pytx@console@#2\endcsname{\pytx@tmp@console}
    \pytx@MakeInlinecFV{#2}
    \pytx@MakeCodeFV{#2}
    \AtBeginDocument{%
        \ifcsstring{pytx@macroformatter@#2}{auto}{%
            \ifbool{pytx@opt@pygments}%
                {\ifcsstring{pytx@console@#2}{true}%
                    {\pytx@MakeFamilyPygCons{#2}}{\pytx@MakeFamilyPyg{#2}}}%
                {\ifcsstring{pytx@console@#2}{true}%
                    {\pytx@MakeFamilyFVCons{#2}}{\pytx@MakeFamilyFV{#2}}}%
        }{}%
        \ifcsstring{pytx@macroformatter@#2}{fancyvrb}%
            {\ifcsstring{pytx@console@#2}{true}%
               {\pytx@MakeFamilyFVCons{#2}}{\pytx@MakeFamilyFV{#2}}}{}%
        \ifcsstring{pytx@macroformatter@#2}{pygments}%
            {\ifcsstring{pytx@console@#2}{true}%
                {\pytx@MakeFamilyPygCons{#2}}{\pytx@MakeFamilyPyg{#2}}}{}%
    }%
}
\@onlypreamble\makepythontexfamily
\newcommand{\setpythontexpyglexer}[2][]{%
    \Depythontex{cmd:setpythontexpyglexer:om:n}%
    \ifstrempty{#1}{\def\pytx@pyglexer{#2}}{%
        \ifcsname pytx@pyglexer@#1\endcsname
            \expandafter\xdef\csname pytx@pyglexer@#1\endcsname{#2}%
        \else
            \PackageError{\pytx@packagename}%
                {Cannot modify a non-existent family}{}%
        \fi
    }%
}%
\@onlypreamble\setpythontexpyglexer
\newcommand{\setpythontexpygopt}[2][]{%
    \Depythontex{cmd:setpythontexpygopt:om:n}%
    \ifstrempty{#1}{\def\pytx@pygopt{#2}}{%
    \ifcsname pytx@pygopt@#1\endcsname
        \expandafter\xdef\csname pytx@pygopt@#1\endcsname{#2}%
    \else
        \PackageError{\pytx@packagename}%
            {Cannot modify Pygments options for a non-existent family}{}%
    \fi
    }%
}
\@onlypreamble\setpythontexpygopt
\newcommand{\setpythontexprettyprinter}[2][]{%
    \Depythontex{cmd:setpythontexprettyprinter:om:n}%
    \ifstrempty{#1}{%
        \ifstrequal{#2}{fancyvrb}{\boolfalse{pytx@opt@pygments}}%
        \ifstrequal{#2}{pygments}{\booltrue{pytx@opt@pygments}}%
    }{%
        \ifcsname pytx@macroformatter@#1\endcsname
            \ifbool{pytx@opt@depythontex}{}{%
                \expandafter\xdef\csname pytx@macroformatter@#1\endcsname{#2}}
        \else
            \PackageError{\pytx@packagename}%
                {Cannot modify a family that does not exist or does not allow formatter choices}%
                {Create the family with \string\makepythontexfamily}%
        \fi
    }%
}
\@onlypreamble\setpythontexprettyprinter
\makepythontexfamily[pyglexer=python]{py}
\makepythontexfamily[pyglexer=pycon, console=true]{pycon}
\makepythontexfamily[pyglexer=python]{sympy}
\makepythontexfamily[pyglexer=pycon, console=true]{sympycon}
\makepythontexfamily[pyglexer=python]{pylab}
\makepythontexfamily[pyglexer=pycon, console=true]{pylabcon}
\renewcommand{\do}[1]{%
    \ifstrequal{#1}{ruby}{\makepythontexfamily[pyglexer=ruby]{ruby}}{}%
    \ifstrequal{#1}{rb}{\makepythontexfamily[pyglexer=ruby]{rb}}{}%
    \ifstrequal{#1}{julia}{\makepythontexfamily[pyglexer=julia]{julia}}{}%
    \ifstrequal{#1}{jl}{\makepythontexfamily[pyglexer=julia]{jl}}{}%
}
\expandafter\docsvlist\expandafter{\pytx@families}
\newbool{pytx@listingenv}
\def\setpythontexlistingenv#1{%
    \Depythontex{cmd:setpythontexlistingenv:m:n}%
    \DeclareFloatingEnvironment[fileext=lopytx,listname={List of Listings},name=Listing]{#1}
    \booltrue{pytx@listingenv}
}
\@onlypreamble\setpythontexlistingenv
\AtBeginDocument{
    \ifcsname listing\endcsname
        \ifbool{pytx@listingenv}{}%
            {\PackageWarning{\pytx@packagename}%
                {A "listing" environment already exists \MessageBreak
                 \pytx@packagename\space will not create one \MessageBreak
                 Use \string\setpythontexlistingenv to create a custom listing environment}}%
    \else
        \ifbool{pytx@listingenv}{}{\DeclareFloatingEnvironment[fileext=lopytx]{listing}}
    \fi
}
\def\pytx@CheckPygmentsInit#1{%
    \ifcsname pytx@fvsettings@PYG#1\endcsname\else
        \expandafter\gdef\csname pytx@fvsettings@PYG#1\endcsname{}%
        \expandafter\gdef\csname pytx@pygopt@PYG#1\endcsname{}%
        \AtEndDocument{\immediate\write\pytx@codefile{pygfamily=PYG#1|#1|%
            \csname pytx@pygopt@PYG#1\endcsname}}%
    \fi
}
\def\pytx@MakePygmentsInlineFV{%
    \newcommand{\pygment}[1]{%
        \edef\pytx@lexer{##1}%
        \Depythontex{cmd:pygment:mv:c}%
        \edef\pytx@type{PYG##1}%
        \edef\pytx@cmd{v}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \let\pytx@InlineShow\pytx@InlineShowFV
        \let\pytx@InlineSave\@empty
        \let\pytx@InlinePrint\@empty
        \pytx@CheckPygmentsInit{##1}%
        \pytx@Inline[]%
    }%
}
\def\pytx@MakePygmentsInlinePyg{%
    \newcommand{\pygment}[1]{%
        \edef\pytx@type{PYG##1}%
        \edef\pytx@cmd{v}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \let\pytx@InlineShow\pytx@InlineShowPyg
        \let\pytx@InlineSave\pytx@InlineSaveCode
        \let\pytx@InlinePrint\@empty
        \pytx@CheckPygmentsInit{##1}%
        \pytx@Inline[]
    }%
}
\def\pytx@MakePygmentsEnvFV{%
    \newenvironment{pygments}{%
        \VerbatimEnvironment
        \pytx@SetContext
        \pytx@SetGroupVerb
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BEPygmentsFV}{\endgroup\pytx@BEPygmentsFV[]}%
    }%
    {\end{Verbatim}%
        \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
        \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    }%
}
\def\pytx@BEPygmentsFV[#1]{%
    \def\pytx@fvopttmp{#1}%
    \begingroup
    \obeylines
    \pytx@BEPygmentsFV@i
}
\def\pytx@BEPygmentsFV@i#1{%
    \endgroup
    \edef\pytx@type{PYG#1}%
    \edef\pytx@lexer{#1}%
    \Depythontex{env:pygments:om:c}%
    \DepyListing
    \edef\pytx@cmd{verbatim}%
    \edef\pytx@session{default}%
    \edef\pytx@linecount{pytx@\pytx@type @\pytx@session @\pytx@group @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \pytx@CheckPygmentsInit{#1}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
    \begin{Verbatim}%
}
\def\pytx@MakePygmentsEnvPyg{%
    \newenvironment{pygments}{%
        \VerbatimEnvironment
        \pytx@SetContext
        \pytx@SetGroupVerb
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BEPygmentsPyg}{\endgroup\pytx@BEPygmentsPyg[]}%
    }%
    {\end{VerbatimOut}%
        \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
        \pytx@FVSet
        \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
        \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
            \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
        \else
            \InputIfFileExists{\pytx@outputdir/%
                \pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}.pygtex}{}%
                {\textbf{??~\pytx@packagename~??}%
                    \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}%
        \fi
        \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
        \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
        \stepcounter{\pytx@counter}%
    }%
}
\def\pytx@BEPygmentsPyg[#1]{%
    \def\pytx@fvopttmp{#1}%
    \begingroup
    \obeylines
    \pytx@BEPygmentsPyg@i
}
\def\pytx@BEPygmentsPyg@i#1{%
    \endgroup
    \edef\pytx@type{PYG#1}%
    \edef\pytx@cmd{verbatim}%
    \edef\pytx@session{default}%
    \xdef\pytx@counter{pytx@\pytx@type @\pytx@session @\pytx@group}%
    \pytx@CheckCounter{\pytx@counter}%
    \edef\pytx@linecount{\pytx@counter @line}%
    \pytx@CheckCounter{\pytx@linecount}%
    \pytx@WriteCodefileInfo
    \pytx@CheckPygmentsInit{#1}%
    \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
    \let\FVB@VerbatimOut\pytx@FVB@VerbatimOut
    \let\FVE@VerbatimOut\pytx@FVE@VerbatimOut
    \begin{VerbatimOut}%
}
\def\pytx@MakePygmentsInputFV{
    \newcommand{\inputpygments}[3][]{%
        \edef\pytx@lexer{##2}%
        \Depythontex{cmd:inputpygments:omm:c}%
        \edef\pytx@type{PYG##2}%
        \edef\pytx@cmd{verbatim}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \edef\pytx@session{EXT:##3}%
        \pytx@CheckPygmentsInit{##2}%
        \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
        \begingroup
        \DepyListing %Always must be in a group
        \pytx@FVSet
        \fvset{firstnumber=auto}%
        \IfFileExists{##3}%
            {\DepyFile{c:##3:mode=verbatim}\VerbatimInput[##1]{##3}}%
            {\PackageWarning{\pytx@packagename}{Input file <##3> doesn't exist}}%
        \endgroup
        \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    }%
}
\def\pytx@MakePygmentsInputPyg{
    \newcommand{\inputpygments}[3][]{%
        \edef\pytx@type{PYG##2}%
        \edef\pytx@cmd{verbatim}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \edef\pytx@session{EXT:##3}%
        \pytx@CheckPygmentsInit{##2}%
        \pytx@WriteCodefileInfoExt
        \IfFileExists{##3}{}{\PackageWarning{\pytx@packagename}%
            {Input file <##3> does not exist}}
        \setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
        \begingroup
        \pytx@FVSet
        \fvset{firstnumber=auto}%
        \ifcsname FV@SV@pytx@\pytx@type @\pytx@session @\pytx@group @0\endcsname
            \UseVerbatim[##1]{pytx@\pytx@type @\pytx@session @\pytx@group @0}%
        \else
            \InputIfFileExists{\pytx@outputdir/##3_##2.pygtex}{}%
                {\textbf{??~\pytx@packagename~??}%
                    \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}%
        \fi
        \endgroup
        \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    }%
}
\newcommand{\setpygmentsfv}[2][]{%
    \Depythontex{cmd:setpygmentsfv:om:n}%
    \ifstrempty{#1}%
        {\gdef\pytx@fvsettings{#2}}%
        {\expandafter\gdef\csname pytx@fvsettings@PYG#1\endcsname{#2}}%
}%
\newcommand{\setpygmentspygopt}[2][]{%
    \Depythontex{cmd:setpygmentspygopt:om:n}%
    \ifstrempty{#1}{\def\pytx@pygopt{#2}}{%
        \expandafter\gdef\csname pytx@pygopt@PYG#1\endcsname{#2}}%
}
\@onlypreamble\setpygmentspygopt
\newcommand{\setpygmentsprettyprinter}[1]{%
    \Depythontex{cmd:setpygmentsprettyprinter:m:n}%
    \ifstrequal{#1}{fancyvrb}{\boolfalse{pytx@opt@pygments}}%
    \ifstrequal{#1}{pygments}{\booltrue{pytx@opt@pygments}}%
}
\@onlypreamble\setpygmentsprettyprinter
\xdef\pytx@macroformatter@PYG{auto}
\def\makepygmentsfv{%
    \pytx@MakePygmentsInlineFV
    \pytx@MakePygmentsEnvFV
    \pytx@MakePygmentsInputFV
}%
\@onlypreamble\makepygmentsfv
\def\makepygmentspyg{%
    \ifbool{pytx@opt@pyginline}%
        {\pytx@MakePygmentsInlinePyg}%
        {\pytx@MakePygmentsInlineFV}%
    \pytx@MakePygmentsEnvPyg
    \pytx@MakePygmentsInputPyg
    \booltrue{pytx@usedpygments}
}%
\@onlypreamble\makepygmentspyg
\def\makepygments{%
    \AtBeginDocument{%
        \ifdefstring{\pytx@macroformatter@PYG}{auto}%
            {\ifbool{pytx@opt@pygments}%
                {\makepygmentspyg}{\makepygmentsfv}}{}
        \ifdefstring{\pytx@macroformatter@PYG}{pygments}%
            {\makepygmentspyg}{}
        \ifdefstring{\pytx@macroformatter@PYG}{fancyvrb}%
            {\makepygmentsfv}{}
    }%
}%
\@onlypreamble\makepygments
\makepygments
\AfterEndDocument{%
    \immediate\closeout\pytx@codefile
    \ifbool{pytx@opt@depythontex}{\immediate\closeout\pytx@depyfile}{}%
}
\ifbool{pytx@opt@beta}{

\def\pytx@FetchStdoutfile[#1][#2]#3{%
    \IfFileExists{\pytx@outputdir/#3.stdout}{%
        \ifstrempty{#1}{\input{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{verb}{\VerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{inlineverb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}%
        \ifstrequal{#1}{v}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stdout}}{}%
        \DepyFile{p:\pytx@outputdir/#3.stdout:mode=#1}%
    }%
    {\pytx@stdout@warntext
        \PackageWarning{\pytx@packagename}{Non-existent printed content}}%
}
\def\pytx@FetchStderrfile[#1][#2]#3{%
    \IfFileExists{\pytx@outputdir/#3.stderr}{%
        \ifstrequal{#1}{raw}{\input{\pytx@outputdir/#3.stderr}}{}%
        \ifstrempty{#1}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \ifstrequal{#1}{verb}{\VerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \ifstrequal{#1}{inlineverb}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \ifstrequal{#1}{v}{\BVerbatimInput[#2]{\pytx@outputdir/#3.stderr}}{}%
        \DepyFile{p:\pytx@outputdir/#3.stderr:mode=#1}%
    }%
    {\textbf{??~\pytx@packagename~??}%
        \PackageWarning{\pytx@packagename}{Non-existent stderr content}}%
}

\renewcommand{\pytx@MakeVerbFV}[1]{%
    \expandafter\newenvironment{#1verb}{%
        \VerbatimEnvironment
        \expandafter\let\expandafter\pytx@lexer\csname pytx@pyglexer@#1\endcsname
        \Depythontex{env:#1verb:oo|:c}%
        \DepyListing
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{verb}%
        \pytx@SetContext
        \pytx@SetGroupVerb
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginVerbEnvFV}{\endgroup\pytx@BeginVerbEnvFV[]}%
    }%
    {\end{Verbatim}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}
\renewcommand{\pytx@MakePygEnv}[2]{%
    \expandafter\newenvironment{#1#2}{%
        \VerbatimEnvironment
        \xdef\pytx@type{#1}%
        \edef\pytx@cmd{#2}%
        \pytx@SetContext
        \ifstrequal{#2}{block}{\pytx@SetGroup}{}
        \ifstrequal{#2}{verb}{\pytx@SetGroupVerb}{}
        \begingroup
        \obeylines
        \@ifnextchar[{\endgroup\pytx@BeginEnvPyg}{\endgroup\pytx@BeginEnvPyg[]}%
    }%
    {\end{VerbatimOut}%
    \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
    \setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
    \pytx@FVSet
    \ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
    \ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
        \UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
    \else
        \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.pygtex}{}%
            {\textbf{??~\pytx@packagename~??}%
                \PackageWarning{\pytx@packagename}{Non-existent Pygments content}}%
    \fi
    \setcounter{\pytx@linecount}{\value{FancyVerbLine}}%
    \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
    \stepcounter{\pytx@counter}%
    }%
}%
\renewcommand{\pytx@MakeVerbPyg}[1]{\pytx@MakePygEnv{#1}{verb}}

\def\setpythontexpyglexer#1#2{%
    \Depythontex{cmd:setpythontexpyglexer:mm:n}%
    \ifcsname pytx@pyglexer@#1\endcsname
        \expandafter\xdef\csname pytx@pyglexer@#1\endcsname{#2}%
    \else
        \PackageError{\pytx@packagename}%
            {Cannot modify a non-existent family}{}%
    \fi
}%
\renewcommand{\setpythontexpygopt}[2]{%
    \Depythontex{cmd:setpythontexpygopt:mm:n}%
    \ifcsname pytx@pygopt@#1\endcsname
        \expandafter\xdef\csname pytx@pygopt@#1\endcsname{#2}%
    \else
        \PackageError{\pytx@packagename}%
            {Cannot modify Pygments options for a non-existent family}{}%
    \fi
}
\def\setpygmentspygopt#1#2{%
    \Depythontex{cmd:setpygmentspygopt:mm:n}%
    \AtEndDocument{\immediate\write\pytx@codefile{%
        \pytx@delimsettings pygfamily=PYG#1,#1,%
        \string{#2\string}\pytx@delimchar}%
    }%
}

\def\setpythontexformatter#1#2{%
    \Depythontex{cmd:setpythontexformatter:mm:n}%
    \ifcsname pytx@macroformatter@#1\endcsname
        \ifbool{pytx@opt@depythontex}{}{%
            \expandafter\xdef\csname pytx@macroformatter@#1\endcsname{#2}}
    \else
        \PackageError{\pytx@packagename}%
            {Cannot modify a family that does not exist or does not allow formatter choices}%
            {Create the family with \string\makepythontexfamily}%
    \fi
}
\@onlypreamble\setpythontexformatter
\def\setpygmentsformatter#1{%
    \Depythontex{cmd:setpygmentsformatter:m:n}%
    \ifbool{pytx@opt@depythontex}{}{\xdef\pytx@macroformatter@PYG{#1}}}
\@onlypreamble\setpygmentsformatter

}{} %End beta
%% \Finale
\endinput
%%
%% End of file `pythontex.sty'.
