(obj=_sentinel, glob=None)
| 3 | _sentinel = object() |
| 4 | |
| 5 | def dir(obj=_sentinel, glob=None): |
| 6 | from fnmatch import fnmatchcase |
| 7 | if obj is _sentinel: |
| 8 | # Get the locals of the caller, not our locals. |
| 9 | names = sorted(sys._getframe(1).f_locals) |
| 10 | else: |
| 11 | names = _dir(obj) |
| 12 | if glob is None: return names |
| 13 | return [name for name in names if fnmatchcase(name, glob)] |