def get_sandbox_python_path(inherit_from_parent=True, inherit_parent_virtualenv=True):
 sandbox_python_path = []
 parent_python_path = os.environ.get('PYTHONPATH', '')
 parent_python_path = parent_python_path.split(':')
 parent_python_path = [path for path in parent_python_path if path]
 if inherit_from_parent:
  sandbox_python_path.extend(parent_python_path)
 if (inherit_parent_virtualenv and hasattr(sys, 'real_prefix')):
  site_packages_dir = get_python_lib()
  assert (sys.prefix in site_packages_dir)
  sandbox_python_path.append(site_packages_dir)
 sandbox_python_path = ':'.join(sandbox_python_path)
 sandbox_python_path = (':' + sandbox_python_path)
 return sandbox_python_path

def get_sandbox_python_path ( inherit_from_parent = True , inherit_parent_virtualenv = True ) : sandbox_python_path = [ ] parent_python_path = os . environ . get ( 'PYTHONPATH' , '' ) parent_python_path = parent_python_path . split ( ':' ) parent_python_path = [ path for path in parent_python_path if path ] if inherit_from_parent : sandbox_python_path . extend ( parent_python_path ) if ( inherit_parent_virtualenv and hasattr ( sys , 'real_prefix' ) ) : site_packages_dir = get_python_lib ( ) assert ( sys . prefix in site_packages_dir ) sandbox_python_path . append ( site_packages_dir ) sandbox_python_path = ':' . join ( sandbox_python_path ) sandbox_python_path = ( ':' + sandbox_python_path ) return sandbox_python_path
return pythonpath environment variable value for the new sandboxed environment .