I think your free function is a big improvement. However, I suggest that your function only implement the dict-style access. Here are some arguments (which are, unfortunately, somewhat contradictory):
- It promotes too many different ways to do the same thing. I'd strongly prefer that we promote only one technique in this function, as the preferred option. This will make it easier for users, since we'll end up with more consistency. (Maybe it should be a new ticket to make all tasks work the same way).
- Existing code that uses .frame or .display doesn't need the function; the code to extract the frame is trivial.
Despite the simplicity of .frame or .display, I think the dict technique is preferable because it easily allows different frames to show different things. Even if a task starts with a simple one-frame display, it could easily gain additional frames later.
Regarding self._display if anetAstrometry.py; you are right. I missed the code.