PRE-PEP: new Path class; (UPDATE) isValid, exists

Christoph Becker-Freyseng webmaster at beyond-thoughts.com
Fri Jan 9 01:43:15 CET 2004


I think the implementation should be changed for the "NormalFSPath".

def exists(self):
	try:
		os.stat(str(self))
		return True
	except OSError, exc:	# Couldn't stat so what's up
		if exc.errno == errno.ENOENT:	# it simply doesn't exist
			return False
	return None	# the path is invalid



def isValid(self, raiseExc=False):
	if self.exists() is None:
		if raiseExc:
			raise InvalidPath
		else:
			return False
	else:
		return True




Christoph Becker-Freyseng






More information about the Python-list mailing list