• Re: Is there a better way? [combining f-string, thousands separator, ri

    From Stefan Ram@3:633/280.2 to All on Mon Aug 26 21:30:44 2024
    Subject: Re: Is there a better way? [combining f-string, thousands separator, right align]

    dn <PythonList@DancesWithMice.info> wrote or quoted:
    and if we really want to go over-board:
    RIGHT_JUSTIFIED = ">"
    THOUSANDS_SEPARATOR = ","
    s_format = F"{RIGHT_JUSTIFIED}{S_FIELD_WIDTH}{THOUSANDS_SEPARATOR}"

    def PROCEDURE_DEFINIION( NAME, BODY ):
    return f'\ndef {NAME}():\n{" "*4}{BODY}\n'

    def PRINT_STATEMENT( WHAT_TO_PRINT ):
    return f'print( "{WHAT_TO_PRINT}" )'

    def PROCEDURE_INVOCATION( WHAT_TO_INVOKE ):
    return f'{WHAT_TO_INVOKE}()'

    exec\
    ( PROCEDURE_DEFINIION( "f", PRINT_STATEMENT( "Hello, world!" ))+
    PROCEDURE_INVOCATION( "f" ))



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)