class LazyFile:
	def __init__(self, path, *args, **kwargs):
		self.path = path
		self.args = args
		self.kwargs = kwargs
		self.file = None

	def read(self, length=-1):
		self.open()
		return self.file.read(length)

	def open(self):
		if self.file is None:
			self.file = open(self.path, *self.args, **self.kwargs)

	def close(self):
		if self.file is None:
			return None
		value = self.file.close()
		self.file = None
		return value


def lazy_open(path, *args, **kwargs):
	return LazyFile(path, *args, **kwargs)
