Return a context manager, which changes to the path's dir during the managed "with" context. On __enter__ it returns the old dir, which might be ``None``.
(self)
| 1003 | |
| 1004 | @contextmanager |
| 1005 | def as_cwd(self): |
| 1006 | """ |
| 1007 | Return a context manager, which changes to the path's dir during the |
| 1008 | managed "with" context. |
| 1009 | On __enter__ it returns the old dir, which might be ``None``. |
| 1010 | """ |
| 1011 | old = self.chdir() |
| 1012 | try: |
| 1013 | yield old |
| 1014 | finally: |
| 1015 | if old is not None: |
| 1016 | old.chdir() |
| 1017 | |
| 1018 | def realpath(self): |
| 1019 | """Return a new path which contains no symbolic links.""" |