I'm using the class example from this answer to make sure certain files are always cleaned up: https://stackoverflow.com/a/865272/651779
What I would like is that when I call
pacakge_object = PackageResource()
instead of
with PackageResource() as package_obj:
# do stuff
it gives an error explaining this class can only be used with the with
statement. Is there a way of knowing if the class was initialized with with PackageResource() as package_obj:
instead of pacakge_object = PackageResource()
?