LangWart: Method congestion from mutate multiplicty

Chris Angelico rosuav at gmail.com
Mon Feb 11 14:27:30 CET 2013


On Mon, Feb 11, 2013 at 11:53 PM, Rick Johnson
<rantingrickjohnson at gmail.com> wrote:
> Which primitive(s) should NOT have been expanded in your opinion? The "Point" object? I agree, that's why MY implementation would call seq.flatten() on all sub-sequences THEREBY allowing each subtype to define it's own flatten behavior. Of course the default behavior of the SequenceBase#flatten would be to flatten everything.
>
> However, ImmutableSequence Types would not flatten. In your example ["spam", "ham"] would not be expanded to ['s', 'p', 'a', 'm', 'h', 'a', 'm']. psst: strings and tuples are immutable!

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.

ChrisA



More information about the Python-list mailing list