On Tue, 6 Aug 2002, Guido van Rossum wrote: > > Perhaps it makes sense to allow "'thon' in 'python'" to return True, > > but still have "[1,2] in [0,1,2,3]" return False if we loosen the > > steadfast requirement that strings and lists be as much alike as > > possible. > > That was never a requirement. Strings and lists are merely similar > insofar as they have very similar needs for a slicing and subscripting > notation, and to a lesser extent for concatenation, repetition and > comparison. Perhaps what Skip meant was that strings and lists are both like sequences. At the moment, the meaning of "in" has two general definitions: one for sequence-like objects and one for mapping-like objects. The former is something along the lines of "e is in s if there exists an i such that s[i] == e". The question from a teaching perspective is: "Are strings a kind of sequence?" -- ?!ng
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4