python 2.7 - How to check if class is initialized using the with statement? -
i'm using class example answer make sure files cleaned up: https://stackoverflow.com/a/865272/651779
what when call
pacakge_object = packageresource() instead of
with packageresource() package_obj: # stuff it gives error explaining class can used with statement. there way of knowing if class initialized with packageresource() package_obj: instead of pacakge_object = packageresource()?
set flag in __enter__ function, , if properties / methods of class called without flag set, cheating on you.
Comments
Post a Comment