Python/flatten arbitrarily nested list
Olivier Cruchant
21

This is nice. Though I notice a couple of things that I’d personally prefer to do differently.

  • Passing an iterable that isn’t a list (I.e. string) simply returns the string. For me, this isn’t expected behavior — but it very well may be for you.
  • The use of “cuts” is overly-complex and not what I’d consider idiomatic python.

Thoughts on something like this?:

They both get the job done, but I’d prefer something like this as it gets me further away from JavaScript/C/etc… style and handles that one little edge case.

Please excuse my unsolicited feedback and I’d love to hear your thoughts.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.