Are instances of user-defined classes mutable?

2020-08-06 Thread ZHAOWANCHENG
the doc of dictionary said "if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key." i think a instance of user-defined class is mutable, but i found it can be placed into a tuple that as a key of a dict: >>> class mycls(object): ... a = 1

Is this AI

2020-08-06 Thread yashvats8
I have created a program in Python Is my Program Artificial Intelligent ? In this I train the program to answer my question Eg 1: Training 0,0,0,1 > Ans is 0 0,0,1,0--> Ans is 1 0,1,1,0--> Ans is 1 You can observe ans is 3rd Element Testing 0,0,1,0 --> Ans ? It gives 1 Eg 2

Re: Are instances of user-defined classes mutable?

2020-08-06 Thread Robin Becker
On 06/08/2020 05:17, ZHAOWANCHENG wrote: the doc of dictionary said "if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key." i think a instance of user-defined class is mutable, but i found it can be placed into a tuple that as a key of a dict: >>

Re: Are instances of user-defined classes mutable?

2020-08-06 Thread Richard Damon
On 8/6/20 12:17 AM, ZHAOWANCHENG wrote: > the doc of dictionary said "if a tuple contains any mutable object either > directly or indirectly, it cannot be used as a key." > i think a instance of user-defined class is mutable, but i found it can be > placed into a tuple that as a key of a dict: >

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: Are instances of user-defined classes mutable?

2020-08-06 Thread Ethan Furman
On 8/6/20 7:40 AM, Robin Becker wrote: On 06/08/2020 05:17, ZHAOWANCHENG wrote: So are instances of user-defined classes mutable or immutable? user class instances are clearly mutable, and in my python 3.8 you can do horrid things like this > > [snip buggy/incorrect uses of __hash__] You

Re: Are instances of user-defined classes mutable?

2020-08-06 Thread Richard Damon
On 8/6/20 10:40 AM, Robin Becker wrote: > On 06/08/2020 05:17, ZHAOWANCHENG wrote: >> the doc of dictionary said "if a tuple contains any mutable object >> either directly or indirectly, it cannot be used as a key." >> i think a instance of user-defined class is mutable, but i found it >> can be pl

Re: Are instances of user-defined classes mutable?

2020-08-06 Thread David Lowry-Duda
On Thu, Aug 06, 2020 at 12:17:17PM +0800, ZHAOWANCHENG wrote: > the doc of dictionary said "if a tuple contains any mutable object either > directly or indirectly, it cannot be used as a key." > i think a instance of user-defined class is mutable, but i found it can be > placed into a tuple that

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

Re: Is this AI

2020-08-06 Thread Souvik Dutta
This is probably more ML then AI. On Thu, Aug 6, 2020, 7:57 PM wrote: > I have created a program in Python > > Is my Program Artificial Intelligent ? > > In this I train the program to answer my question > Eg 1: > > Training > 0,0,0,1 > Ans is 0 > 0,0,1,0--> Ans is 1 > 0,1,1,0--> Ans

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

Explicit is better than Implicit

2020-08-06 Thread Skip Montanaro
Hmmm... Rename genes, fix Excel, or dump Excel in favor of Python? I know what my choice would have been. :-) https://www.theverge.com/2020/8/6/21355674/human-genes-rename-microsoft-excel-misreading-dates Skip -- 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 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 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 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 UTC-5, Chris Angelico wrote:

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 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 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: Explicit is better than Implicit

2020-08-06 Thread dn via Python-list
On 07/08/2020 05:33, Skip Montanaro wrote: Hmmm... Rename genes, fix Excel, or dump Excel in favor of Python? I know what my choice would have been. :-) https://www.theverge.com/2020/8/6/21355674/human-genes-rename-microsoft-excel-misreading-dates At the risk of screaming off-topic... The ar

Re: Explicit is better than Implicit

2020-08-06 Thread Cameron Simpson
On 07Aug2020 09:40, DL Neil wrote: >On 07/08/2020 05:33, Skip Montanaro wrote: >>Hmmm... Rename genes, fix Excel, or dump Excel in favor of Python? I know >>what my choice would have been. :-) >> >>https://www.theverge.com/2020/8/6/21355674/human-genes-rename-microsoft-excel-misreading-dates > > >

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: Explicit is better than Implicit

2020-08-06 Thread Skip Montanaro
> > When Excel reads a file, it looks for stuff and decides to upgrade its > type. Eg dates etc (particularly pernicious with US-style dates versus > the rest of the planet). Mojibake for data ensues. > > As always, I am reminded of Heuer's Razor: > > If it can't be turned off, it's not a feat

Re: Explicit is better than Implicit

2020-08-06 Thread Python
On Thu, Aug 06, 2020 at 07:19:01PM -0500, Skip Montanaro wrote: > > > > When Excel reads a file, it looks for stuff and decides to upgrade its > > type. Eg dates etc (particularly pernicious with US-style dates versus > > the rest of the planet). Mojibake for data ensues. > > > > As always, I am r

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 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:Re: Are instances of user-defined classes mutable?

2020-08-06 Thread ZHAOWANCHENG
At 2020-08-06 23:17:57, "Richard Damon" wrote: >On 8/6/20 10:40 AM, Robin Becker wrote: >> On 06/08/2020 05:17, ZHAOWANCHENG wrote: >>> the doc of dictionary said "if a tuple contains any mutable object >>> either directly or indirectly, it cannot be used as a key." >>> i think a instance of user

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