News for hackers. Stuff that matters.
Re:Strange line of Python by wisty on Friday November 18, 2011 @04:50PM (#3253599)
> What's so hard about this?

I've been programming python for quite a while, and never seen anything like

    main_iterator = 'abc'
    inner_iterator = '123'
    [c+n for c in main_iterator for n in inner_iterator]
It's just ugly. I guess it has its purpose (cross products?) but it's still ugly.

Once you know what that means, it's obvious what you mean by

    [j for i in main_iterator for j in inner_iterator(i)]
But I've just never seen two loops crushed together like this.

There are no comments on this comment yet.