MCPcopy Index your code
hub / github.com/python/cpython / _parents

Function _parents

Lib/zipfile/_path/__init__.py:26–42  ·  view source on GitHub ↗

Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [

(path)

Source from the content-addressed store, hash-verified

24
25
26def _parents(path):
27 """
28 Given a path with elements separated by
29 posixpath.sep, generate all parents of that path.
30
31 >>> list(_parents('b/d'))
32 ['b']
33 >>> list(_parents('/b/d/'))
34 ['/b']
35 >>> list(_parents('b/d/f/'))
36 ['b/d', 'b']
37 >>> list(_parents('b'))
38 []
39 >>> list(_parents(''))
40 []
41 """
42 return itertools.islice(_ancestry(path), 1, None)
43
44
45def _ancestry(path):

Callers

nothing calls this directly

Calls 2

_ancestryFunction · 0.85
isliceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…