Re: Is there a better way? [combining f-string, thousands separator, right align]

Liste des GroupesRevenir à cl python 
Sujet : Re: Is there a better way? [combining f-string, thousands separator, right align]
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 26. Aug 2024, 12:30:44
Autres entêtes
Organisation : Stefan Ram
Message-ID : <CALL-20240826122738@ram.dialup.fu-berlin.de>
References : 1 2
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" ))



Date Sujet#  Auteur
26 Aug 24 * Re: Is there a better way? [combining f-string, thousands separator, right align]2dn
26 Aug 24 `- Re: Is there a better way? [combining f-string, thousands separator, right align]1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal