sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #15936
Re: [Question #221131]: "with" statement
Question #221131 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/221131
Status: Open => Answered
RaiMan proposed the following answer:
with x as y:
some code
# with end
only works and guarantees:
- that x's __enter__ is called at the beginning
- that y is assigned the return value of __enter__
- that at "with end" x's __exit__ is called
since y is the object you are using, it references the same object (lets name it anonymous_object, created by MyClass()), that is referenced by your self.myClass property of x.
Setting self.myClass to None , only cuts the rope between self.myClass and anonymous_object, but y (in your case aNewClass) still references anonymous_object.
So your 2 variables simply reference the same object, which will live as
long as at least one reference to it exists (aNewClass in your case).
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.