view() — anthropic-sdk-python Function Reference
Architecture documentation for the view() function in basic.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 460f1285_af24_2579_35b7_ffa668dec7e8["view()"] c2730250_7059_6f44_aa62_71ce88c5a804["LocalFilesystemMemoryTool"] 460f1285_af24_2579_35b7_ffa668dec7e8 -->|defined in| c2730250_7059_6f44_aa62_71ce88c5a804 42a84966_de9f_298e_a98d_c527baf8aa0e["_validate_path()"] 460f1285_af24_2579_35b7_ffa668dec7e8 -->|calls| 42a84966_de9f_298e_a98d_c527baf8aa0e style 460f1285_af24_2579_35b7_ffa668dec7e8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
examples/memory/basic.py lines 78–110
def view(self, command: BetaMemoryTool20250818ViewCommand) -> str:
full_path = self._validate_path(command.path)
if full_path.is_dir():
items: List[str] = []
try:
for item in sorted(full_path.iterdir()):
if item.name.startswith("."):
continue
items.append(f"{item.name}/" if item.is_dir() else item.name)
return f"Directory: {command.path}" + "\n".join([f"- {item}" for item in items])
except Exception as e:
raise RuntimeError(f"Cannot read directory {command.path}: {e}") from e
elif full_path.is_file():
try:
content = full_path.read_text(encoding="utf-8")
lines = content.splitlines()
view_range = command.view_range
if view_range:
start_line = max(1, view_range[0]) - 1
end_line = len(lines) if view_range[1] == -1 else view_range[1]
lines = lines[start_line:end_line]
start_num = start_line + 1
else:
start_num = 1
numbered_lines = [f"{i + start_num:4d}: {line}" for i, line in enumerate(lines)]
return "\n".join(numbered_lines)
except Exception as e:
raise RuntimeError(f"Cannot read file {command.path}: {e}") from e
else:
raise RuntimeError(f"Path not found: {command.path}")
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does view() do?
view() is a function in the anthropic-sdk-python codebase, defined in examples/memory/basic.py.
Where is view() defined?
view() is defined in examples/memory/basic.py at line 78.
What does view() call?
view() calls 1 function(s): _validate_path.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free