# LangWart: Method congestion from mutate multiplicty

Rick Johnson rantingrickjohnson at gmail.com
Tue Feb 12 05:55:28 CET 2013

```On Monday, February 11, 2013 7:27:30 AM UTC-6, Chris Angelico wrote:

> So...
> flatten([None, 23, [1, 2, 3], (2, 3), ["spam", "ham"]])
>
> would return
>
> [None, 23, 1, 2, 3, (2, 3), "spam", "ham"]
>
> I think that's even more unexpected.

Why? Are you over-analyzing? Show me a result that /does/ make you happy.

Do you remember when i was talking about how i attempt to intuit interfaces before reading any docs? Well i have news for you Chris, what you are doing is NOT "intuiting" how flatten will work, what you are doing is "projecting" how flatten will work; these are two completely different concepts Chris.

The word "flatten" is too ambiguous to intuit the /exact/ "result". The only intuit-able attribute of flatten is that calling list.flatten() will result in a list that probably looks different than the current list. Intuition is your friend; not your own personal "clairvoyant side-kick"!

To learn the interface you need to initially "intuit", but then you need to test. Run a few example sequences and see what results you get, compare those results to what you /expected/ to get. If it works the way you expect, move on to the next topic, if not, dig deeper.

You can't procrastinate over this method forever because NEWSFLASH you will /never/ find a perfect flatten algorithm that will please /everyone/, so just pick the most logical and consistent, and MOVE ON!

Infinite recursion anyone?

while obj.repeat is True:
obj.lather()
obj.rinse()
obj.repeat = True

```

More information about the Python-list mailing list