Not found in the documentation

Chris Angelico rosuav at gmail.com
Wed Apr 28 17:11:09 EDT 2021


On Thu, Apr 29, 2021 at 5:16 AM elas tica <elasstiika at gmail.com> wrote:
>
>
> 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? ;)

The one you were referring to. The one that was in the quoted text.
The one that this subthread is about. Are you deliberately being
obtuse?

> > 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.

And by the definition you quoted - that some objects contain
references to other objects - the only containment is a range's
endpoints.

> But this discussion is undecidable since the Python Language Reference
> doesn't provide a decent definition of a container.

And yet, the definition you're complaining about is easily able to
answer these exact questions.

> > 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)

Before that, people had to use common sense, now there's a documented
answer. I'm not seeing a huge problem, but to the extent that it was a
problem, it has been solved.

> - what is a container ? what does mean "contains references" ? is a string a container or not and where the docs explains the answer?

Are you able to put an object reference inside a string? If not, it is
not a container. Is a string object able to keep other objects alive
by retaining references to them? No. It's right in the piece that you
quoted: some objects contain references to *other objects*.

> - what is exactly a token? are "is not" or "not in " tokens?

I'm not sure, because it depends on the parser, and different language
implementations can use different parsers. To what extent does it make
a difference? Where in the docs does something refer to "token" in a
way that needs to disambiguate this?

> > 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?
>

Ahhhh, now I get it. You're one of those people who hates on every
change that happens, because some other change didn't happen. Good. Go
post on Twitter, you'll fit in just fine.

ChrisA


More information about the Python-list mailing list