Posts: 4,646
Threads: 1,493
Joined: Sep 2016
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 544
Threads: 15
Joined: Oct 2016
Aug-08-2018, 12:51 AM
(This post was last modified: Aug-08-2018, 12:58 AM by Windspar.)
Probably because sets are mutable. You need immutable objects.
simple solution is to wrap it with a tuple.
a[tuple(set([1,1,4,4,4,4,5,]))] = 1
99 percent of computer problems exists between chair and keyboard.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
Aug-08-2018, 01:33 AM
(This post was last modified: Aug-08-2018, 01:33 AM by Skaperen.)
so how can i get any one element from a frozenset? with a mutable set i would pop one and put it back in. but i see no methods to get something out of a frozenset. i guess i just have to make it into a regular set or a tuple.
some_arbitrary_element = tuple(my_frozen_set)[0]
assuming it isn't empty.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,646
Threads: 1,493
Joined: Sep 2016
i'm not using it as a key per se, but using the set as a non-duplicating collection. get an element out is to check what types the set probably has (to avoid a full test of everything if the random item shows it is not needed)
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.