Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

Liste des GroupesRevenir à cl python 
Sujet : Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )
De : HenHanna (at) *nospam* devnull.tb (HenHanna)
Groupes : comp.lang.python comp.lang.lisp comp.lang.scheme
Date : 31. May 2024, 05:47:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v3bkoj$23bck$1@dont-email.me>
User-Agent : Mozilla Thunderbird
          ;;;  Pls tell me about little tricks you use in Python or Lisp.
[('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)]
((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that 11252) (in 10743) (it 10687))
i think the latter is easier-to-read, so i use this code
                                                        (by Peter Norvig)
def lispstr(exp):
            # "Convert a Python object back into a Lisp-readable string."
     if isinstance(exp, list):
         return '(' + ' '.join(map(lispstr, exp)) + ')'
     else:
         return str(exp)
def Lprint(x): print(lispstr(x))

Date Sujet#  Auteur
31 May 24 * Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )3HenHanna
1 Jun 24 +- Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )1Peter J. Holzer
24 Jun 24 `- Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )1Sebastian Wells

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal