Python Forum
list approach due nested order
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list approach due nested order
#4
Combining frozenset with unique_everseen yields my preferred solution
from more_itertools import unique_everseen

def create():
    yield ['a', 'b']
    yield ['b', 'a']
    yield [1, 2]
    
unique = list(unique_everseen(create(), key=frozenset))
print(unique)
Output:
[['a', 'b'], [1, 2]]
Reply


Messages In This Thread
list approach due nested order - by 3Pinter - Oct-07-2019, 08:44 AM
RE: list approach due nested order - by stranac - Oct-07-2019, 08:49 AM
RE: list approach due nested order - by 3Pinter - Oct-07-2019, 09:54 AM
RE: list approach due nested order - by Gribouillis - Oct-07-2019, 10:15 AM
RE: list approach due nested order - by 3Pinter - Oct-07-2019, 01:41 PM
RE: list approach due nested order - by Gribouillis - Oct-07-2019, 01:46 PM
RE: list approach due nested order - by 3Pinter - Oct-07-2019, 01:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What is a faster way to deep copy a nested list without using .deepcopy()? Shervin_Ataeian 1 1,846 Oct-13-2024, 01:28 PM
Last Post: Pedroski55
  Advice needed on how to approach this problem... sawtooth500 1 1,535 Apr-06-2024, 01:55 PM
Last Post: snippsat
  Copying the order of another list with identical values gohanhango 7 2,926 Nov-29-2023, 09:17 PM
Last Post: Pedroski55
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 3,199 May-22-2023, 10:39 PM
Last Post: ICanIBB
  List all possibilities of a nested-list by flattened lists sparkt 1 1,901 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Updating nested dict list keys tbaror 2 2,061 Feb-09-2022, 09:37 AM
Last Post: tbaror
  Python Program to Find the Total Sum of a Nested List vlearner 8 8,641 Jan-23-2022, 07:20 PM
Last Post: menator01
  Looping through nested elements and updating the original list Alex_James 3 3,080 Aug-19-2021, 12:05 PM
Last Post: Alex_James
  Order a list with successive permutations based on another list yvrob 3 3,937 Mar-19-2021, 08:20 AM
Last Post: supuflounder
  Group List Elements according to the Input with the order of binary combination quest_ 19 9,939 Jan-28-2021, 03:36 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020