1

one day I just wonder how to implement str, list and map methods in python.

when I tried to "go to definition" for split() and the code seems like

def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
    """
    S.split(sep=None, maxsplit=-1) -> list of strings

    Return a list of the words in S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string is a separator and empty strings are
    removed from the result.
    """
    return []

How can I find those method's codes?

user3773632
  • 445
  • 6
  • 20
  • Burhan Khalid the poster is asking how `str()`, `list()`, and `map()` are implemented, and was just using `split()` as an example. – Dillon Davis Jul 16 '18 at 06:36
  • 1
    Since I can't post this as an answer, excuse the poorly formatted comment/answer- [str() function line 304](https://github.com/python/cpython/blob/master/Lib/locale.py), [map() function line 558](https://github.com/python/cpython/blob/master/Lib/concurrent/futures/_base.py), [list() function line 1974](https://github.com/python/cpython/blob/master/Lib/pydoc.py). I'd post the source here, but it would take 4 comments to do so... – Dillon Davis Jul 16 '18 at 06:42

0 Answers0