Re: Different "look and feel" of some built-in functions

2021-10-02 Thread Oscar Benjamin
On Sat, 25 Sept 2021 at 02:11, Oscar Benjamin wrote: > On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote: > >> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin >> wrote: >> > >> > On Sat, 25 Sept 2021 at 00:37, Greg Ewing >> > wrote: >> > > I suppose they could be fiddled somehow to make it p

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Dieter Maurer
Steve Keller wrote at 2021-9-25 00:15 +0200: >"Dieter Maurer" writes: > >> Steve Keller wrote at 2021-9-24 11:48 +0200: >> >Why do some built-in Python functions feel so differently: >> >> Because the typical use cases are different >> >> [...] >> >> >while other functions like set.union() and set

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Chris Angelico
On Sun, Sep 26, 2021 at 2:27 AM Dieter Maurer wrote: > > Stefan Ram wrote at 2021-9-24 16:48 GMT: > >"Dieter Maurer" writes: > >>A list is ordered. Therefore, it is important where > >>in this order an element is added. Thus, for a list, > >>`append` is a better name than `add` -- because it alre

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Dieter Maurer
Stefan Ram wrote at 2021-9-24 16:48 GMT: >"Dieter Maurer" writes: >>A list is ordered. Therefore, it is important where >>in this order an element is added. Thus, for a list, >>`append` is a better name than `add` -- because it already >>tells us in the name where it adds the new element. > > In

Re: Different "look and feel" of some built-in functions

2021-09-25 Thread Oscar Benjamin
On Sat, 25 Sept 2021 at 02:16, Chris Angelico wrote: > On Sat, Sep 25, 2021 at 11:11 AM Oscar Benjamin > wrote: > > > > On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote: > >> > >> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin > >> wrote: > >> > > >> > On Sat, 25 Sept 2021 at 00:37, Greg E

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 11:11 AM Oscar Benjamin wrote: > > On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote: >> >> On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin >> wrote: >> > >> > On Sat, 25 Sept 2021 at 00:37, Greg Ewing >> > wrote: >> > > I suppose they could be fiddled somehow to make

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Oscar Benjamin
On Sat, 25 Sept 2021 at 02:01, Chris Angelico wrote: > On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin > wrote: > > > > On Sat, 25 Sept 2021 at 00:37, Greg Ewing > > wrote: > > > I suppose they could be fiddled somehow to make it possible, but > > > that would be turning them into special cases

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 10:56 AM Oscar Benjamin wrote: > > On Sat, 25 Sept 2021 at 00:37, Greg Ewing > wrote: > > > On 25/09/21 10:15 am, Steve Keller wrote: > > > BTW, I like how the min() and max() functions allow both ways of being > > > called. > > > > That wouldn't work for set.union and set

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Oscar Benjamin
On Sat, 25 Sept 2021 at 00:37, Greg Ewing wrote: > On 25/09/21 10:15 am, Steve Keller wrote: > > BTW, I like how the min() and max() functions allow both ways of being > > called. > > That wouldn't work for set.union and set.intersection, because as > was pointed out, they're actually methods, so

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Greg Ewing
On 25/09/21 10:15 am, Steve Keller wrote: BTW, I like how the min() and max() functions allow both ways of being called. That wouldn't work for set.union and set.intersection, because as was pointed out, they're actually methods, so set.union(some_seq) is a type error: >>> a = {1, 2} >>> b = {

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Steve Keller
"Dieter Maurer" writes: > Steve Keller wrote at 2021-9-24 11:48 +0200: > >Why do some built-in Python functions feel so differently: > > Because the typical use cases are different > > [...] > > >while other functions like set.union() and set.intersection() work on > >a list of arguments but n

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Sat, Sep 25, 2021 at 3:42 AM Stefan Ram wrote: > > "Dieter Maurer" writes: > >A list is ordered. Therefore, it is important where > >in this order an element is added. Thus, for a list, > >`append` is a better name than `add` -- because it already > >tells us in the name where it adds the new

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Dieter Maurer
Stefan Ram wrote at 2021-9-24 14:53 GMT: >Steve Keller writes: >>Why do some built-in Python functions feel so differently: > >|>>> s = set() >|>>> s.add( 1 ) >|>>> > > >|>>> l = [] >|>>> l.add( 1 ) > >| >|Traceback (most recent call last): >| File "", line 1, in >|AttributeError: 'list' object

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Dieter Maurer
Steve Keller wrote at 2021-9-24 11:48 +0200: >Why do some built-in Python functions feel so differently: Because the typical use cases are different >For example sum(), all(), any() expect exactly one argument which is a >sequence to operate on, i.e. a list, an iterator or a generator etc. > >

Re: Different "look and feel" of some built-in functions

2021-09-24 Thread Chris Angelico
On Fri, Sep 24, 2021 at 11:47 PM Steve Keller wrote: > > Why do some built-in Python functions feel so differently: > > For example sum(), all(), any() expect exactly one argument which is a > sequence to operate on, i.e. a list, an iterator or a generator etc. > > sum([1,2,3,4]) > sum(ran

Different "look and feel" of some built-in functions

2021-09-24 Thread Steve Keller
Why do some built-in Python functions feel so differently: For example sum(), all(), any() expect exactly one argument which is a sequence to operate on, i.e. a list, an iterator or a generator etc. sum([1,2,3,4]) sum(range(1, 101)) sum(2**i for i in range(10)) all([True, False])