Python Forum
flattening a list with some elements being lists
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
flattening a list with some elements being lists
#14
i like to have my code, especially functions, work in both Python2 (until at least Python2 EOL) and Python3 (back as far as possible) without using any modules. and if it really needs a module, preferably one that comes in Python itself, and if not that, one that can be installed with pip. i think my own flatten function managed to do that. it was a bit longer, but "simpler" in the sense of not using things like generators an subgenerators. my technique to manage the recursion was sloppy. buran did better and it still meets my goals (like not needing a module). even better is that it doesn't need variable arguments like i used. and even better is that the whole thing is functional.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
RE: flattening a list with some elements being lists - by Skaperen - Aug-06-2018, 11:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  unable to remove all elements from list based on a condition sg_python 3 612 Jan-27-2024, 04:03 PM
Last Post: deanhystad
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 597 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  List all possibilities of a nested-list by flattened lists sparkt 1 1,034 Feb-23-2023, 02:21 PM
Last Post: sparkt
  Checking if a string contains all or any elements of a list k1llcod3 1 1,283 Jan-29-2023, 04:34 AM
Last Post: deanhystad
  user input values into list of lists tauros73 3 1,222 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  returning a List of Lists nafshar 3 1,197 Oct-28-2022, 06:28 PM
Last Post: deanhystad
  Creating list of lists, with objects from lists sgrinderud 7 1,828 Oct-01-2022, 07:15 PM
Last Post: Skaperen
  How to change the datatype of list elements? mHosseinDS86 9 2,166 Aug-24-2022, 05:26 PM
Last Post: deanhystad
  ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 5,472 May-17-2022, 11:38 AM
Last Post: Larz60+
  How to efficiently average same entries of lists in a list xquad 5 2,282 Dec-17-2021, 04:44 PM
Last Post: xquad

Forum Jump:

User Panel Messages

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