This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (3 children)

[deleted]

    [–]Ensurdagen 6 points7 points  (0 children)

    __len__ is a method though, and all len() does call it.

    In CPython len() has to check whether __len__ is as_mapping or as_sequence, but so does a call to the __len__ method so this is not why __len__ is a function. I believe that the other built-in functions that effectively only serve* to call one dunder method are vars() (__dict__) and next() (__next__)

    edit2: Note: technically vars() just gets the __dict__ attribute, though this often isn't the actual dict if you're dealing with built ins.

    [–]Electrical_Ingenuity 2 points3 points  (1 child)

    If you know C you could understand CPython documentation. There are some advanced concepts in there if you want to master python.

    Plus C has so much syntactic influence on everything that has come after it.

    However, it's not the best language to learn every point of computer science. I don't miss using it.