I receive the attribute error when I try to run the code.
with ParamExample(URI) as pe:
with MotionCommander(pe, default_height=0.3)as mc:
This is where the error occurs.
Traceback (most recent call last):
File "test44.py", line 156, in <module>
with ParamExample(URI) as pe:
AttributeError: __enter__
That is the traceback that I receive in my terminal. If you need to see more of my code, please let me know. Any help is appreciated, thank you!
More code would be appreciated (specifically the
ParamExampleimplementation), but I'm assuming you're missing the__enter__(and probably__exit__) method on that class.When you use a
withblock in python, the object in the with statement gets its__enter__method called, the block inside thewithruns, and then the__exit__gets called (optionally with exception info if one was raised). Thus, if you don't have an__enter__defined on your class, you'll see this error.Side note: you need to either indent the second
withblock so it's actually inside the first, OR replace these two lines withwhich is the same as nesting these two context managers (the name of the objects used by
withblocks).