Le mercredi 28 avril 2021 à 17:36:32 UTC+2, Chris Angelico a écrit : > > if a string or a range object is a container or not. For instance, > > can we say that range(100) contains 42 ? > Not by that definition of container.
Which definition? ;) > some objects have references to other objects, and the high level > concept that some objects support the "in" operator for containment > checks. They are similar, in that many objects use "in" to check the > exact same set that they refer to, but they are not the same (for > instance, range(1, 10, 1000000) requires a reference to the "one > million" integer, even though it is not actually part of the range). The problem with range is different because we all know that a range object doesn't hold (= contain) the int's (except the endpoints and the step) we can iterate on, instead a range object computes on the fly the int's it holds. On the contrary, the string "2021" holds the digits, even "2021"*10**6 does. But this discussion is undecidable since the Python Language Reference doesn't provide a decent definition of a container. > What are you actually trying to prove here? What > problem are you solving? Or is this just nitpicking for the sake of > it? I was only looking for basic definitions, unfortunately the official docs are not able to provide : - what is the str value of an int? (we have to wait until Python 3.8.6 docs to get the response) - what is a container ? what does mean "contains references" ? is a string a container or not and where the docs explains the answer? - what is exactly a token? are "is not" or "not in " tokens? > the language definition. CPython, for instance, is in process of > completely rewriting its parser, and what about rewriting and *redesigning* the docs? Is there even a discussion about this? Nobody complains? -- https://mail.python.org/mailman/listinfo/python-list