def _wireNameToPythonIdentifier(key):
    """
    (Private) Normalize an argument name from the wire for use with Python
    code.  If the return value is going to be a python keyword it will be
    capitalized.  If it contains any dashes they will be replaced with
    underscores.

    The rationale behind this method is that AMP should be an inherently
    multi-language protocol, so message keys may contain all manner of bizarre
    bytes.  This is not a complete solution; there are still forms of arguments
    that this implementation will be unable to parse.  However, Python
    identifiers share a huge raft of properties with identifiers from many
    other languages, so this is a 'good enough' effort for now.  We deal
    explicitly with dashes because that is the most likely departure: Lisps
    commonly use dashes to separate method names, so protocols initially
    implemented in a lisp amp dialect may use dashes in argument or command
    names.

    @param key: a C{bytes}, looking something like 'foo-bar-baz' or 'from'
    @type key: C{bytes}

    @return: a native string which is a valid python identifier, looking
    something like 'foo_bar_baz' or 'From'.
    """
    lkey = nativeString(key.replace(b"-", b"_"))
    if lkey in PYTHON_KEYWORDS:
        return lkey.title()
    return lkey

    (Private) Normalize an argument name from the wire for use with Python
    code.  If the return value is going to be a python keyword it will be
    capitalized.  If it contains any dashes they will be replaced with
    underscores.

    The rationale behind this method is that AMP should be an inherently
    multi-language protocol, so message keys may contain all manner of bizarre
    bytes.  This is not a complete solution; there are still forms of arguments
    that this implementation will be unable to parse.  However, Python
    identifiers share a huge raft of properties with identifiers from many
    other languages, so this is a 'good enough' effort for now.  We deal
    explicitly with dashes because that is the most likely departure: Lisps
    commonly use dashes to separate method names, so protocols initially
    implemented in a lisp amp dialect may use dashes in argument or command
    names.

    @param key: a C{bytes}, looking something like 'foo-bar-baz' or 'from'
    @type key: C{bytes}

    @return: a native string which is a valid python identifier, looking
    something like 'foo_bar_baz' or 'From'.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/protocols/amp.py