Re: What about an EXPLICIT naming scheme for built-ins?

From: David Fraser (davidf_at_sjsoft.com)
Date: 09/03/04


Date: Fri, 03 Sep 2004 21:52:40 +0200

Marco Aschwanden wrote:
> I just read the changes for 2.4 and while scanning the list the past
> tense built-ins got my attention:
>
> sorted() - a new builtin sorted() acts like an in-place list.sort() but
> 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
> that loops over the elements of the sequence in reverse order (PEP 322)
>
>
> sort() works in-place.
> reverse() works in-place.
>

How about reversed() returning a sequence, like sorted does, but adding
an iterator function called riter or reverseiter to iterate over
sequences in reverse order. That would then be similar to the iter
builtin. You could have a sortediter as well

David



Relevant Pages

  • 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?
    ... > How about reversedreturning a sequence, like sorted does, but adding ... > an iterator function called riter or reverseiter to iterate over ... > sequences in reverse order. ... You could have a sortediter as well ...
    (comp.lang.python)
  • Re: Strange behaviour with reversed()
    ... I suppose the doc could be augmented with "The iterator is intialized once ... | use reversedon a sequence, ... The 'reverse' of a changing sequence, especially one changing in length, is ... So the above is consistent with storing a reference (and an index ...
    (comp.lang.python)
  • Re: Noob questions about Python
    ... Note that there's also the reverse() function that returns a reverse ... iterator over any sequence, ...
    (comp.lang.python)
  • Re: Reverse order numbered list
    ... The challenge is to create such a sequence as my ... Brotha Iz ... Johnny Love Jazz ... Is there a simple method to display a numbered list in reverse ...
    (microsoft.public.word.numbering)