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

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -