On Mon, May 4, 2020 at 11:43 AM Soni L. <fakedme...@gmail.com> wrote:
>
>
>
> On 2020-05-03 10:19 p.m., Steven D'Aprano wrote:
> > On Sat, May 02, 2020 at 11:01:21PM +0200, Alex Hall wrote:
> > > On Sat, May 2, 2020 at 10:52 PM Dominik Vilsmeier 
> > > <dominik.vilsme...@gmx.de>
> > > wrote:
> > >
> > > > `frozenset` and `set` make a counterexample:
> > > >
> > > > >>> frozenset({1}) == {1}
> > > > True
> > > >
> > >
> > > Nice catch! That's really interesting. Is there reasoning behind
> > > `frozenset({1}) == {1}` but `[1] != (1,)`, or is it just an accident of
> > > history?
> >
> > Conceptually, sets are sets, whether they are mutable or frozen.
> >
> >
> > > Isn't a tuple essentially just a frozenlist? I know the intended
> > > semantics of tuples and lists tend to be different, but I'm not sure 
> > > that's
> > > relevant.
> >
> > o_O
> >
> > If the intended semantics aren't relevant, I'm not sure what is...
> >
> >
>
> for what it's worth, I see myself using tuples as frozen lists more
> often than their "intended semantics".
>
> more specifically, you can't pass lists to:
>
> 1. isinstance
> 2. issubclass
> 3. str.endswith
>
> among others. so I sometimes just convert a list of strings into a tuple
> of strings and store it somewhere so I can use it with str.endswith
> later. (this is not how you're "supposed" to implement domain suffix
> blocks but w/e)

That doesn't mean you're using a tuple as a frozen list - it means
you're using a tuple as a static collection. I've never had a
situation where I've wanted to use isinstance with a list that gets
built progressively at run-time; it's always a prewritten collection.

I don't see what this has to do with lists and tuples. You're using
tuples the way they're meant to be used.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/JYWQKTJE3XHHIIEYBYFZK4OGCDM7I2SL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to