Deutsch   English   Français   Italiano  
<v5b0nv$7182$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Sebastian Wells <sebastian@here.com.invalid>
Newsgroups: comp.lang.python,comp.lang.lisp,comp.lang.scheme
Subject: Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in
 Python )
Date: Mon, 24 Jun 2024 05:38:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <v5b0nv$7182$2@dont-email.me>
References: <v3bkoj$23bck$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 24 Jun 2024 07:38:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="2787d93bb44b66d3fe4dceb9b5d2d9b9";
	logging-data="230658"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19nWfyBbmhvNTwzRsJsvg95qXPQLQZoZpY="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:rY5rTbmDHhSEpwBJxSIfuFOT+1A=
Bytes: 2937

On Thu, 30 May 2024 21:47:14 -0700, HenHanna wrote:

> ;;;  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))
> 

The direct Lispification of the original expression would probably be
something like this:

  #(#("the" 36225) #("and" 17551) #("of" 16759)
    #("i" 16696) #("a" 15816))

...etc, taking into account that Python "lists" are really
arrays, and there's no real Lisp equivalent to tuples,
but they're essentially arrays also. And there's a distinction
between strings and symbols in Lisp that could be approximated
in Python by defining an empty class for each desired symbol.
But since strings are used in the Python example, they should
be used in the Lisp one, too.

That written, there's not much benefit in doing this in a Python
program, and you actually lose one of the advantages you started
out with: Like Lisp, the Python syntax is readable Python. Unlike
Lisp, there's no reader that will give you the original structure
from its string representation without having to also evaluate it
as code. Lispifying it doesn't bring that advantage unless you
also implement a reader, and even then you might be better off
convincing some insider to endorse a Python analogue to JSON. But
that insider would probably tell you to use JSON, ignoring
the lack of distinct array/tuple types in JSON, or he'd tell you
to use Pickle, ignoring the fact that it's a binary format.

Norvig was coping big time. He even called Python an "acceptable"
compromise between what Lisp delivers and whatever it is that's
supposed to be good about Python that it didn't directly copy
from Lisp.