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

Christoph Becker-Freyseng webmaster at beyond-thoughts.com
Thu Jan 8 19:43:15 EST 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