Re: Equivalents of Ruby's "!" methods?



Grzegorz Staniak wrote:

BTW, is there a reason why sorted() on a list returns a list, while reversed() on the same list returns an iterator?

the algorithm required to sort a sequence is something entirely different from the algorithm required to loop over a sequence in reverse. we went through this a few days ago.

</F>

.



Relevant Pages

  • Re: What about an EXPLICIT naming scheme for built-ins?
    ... But having sortedto return a iterator ... sortedreturns a brand new sorted sequence. ... -- sorting long sequences to use only a few of the first elements. ... if you need to sort a long list to get the top 10 elements. ...
    (comp.lang.python)
  • What about an EXPLICIT naming scheme for built-ins?
    ... can be used in expressions, as it returns a copy of the sequence, sorted. ... reverse() works in-place. ... The past tense of sort() indicates that a copy of the sequence is returned. ...
    (comp.lang.python)
  • Re: What about an EXPLICIT naming scheme for built-ins?
    ... as the iterator versions of sortedand reversed. ... > can be used in expressions, as it returns a copy of the sequence, sorted. ... > reverse() works in-place. ... > I would like to see Python introducing a naming scheme for built-ins. ...
    (comp.lang.python)
  • Re: What about an EXPLICIT naming scheme for built-ins?
    ... > reverse() works in-place. ... > The past tense of sort() indicates that a copy of the sequence is returned. ...
    (comp.lang.python)
  • Re: What about an EXPLICIT naming scheme for built-ins?
    ... > can be used in expressions, as it returns a copy of the sequence, sorted. ... > reversed- a new builtin that takes a sequence and returns an iterator ... > reverse() works in-place. ... You could have a sortediter as well ...
    (comp.lang.python)