Skip to content

# cmd2.constants

## `` cmd2.constants

Constants used throughout `cmd2`.

### `` INFINITY `module-attribute`

    INFINITY = float('inf')

### `` QUOTES `module-attribute`

    QUOTES = ('"', "'")

### `` REDIRECTION_PIPE `module-attribute`

    REDIRECTION_PIPE = '|'

### `` REDIRECTION_OVERWRITE `module-attribute`

    REDIRECTION_OVERWRITE = '>'

### `` REDIRECTION_APPEND `module-attribute`

    REDIRECTION_APPEND = '>>'

### `` REDIRECTION_CHARS `module-attribute`

    REDIRECTION_CHARS = (REDIRECTION_PIPE, REDIRECTION_OVERWRITE)

### `` REDIRECTION_TOKENS `module-attribute`

    REDIRECTION_TOKENS = (REDIRECTION_PIPE, REDIRECTION_OVERWRITE, REDIRECTION_APPEND)

### `` COMMENT_CHAR `module-attribute`

    COMMENT_CHAR = '#'

### `` MULTILINE_TERMINATOR `module-attribute`

    MULTILINE_TERMINATOR = ';'

### `` LINE_FEED `module-attribute`

    LINE_FEED = '\n'

### `` DEFAULT_SHORTCUTS `module-attribute`

    DEFAULT_SHORTCUTS = {'?': 'help', '!': 'shell', '@': 'run_script', '@@': '_relative_run_script'}

### `` COMMAND_NAME `module-attribute`

    COMMAND_NAME = '<COMMAND_NAME>'

### `` COMMAND_FUNC_PREFIX `module-attribute`

    COMMAND_FUNC_PREFIX = 'do_'

### `` HELP_FUNC_PREFIX `module-attribute`

    HELP_FUNC_PREFIX = 'help_'

### `` COMPLETER_FUNC_PREFIX `module-attribute`

    COMPLETER_FUNC_PREFIX = 'complete_'

### `` PRIVATE_ATTR_PREFIX `module-attribute`

    PRIVATE_ATTR_PREFIX = '_cmd2_'

### `` PUBLIC_ATTR_PREFIX `module-attribute`

    PUBLIC_ATTR_PREFIX = 'cmd2_'

### `` COMMAND_ATTR_HELP_CATEGORY `module-attribute`

    COMMAND_ATTR_HELP_CATEGORY = cmd2_private_attr_name('help_category')

### `` ARGPARSE_COMMAND_ATTR_SPEC `module-attribute`

    ARGPARSE_COMMAND_ATTR_SPEC = cmd2_private_attr_name('argparse_command_spec')

### `` SUBCOMMAND_ATTR_SPEC `module-attribute`

    SUBCOMMAND_ATTR_SPEC = cmd2_private_attr_name('subcommand_spec')

### `` PARSER_ATTR_OWNER_ID `module-attribute`

    PARSER_ATTR_OWNER_ID = cmd2_private_attr_name('owner_id')

### `` NS_ATTR_STATEMENT `module-attribute`

    NS_ATTR_STATEMENT = cmd2_public_attr_name('statement')

### `` NS_ATTR_SUBCOMMAND_FUNC `module-attribute`

    NS_ATTR_SUBCOMMAND_FUNC = cmd2_public_attr_name('subcommand_func')

### `` cmd2_private_attr_name

    cmd2_private_attr_name(name)

Build a private attribute name with the cmd2 prefix.

PARAMETER | DESCRIPTION
--- | ---
`name` | the name of the attribute TYPE: `str`

RETURNS | DESCRIPTION
--- | ---
`str` | the prefixed attribute name

Source code in `cmd2/constants.py`

    41
    42
    43
    44
    45
    46
    47

    def cmd2_private_attr_name(name: str) -> str:
        """Build a private attribute name with the _cmd2_ prefix.

        :param name: the name of the attribute
        :return: the prefixed attribute name
        """
        return f"{PRIVATE_ATTR_PREFIX}{name}"

### `` cmd2_public_attr_name

    cmd2_public_attr_name(name)

Build a public attribute name with the cmd2_ prefix.

PARAMETER | DESCRIPTION
--- | ---
`name` | the name of the attribute TYPE: `str`

RETURNS | DESCRIPTION
--- | ---
`str` | the prefixed attribute name

Source code in `cmd2/constants.py`

    50
    51
    52
    53
    54
    55
    56

    def cmd2_public_attr_name(name: str) -> str:
        """Build a public attribute name with the cmd2_ prefix.

        :param name: the name of the attribute
        :return: the prefixed attribute name
        """
        return f"{PUBLIC_ATTR_PREFIX}{name}"