Python Forum

Full Version: how to put a frozenset in a frozen set
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
what is a an expression to put a frozenset inside a frozenset? since a frozenet is hashable it should work ... in theory. when i try it i just get a new frozenset with the members of the one i tried to put in.
Yeah, that's because frozensets are immutable. That's what makes them hashable.
i mean in the expression that initially creates them. sorry for the confusion.
Then I have absolutely no idea what you are talking about.
is that what you a looking for

>>> foo = frozenset([1, 2, 3])
>>> foo
frozenset({1, 2, 3})
>>> bar = frozenset((foo, ))
>>> bar
frozenset({frozenset({1, 2, 3})})
not that I see the point of making frozenset with one frozenset inside it (i.e. I guess you did
>>> bar = frozenset(foo)
>>> bar
frozenset({1, 2, 3})
i was trying a way like one of those and was getting a single frozenset with the original numbers. it appeared that frozenset() was just trying to convert whatever container was passed to it to be a frozenset. but now it seems to be working. now i don't know how to do a conversion. one way or the other it does something, but i never know which.

some other code gets numbers out of containers at any depth, and this is part of the test code for it (trying many combinations).