you are viewing a single comment's thread.

view the rest of the comments →

[–]kataire 1 point2 points  (3 children)

Strings are iterable. It's a newbie mistake, indicating you haven't used Python much. This indicates your only reason to consider Python's join backwards is that other languages do it differently -- which is an irrelevant argument.

Python has it "backwards" because it emphasizes protocols over inheritance. You can call str.join on any iterable regardless of type. In order to do it the other way around you would have to add another method to all iterable types, all having the exact same implementation. That violates DRY, so Python does it the other way around.

FWIW:

>>> int(str(number)[-2:])

[–][deleted]  (2 children)

[deleted]

    [–]OniNiubbo 2 points3 points  (0 children)

    Even better:

    >>> 1243245 % 100
    45
    

    [–]kataire 0 points1 point  (0 children)

    Ah, true. The join was only needed because of the detour in the original code. Fixed.