[Python-ideas] Add "equal" builtin function
Sjoerd Job Postmus
sjoerdjob at sjoerdjob.com
Thu Oct 6 10:52:46 EDT 2016
On Thu, Oct 06, 2016 at 02:45:11PM +0000, אלעזר wrote:
> It is a real problem. People are used to write `seq == [1, 2, 3]` and it
> passes unnoticed (even with type checkers) that if seq changes to e.g. a
> tuple, it will cause subtle bugs. It is inconvenient to write `len(seq) ==
> 3 and seq == [1, 2, 3]` and people often don't notice the need to write it.
>
> (I'd like to note that it makes sense for this operation to be written as
>
> *iter1 == *lst
>
> although it requires a significant change to the language, so a
> Sequence.equal function makes sense)
>
> Elazar
>
I think you're mistaken about the suggestion. It's not about a function
def equal(it1: Iterable, it2: Iterable) -> bool:
but about a function
def equal(it: Iterable) -> bool:
.
More information about the Python-ideas
mailing list