Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-15 Thread Richard Damon
A few comments come to mind about this discussion about TCO. First, TCO, Tail Call Optimization, is talking about something that is an optimization. Optimizations, are generally some OPTIONAL improvement in the method of executing the code that doesn't alter its DEFINED meaning. First big point,

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-15 Thread Antoon Pardon
Op 15/08/20 om 15:02 schreef Chris Angelico: > On Sat, Aug 15, 2020 at 10:45 PM Antoon Pardon > wrote: >> >> >> I don't understand this argument. The trace back information that is >> destroyed with this optimization, is information that isn't available >> anyway if you write the code in an iterat

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-15 Thread Marco Sulla
@Chris: you're very right, but, I repeat, you can't have a real TCO (asyncio apart): (venv_3_10) marco@buzz:~$ python Python 3.10.0a0 (heads/master-dirty:ba18c0b13b, Aug 14 2020, 17:52:45) [GCC 10.1.1 20200718] on linux Type "help", "copyright", "credits" or "license" for more information. >>> def

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-15 Thread Chris Angelico
On Sat, Aug 15, 2020 at 10:45 PM Antoon Pardon wrote: > > Op 7/08/20 om 18:45 schreef Chris Angelico: > > On Sat, Aug 8, 2020 at 2:21 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > >> > >> On 2020-08-07 at 17:55:45 +0200, > >> Marco Sulla wrote: > >>> @Chris: note that "real" recursion in Pytho

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-15 Thread Antoon Pardon
Op 7/08/20 om 18:45 schreef Chris Angelico: > On Sat, Aug 8, 2020 at 2:21 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: >> >> On 2020-08-07 at 17:55:45 +0200, >> Marco Sulla wrote: >>> @Chris: note that "real" recursion in Python is not possible, since >>> there's no support for tail recursion. M

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-11 Thread bryan . gene . olson
Christian Seberino wrote: > A beginner I think could learn Lisp much faster than Python. For talented beginners, Lisp rocks much like Python, in that easy assignments are easy enough to implement. On the high end, Lisp rocks again: Lisp masters are astonishingly productive. In between, beyond pe

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-10 Thread Chris Angelico
On Tue, Aug 11, 2020 at 5:48 AM Roel Schroeven wrote: > I'm not saying there is nothing useful in functional programming and the > use of recursion; there most certainly is. But the way many texts > introduce it IMO doesn't help at all to understand the elegance that can > be achieved. Indeed. Wh

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-10 Thread Roel Schroeven
Terry Reedy schreef op 7/08/2020 om 22:08: On 8/7/2020 11:46 AM, Chris Angelico wrote: My point is that doing Fibonacci recursively is arguably more elegant while being materially worse at performance. This is a common misconception. Linear iteration and tail recursion are equivalent. The i

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Sat, 8 Aug 2020 at 03:46, Christian Seberino wrote: > >> Readability of programming languages was measured > >> using an objective method, and Python was one of > >> the most readable. > > Do you have a source for this? This question means you have not read at all my suggestions :-D Anyway, th

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
>> Readability of programming languages was measured >> using an objective method, and Python was one of >> the most readable. Do you have a source for this? -- https://mail.python.org/mailman/listinfo/python-list

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
On 8/7/20 6:55 PM, Marco Sulla wrote: > On Sat, 8 Aug 2020 at 00:28, Richard Damon wrote: >> The really interesting part is that since Lisp programs manipulate lists >> as data, and the program is just a list, Lisp programs have the >> theoretical ability to edit themselves (assuming the implement

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Sat, 8 Aug 2020 at 00:28, Richard Damon wrote: > The really interesting part is that since Lisp programs manipulate lists > as data, and the program is just a list, Lisp programs have the > theoretical ability to edit themselves (assuming the implementation give > access to the list of the prog

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
berino just expressed a doubt about how a clear separation > between a statement and an expression is quite desiderable in the > "real" programming world. And I tried to explain it with the > assignment operation, since a ton of programmers feel very frustrated > abo

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Terry Reedy
On 8/7/2020 11:55 AM, Marco Sulla wrote: @Chris: note that "real" recursion in Python is not possible, This is backwards. Python only does real recursion when one writes recursive calls. since there's no support for tail recursion. I am pretty sure that what you mean by 'support' is to

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Python
e not students, they are experienced programmers. This may explain why they usually can easily implement the recursive version, but it does not really address why most of them have trouble with the iterative version. :) -- https://mail.python.org/mailman/listinfo/python-list

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
On 8/7/20 4:08 PM, Terry Reedy wrote: > On 8/7/2020 11:46 AM, Chris Angelico wrote: > >> My point is that doing Fibonacci recursively is arguably more elegant >> while being materially worse at performance. > > This is a common misconception.  Linear iteration and tail recursion > are equivalent. 

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Chris Angelico
On Sat, Aug 8, 2020 at 6:34 AM Terry Reedy wrote: > > On 8/7/2020 11:46 AM, Chris Angelico wrote: > > > My point is that doing Fibonacci recursively is arguably more elegant > > while being materially worse at performance. > > This is a common misconception. Linear iteration and tail recursion ar

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Fri, 7 Aug 2020 at 22:35, Terry Reedy wrote: > This is a common misconception. Linear iteration and tail recursion are > equivalent. The issue is calculating values once versus multiple times. > Here is the fast recursion equivalent to the fast iteration. > > def fib(n, pair=(1,0)): > p

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Fri, 7 Aug 2020 at 19:41, Christian Seberino wrote: > I think this is really significant point why more syntax does necessarily > mean less readability. I don't think so. Readability of programming languages was measured using an objective method, and Python was one of the most readable. The

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread 2QdxY4RzWzUUiLuE
On 2020-08-07 at 13:43:06 -0500, Wyatt Biggs wrote: > > It's also probably significantly slower, so you'd likely still want to > > use the iterative version > > Generalizing this to the majority of recursive functions/methods, are > their iterative counterparts more efficient? (I say "majority o

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Terry Reedy
On 8/7/2020 11:46 AM, Chris Angelico wrote: My point is that doing Fibonacci recursively is arguably more elegant while being materially worse at performance. This is a common misconception. Linear iteration and tail recursion are equivalent. The issue is calculating values once versus mult

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread 2QdxY4RzWzUUiLuE
world. And I tried to explain it with the > assignment operation, since a ton of programmers feel very frustrated > about reading code of other programmers with assignment in an if > statement. I'm quite sure that they thought, as I thought: "What do > this?" > Worse whe

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread 2QdxY4RzWzUUiLuE
On 2020-08-07 at 11:02:50 -0700, Christian Seberino wrote: > > In Lisp, your hammer is the list. > > > In, say, Java, your tool is classes and inheritance. > > And yet if Lisp or Java programmers were here they would say their > languages //are// multi-paradigm too. For example, Lisp has the >

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
en a statement and an expression is quite desiderable in the "real" programming world. And I tried to explain it with the assignment operation, since a ton of programmers feel very frustrated about reading code of other programmers with assignment in an if statement. I'm quite sure th

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Wyatt Biggs
> It's also probably significantly slower, so you'd likely still want to > use the iterative version Generalizing this to the majority of recursive functions/methods, are their iterative counterparts more efficient? (I say "majority of" because I've personally encountered one or two recursive func

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
> In Lisp, your hammer is the list. > In, say, Java, your tool is classes and inheritance. And yet if Lisp or Java programmers were here they would say their languages //are// multi-paradigm too. For example, Lisp has the Common Lisp Object System (CLOS) and Java has the Vector class and so on

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread 2QdxY4RzWzUUiLuE
simultaneously open in your head. > > (defun dist-rad (lat1 lng1 lat2 lng2) > (let* ((hlat (haversine (- lat2 lat1))) > ;; Then there's the let vs. let* issue, > ;; no big deal for experienced programmers > ;; but not entirely easy to explain to a beginner. >

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
On 8/7/20 12:52 PM, Marco Sulla wrote: > About statement vs expression: maybe you, Richard and > 2QdxY4RzWzUUiLuE, are right, maybe not. This is hard to say, since the > official C documentation is not public and you have to pay a small fee > to obtain it. > > Anyway, I said "in C, the assignment i

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
> Another point to consider is the ecosystem of your language. If you > install Python, then you get basic math, I/O, a GUI toolkit, network > libraries, ... In more "traditional" languages like C or Lisp, you get > math and I/O, period. For everything else you need to hunt down a > library.

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
Your iterative fib(x) code and comment was quite nice. -- https://mail.python.org/mailman/listinfo/python-list

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Fri, 7 Aug 2020 at 18:48, Chris Angelico wrote: > Tail call optimization (there's no reason to restrict it to recursion > alone) is something a Python implementation could choose to do, but > the trouble is that full optimization tends to destroy traceback > information Indeed this is implemen

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
About statement vs expression: maybe you, Richard and 2QdxY4RzWzUUiLuE, are right, maybe not. This is hard to say, since the official C documentation is not public and you have to pay a small fee to obtain it. Anyway, I said "in C, the assignment is a statement that can be used in expression". You

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Chris Angelico
On Sat, Aug 8, 2020 at 2:44 AM Richard Damon wrote: > > On 8/7/20 11:46 AM, Chris Angelico wrote: > > My point is that doing Fibonacci recursively is arguably more elegant > > while being materially worse at performance, but there are other > > examples that are fundamentally recursive, are just a

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Chris Angelico
On Sat, Aug 8, 2020 at 2:21 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > On 2020-08-07 at 17:55:45 +0200, > Marco Sulla wrote: > > @Chris: note that "real" recursion in Python is not possible, since > > there's no support for tail recursion. Maybe something similar can be > > done using asyn

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
On 8/7/20 11:46 AM, Chris Angelico wrote: > My point is that doing Fibonacci recursively is arguably more elegant > while being materially worse at performance, but there are other > examples that are fundamentally recursive, are just as elegant (merge > sort: "fracture the array in half, sort each

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Richard Damon
On 8/7/20 11:55 AM, Marco Sulla wrote: > Commonly, in imperative languages like C, you can write > > if (a = b) {...} > > This is allowed in C, even if a = b is not an expression, but an > assignment statement. 99% of times you simply wrong and wanted: But in C (and related languages) it IS an exp

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread 2QdxY4RzWzUUiLuE
On 2020-08-07 at 17:55:45 +0200, Marco Sulla wrote: > On Fri, 7 Aug 2020 at 17:14, Christian Seberino wrote: > Commonly, in imperative languages like C, you can write > > if (a = b) {...} > > This is allowed in C, even if a = b is not an expression ... In C, a = b *is* an expression. An ass

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Akkana Peck
ntheses simultaneously open in your head. (defun dist-rad (lat1 lng1 lat2 lng2) (let* ((hlat (haversine (- lat2 lat1))) ;; Then there's the let vs. let* issue, ;; no big deal for experienced programmers ;; but not entirely easy to explain to a beginner. ;; On the other h

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Gollwitzer
Am 06.08.20 um 17:13 schrieb Christian Seberino: Python is my favorite language and the easiest to use in my opinion. Lisp has a far simpler grammar and syntax. A beginner I think could learn Lisp much faster than Python. Therefore, it seems like Lisp *should* be easier to work with and more

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Marco Sulla
On Fri, 7 Aug 2020 at 17:14, Christian Seberino wrote: > This is an interesting observation. I've heard people say the fact that > Python has both expressions and statements is a negative. (Lisp only > has expressions.) Commonly, in imperative languages like C, you can write if (a = b) {...}

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Chris Angelico
On Sat, Aug 8, 2020 at 1:38 AM Python wrote: > > On Fri, Aug 07, 2020 at 04:23:42PM +1000, Chris Angelico wrote: > > On Fri, Aug 7, 2020 at 11:11 AM Python wrote: > > > Pretty straightforward. Now try yourself to write the iterative > > > version. > > > > It might look slightly better to a mathe

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Python
On Fri, Aug 07, 2020 at 04:23:42PM +1000, Chris Angelico wrote: > On Fri, Aug 7, 2020 at 11:11 AM Python wrote: > > Pretty straightforward. Now try yourself to write the iterative > > version. > > It might look slightly better to a mathematician, but it's so > abysmally inefficient (unless you a

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
> 1. Python mostly separates computation of values (expressions) from flow > control and name binding (statements). When the latter are mixed with > the former, most people restrict the mixing to a line or two. This is an interesting observation. I've heard people say the fact that Python ha

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Chris Angelico
On Sat, Aug 8, 2020 at 1:06 AM Christian Seberino wrote: > > > > ChrisA > > You're definitely an expert programmer. > Uhh thank you? I think? I'm not sure if you're complimenting me or making some sort of joke relating to the code I posted, or if it's actually nothing to do with me at all. Al

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
> ChrisA You're definitely an expert programmer. -- https://mail.python.org/mailman/listinfo/python-list

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Christian Seberino
> If "the Python way" seems simpler to you than "the Lisp way," > or iteration seems simpler to you than recursion, then so be it. Other > languages and other programmers are different. I think this is so true. I've had similar conversations with Lisp fans and it has confused me at times why the

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Terry Reedy
simpler syntax arises from the fact that there's basically one data structure: a list. In general, the one data structure is a tree*, skewed by being smashed into a linked list. Replaced 'list' with 'skewed tree' in what you say below, and I think you explain well th

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-07 Thread Terry Reedy
On 8/6/2020 11:13 AM, Christian Seberino wrote: Python is my favorite language and the easiest to use in my opinion. Lisp has a far simpler grammar and syntax. A beginner I think could learn Lisp much faster than Python. Therefore, it seems like Lisp *should* be easier to work with and more

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Chris Angelico
On Fri, Aug 7, 2020 at 11:11 AM Python wrote: > Not necessarily. Some problems very naturally lend themselves to > recursive solutions. Fibonacci's sequence is one. > > #!/usr/bin/python > > def fib(x): > if x < 1: > raise "arg must be >= 1" > if x == 1: > return 0 >

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread 2QdxY4RzWzUUiLuE
On 2020-08-06 at 20:07:05 -0700, Christian Seberino wrote: > Some problems are well suited to recursion but perhaps //most// > problems are better suited to iteration? > Maybe the spread is 10% vs 90%? Citation needed? > Therefore in general more often the Python way seems simpler than Lisp?

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Christian Seberino
Some problems are well suited to recursion but perhaps //most// problems are better suited to iteration? Maybe the spread is 10% vs 90%? Therefore in general more often the Python way seems simpler than Lisp? -- https://mail.python.org/mailman/listinfo/python-list

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread 2QdxY4RzWzUUiLuE
On 2020-08-06 at 16:08:29 -0700, Christian Seberino wrote: > > Trying to maintain that recursive list of unclosed lists in your > > brain is fun. It stretches the brain in interesting ways. I was > > way into Lisp at one point, including writing several Lisp > > interpreters (that simple structur

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Python
On Thu, Aug 06, 2020 at 04:08:29PM -0700, Christian Seberino wrote: > > Trying to maintain that recursive list of unclosed lists in your > > brain is fun. It stretches the brain in interesting ways. I was > > way into Lisp at one point, including writing several Lisp > > interpreters (that simple s

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Christian Seberino
> Trying to maintain that recursive list of unclosed lists in your > brain is fun. It stretches the brain in interesting ways. I was > way into Lisp at one point, including writing several Lisp > interpreters (that simple structure makes Lisp very easy to > implement). But I never found Lisp code v

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Richard Damon
On 8/6/20 4:07 PM, 2qdxy4rzwzuui...@potatochowder.com wrote: > for (index, value) in enumerate(this_list): > this_list[index] = 2 * value > > Or: > > for index in range(len(this_list)): > this_list[index] *= 2 > > (But I tend to avoid that, though, because I can never rememb

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread 2QdxY4RzWzUUiLuE
On 2020-08-07 at 05:22:53 +1000, Chris Angelico wrote: > On Fri, Aug 7, 2020 at 5:10 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > One thing worth noting is that your mental pseudo-code is affected by > the languages you're comfortable with. You said: > > > create a new list in which each va

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Chris Angelico
On Fri, Aug 7, 2020 at 5:10 AM <2qdxy4rzwzuui...@potatochowder.com> wrote: > > I would say that expressiveness is how *directly* you can translate your > ideas into code, and how *directly* some one else can see your original > idea by reading your code. Yep, how directly or how accurately. > So

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread 2QdxY4RzWzUUiLuE
On 2020-08-07 at 04:00:34 +1000, Regarding "Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?," Chris Angelico wrote: > On Fri, Aug 7, 2020 at 2:36 AM Christian Seberino wrote: > > > > On Thursday, August 6, 2020 at 10:52:00 AM UT

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Akkana Peck
Christian Seberino writes: > Python is my favorite language and the easiest to use in my opinion. > > Lisp has a far simpler grammar and syntax. A beginner I think could > learn Lisp much faster than Python. > > Therefore, it seems like Lisp *should* be easier to work with and more > readable.

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Chris Angelico
On Fri, Aug 7, 2020 at 2:36 AM Christian Seberino wrote: > > On Thursday, August 6, 2020 at 10:52:00 AM UTC-5, Chris Angelico wrote: > > The point of learning a > > language isn't that you can take a piece of pre-existing code and > > figure out what it'll do, step by step; the point is to be able

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Christian Seberino
On Thursday, August 6, 2020 at 10:52:00 AM UTC-5, Chris Angelico wrote: > The point of learning a > language isn't that you can take a piece of pre-existing code and > figure out what it'll do, step by step; the point is to be able to > encode your intentions in that language, and to read the code

Re: How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Chris Angelico
On Fri, Aug 7, 2020 at 1:16 AM Christian Seberino wrote: > > Python is my favorite language and the easiest to use in my opinion. > > Lisp has a far simpler grammar and syntax. A beginner I think could > learn Lisp much faster than Python. > > Therefore, it seems like Lisp *should* be easier to

How explain why Python is easier/nicer than Lisp which has a simpler grammar/syntax?

2020-08-06 Thread Christian Seberino
Python is my favorite language and the easiest to use in my opinion. Lisp has a far simpler grammar and syntax. A beginner I think could learn Lisp much faster than Python. Therefore, it seems like Lisp *should* be easier to work with and more readable. I don't feel like it is easier to use b

Re: I am newbie who can explain this code to me?

2016-09-22 Thread 380162267qq
在 2016年9月20日星期二 UTC-4下午3:11:27,Terry Reedy写道: > On 9/20/2016 9:12 AM, Peter Otten wrote: > > >> 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > >>> On 20/09/2016 13:12, 38016226...@gmail.com wrote: > >>> d = {} > >>> keys = range(256) > >>> vals = map(chr, keys) > >>> map(operator.setite

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Peter Otten
Nobody wrote: > On Tue, 20 Sep 2016 15:12:39 +0200, Peter Otten wrote: > >> because they don't build lists only to throw them away. > > The lists could have been avoided by using iterators, e.g. > > import itertools as it > keys = xrange(256) > vals = it.imap(chr, keys) > max(it.imap(operator.s

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Nobody
On Tue, 20 Sep 2016 15:12:39 +0200, Peter Otten wrote: > because they don't build lists only to throw them away. The lists could have been avoided by using iterators, e.g. import itertools as it keys = xrange(256) vals = it.imap(chr, keys) max(it.imap(operator.setitem, it.repeat(d), keys, vals))

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Terry Reedy
On 9/20/2016 9:12 AM, Peter Otten wrote: 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: On 20/09/2016 13:12, 38016226...@gmail.com wrote: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the

Re: I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
在 2016年9月20日星期二 UTC-4上午9:13:35,Peter Otten写道: > 38016226...@gmail.com wrote: > > > 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > >> On 20/09/2016 13:12, 38016226...@gmail.com wrote: > >> d = {} > >> keys = range(256) > >> vals = map(chr, keys) > >> map(operator.setitem, [d]*len(key

Re: I am newbie who can explain this code to me?

2016-09-20 Thread Peter Otten
38016226...@gmail.com wrote: > 在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: >> On 20/09/2016 13:12, 38016226...@gmail.com wrote: >> d = {} >> keys = range(256) >> vals = map(chr, keys) >> map(operator.setitem, [d]*len(keys), keys, vals) >> > >> > It is from python library. What does

Re: I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
在 2016年9月20日星期二 UTC-4上午8:17:13,BartC写道: > On 20/09/2016 13:12, 38016226...@gmail.com wrote: > d = {} > keys = range(256) > vals = map(chr, keys) > map(operator.setitem, [d]*len(keys), keys, vals) > > > > It is from python library. What does [d]*len(keys) mean? > > d is the name

Re: I am newbie who can explain this code to me?

2016-09-20 Thread BartC
On 20/09/2016 13:12, 38016226...@gmail.com wrote: d = {} keys = range(256) vals = map(chr, keys) map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the name of dict but put d in [] really confused me. if len(keys) is 5 then [d]*5 is

I am newbie who can explain this code to me?

2016-09-20 Thread 380162267qq
>>> d = {} >>> keys = range(256) >>> vals = map(chr, keys) >>> map(operator.setitem, [d]*len(keys), keys, vals) It is from python library. What does [d]*len(keys) mean? d is the name of dict but put d in [] really confused me. -- https://mail.python.org/mailman/listinfo/python-list

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Chris Angelico
On Tue, Jan 19, 2016 at 4:00 AM, Ian Kelly wrote: >> Armed with that information, you should be able to track down what's >> going on. It's curious, though, that you have a callable subclass of >> module bound to the name int. Very curious indeed. > > What makes you think that it's a callable subc

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Random832
On Mon, Jan 18, 2016, at 11:51, Chris Angelico wrote: > Armed with that information, you should be able to track down what's > going on. It's curious, though, that you have a callable subclass of > module bound to the name int. Very curious indeed. He hasn't tried calling it. And there's no reason

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Ian Kelly
On Mon, Jan 18, 2016 at 9:51 AM, Chris Angelico wrote: > On Tue, Jan 19, 2016 at 3:28 AM, Charles T. Smith >> Okay, I think I understand it now: >> >> (PDB)type (int) >> >> >> (PDB)type (float) >> > > And that's pretty strong evidence right there! So the next question > is... what got imported u

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Chris Angelico
On Tue, Jan 19, 2016 at 3:28 AM, Charles T. Smith wrote: > On Tue, 19 Jan 2016 03:19:59 +1100, Chris Angelico wrote: >> Possibility #1: 'int' has been rebound. >> >> Possibility #2: 'type' has been rebound. >> >> I'd check them in that order. >> >> ChrisA > > > But: > > (PDB)p 5 + 0 > 5 That show

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Charles T. Smith
On Tue, 19 Jan 2016 03:19:59 +1100, Chris Angelico wrote: > On Tue, Jan 19, 2016 at 3:11 AM, Charles T. Smith > wrote: >> $ python >> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 >> Type "help", "copyright", "credits" or "license" for more information. > type(0) is i

Re: When is an int not an int? Who can explain this?

2016-01-18 Thread Chris Angelico
On Tue, Jan 19, 2016 at 3:11 AM, Charles T. Smith wrote: > $ python > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. type(0) is int > True > ... > (PDB)type(0) is int > False > (PDB)type(1) is i

When is an int not an int? Who can explain this?

2016-01-18 Thread Charles T. Smith
$ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> type(0) is int True ... (PDB)type(0) is int False (PDB)type(1) is int False (PDB)p 5 + 0 5 (PDB)class c (object): pass (PDB)type (c()) is c T

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Erik
Apologies for self-replying, On 01/12/15 22:34, Erik wrote: what you're asking for is that the *container* object whose element is being assigned to is first queried as to whether it will accept a mutated element being assigned to it before that element is mutated. What I said above is rubbis

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Terry Reedy
On 12/1/2015 4:36 PM, Denis McMahon wrote: On Tue, 01 Dec 2015 16:18:49 -0500, Terry Reedy wrote: On 12/1/2015 3:32 PM, Denis McMahon wrote: On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: In the case of: tup[1] += [6, 7] what it's trying to do is: tup[1] = tup[1].__iadd__([

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Erik
On 01/12/15 21:37, Denis McMahon wrote: The assignment succeeds. That's imo a bug. If it's a TypeError to try and assign a value to tup[1], then tup[1] should not allow the mutated list to be assigned. Nothing got assigned. That original list object remains in that slot. However, it has been

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
On Tue, 01 Dec 2015 14:44:38 -0600, Ian Kelly wrote: > On Tue, Dec 1, 2015 at 2:32 PM, Denis McMahon > wrote: >> On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: >> >>> In the case of: >>> >>> tup[1] += [6, 7] >>> >>> what it's trying to do is: >>> >>> tup[1] = tup[1].__iadd__([6, 7]) >>

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
On Tue, 01 Dec 2015 16:18:49 -0500, Terry Reedy wrote: > On 12/1/2015 3:32 PM, Denis McMahon wrote: >> On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: >> >>> In the case of: >>> >>> tup[1] += [6, 7] >>> >>> what it's trying to do is: >>> >>> tup[1] = tup[1].__iadd__([6, 7]) >>> >>> tup

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Terry Reedy
On 12/1/2015 3:32 PM, Denis McMahon wrote: On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: In the case of: tup[1] += [6, 7] what it's trying to do is: tup[1] = tup[1].__iadd__([6, 7]) tup[1] refers to a list, and the __iadd__ method _does_ mutate it, but then Python tries to put

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Ian Kelly
On Tue, Dec 1, 2015 at 2:32 PM, Denis McMahon wrote: > On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: > >> In the case of: >> >> tup[1] += [6, 7] >> >> what it's trying to do is: >> >> tup[1] = tup[1].__iadd__([6, 7]) >> >> tup[1] refers to a list, and the __iadd__ method _does_ mutate

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-12-01 Thread Denis McMahon
On Tue, 01 Dec 2015 03:32:31 +, MRAB wrote: > In the case of: > > tup[1] += [6, 7] > > what it's trying to do is: > > tup[1] = tup[1].__iadd__([6, 7]) > > tup[1] refers to a list, and the __iadd__ method _does_ mutate it, but > then Python tries to put the result that the method

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-11-30 Thread MRAB
On 2015-12-01 02:14, fl wrote: On Wednesday, June 24, 2015 at 8:17:08 PM UTC-4, Chris Angelico wrote: On Thu, Jun 25, 2015 at 9:52 AM, fl wrote: > The reason is that list implements __iadd__ like this (except in C, not Python): > > class List: > def __iadd__(self, other): > self.ex

Re: Could you explain this rebinding (or some other action) on "nums = nums"?

2015-11-30 Thread fl
On Wednesday, June 24, 2015 at 8:17:08 PM UTC-4, Chris Angelico wrote: > On Thu, Jun 25, 2015 at 9:52 AM, fl wrote: > > The reason is that list implements __iadd__ like this (except in C, not > > Python): > > > > class List: > > def __iadd__(self, other): > > self.extend(other) > >

Re: Could you explain why the following generates 4 same elements list?

2015-11-18 Thread dieter
fl writes: > Hi, > > I cannot reason out why the code: > > def mpl(): > return [lambda x : i * x for i in range(4)] > > print [m(2) for m in mpl()] > / > > has result: > > [6, 6, 6, 6] The "i" in your lambda definition is a variable reference which is not dereferenced (

Re: Could you explain why the following generates 4 same elements list?

2015-11-18 Thread Ian Kelly
On Wed, Nov 18, 2015 at 5:05 PM, fl wrote: > Hi, > > I cannot reason out why the code: > > def mpl(): > return [lambda x : i * x for i in range(4)] > > print [m(2) for m in mpl()] > / > > has result: > > [6, 6, 6, 6] > > > I have tried to simplify the above code to an easy und

Could you explain why the following generates 4 same elements list?

2015-11-18 Thread fl
Hi, I cannot reason out why the code: def mpl(): return [lambda x : i * x for i in range(4)] print [m(2) for m in mpl()] / has result: [6, 6, 6, 6] I have tried to simplify the above code to an easy understanding form, but fails. Either the modified code does not work

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-26 Thread Atnakus Arzah
t it is in the above line. Can you explain it to me? Its just a variable whose value isn't used in this specific expression, you could use 'x', 'y', or any other valid variable name there and it should work. -- Atnakus Arzah When in doubt, have a cookie! -- https://mail.python.org/mailman/listinfo/python-list

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-26 Thread Gary Herron
On 06/25/2015 06:07 PM, fl wrote: Hi, I read Ned's tutorial on Python. It is very interesting. On its last example, I cannot understand the '_' in: board=[[0]*8 for _ in range(8)] I know '_' is the precious answer, but it is still unclear what it is in the above

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-25 Thread Mark Lawrence
ge(8)] I know '_' is the precious answer, but it is still unclear what it is in the above line. Can you explain it to me? Thanks, Lots of people could carry on explaining things to you, but you don't appear to be making any attempt to do some research before posing your question

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-25 Thread fl
> > > board=[[0]*8 for _ in range(8)] > > > > > > I know '_' is the precious answer, but it is still unclear what it is > > in the above line. Can you explain it to me? > > > > > > Thanks, > > > > Lots of people could carry

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-25 Thread André Roberge
is the precious answer, but it is still unclear what it is > in the above line. Can you explain it to me? '_' is the previous answer ONLY when using the read-eval-print-loop interpreter. Here, it is the "name" of a variable; since we don't care about the particular nam

Re: Can anybody explain the '-' in a 2-D creation code?

2015-06-25 Thread Mark Lawrence
On 26/06/2015 02:07, fl wrote: Hi, I read Ned's tutorial on Python. It is very interesting. On its last example, I cannot understand the '_' in: board=[[0]*8 for _ in range(8)] I know '_' is the precious answer, but it is still unclear what it is in the above li

Can anybody explain the '-' in a 2-D creation code?

2015-06-25 Thread fl
Hi, I read Ned's tutorial on Python. It is very interesting. On its last example, I cannot understand the '_' in: board=[[0]*8 for _ in range(8)] I know '_' is the precious answer, but it is still unclear what it is in the above line. Can you explain it t

Re: Could you explain "[1, 2, 3].remove(2)" to me?

2015-06-25 Thread Jussi Piitulainen
fl writes: > aa=[1, 2, 3].remove(2) > > I don't know where the result goes. Could you help me on the question? That method modifies the list and returns None (or raises an exception). Get a hold on the list first: aa=[1, 2, 3] *Then* call the method. Just call the method, do not try to store t

  1   2   3   4   5   6   >