class_docstr: shared implementation for filesystem path objects.
docstr: return a string which is a relative path from self
  (assumed to be a directory) to dest such that
  self.join(bestrelpath) == dest and if not such
  path can be determined return dest.
docstr_tok: ["return","a","string","which","is","a","relative","path","from","self","(","assumed","to","be","a","directory",")","to","dest","such","that","self.join","(","bestrelpath",")","==","dest","and","if","not","such","path","can","be","determined","return","dest","."]
code: def bestrelpath(self, dest):
      """return a string which is a relative path from self
      (assumed to be a directory) to dest such that
      self.join(bestrelpath) == dest and if not such
      path can be determined return dest.
      """
      try:
          if self == dest:
              return os.curdir
          base = self.common(dest)
          if not base:  # can be the case on windows
              return str(dest)
          self2base = self.relto(base)
          reldest = dest.relto(base)
          if self2base:
              n = self2base.count(self.sep) + 1
          else:
              n = 0
          l = [os.pardir] * n
          if reldest:
              l.append(reldest)
          target = dest.sep.join(l)
          return target
      except AttributeError:
          return str(dest)
  
imports: import warnings
  import os
  import sys
  import posixpath
  import fnmatch
  import py
label_desc: Use image node_id 18 for calling the PathBase obj's underlying member method code with example usage: obj.bestrelpath(dest) and returns: target, os, str, str