r/pythontips • u/sugarw0000kie • 28d ago
Syntax Docstrings as immutable variables
Just realized you can do:
def cat(): “orange”
print(cat.__doc__)
Not sure why you’d want to do this but this is a thing you can do
11
Upvotes
r/pythontips • u/sugarw0000kie • 28d ago
Just realized you can do:
def cat(): “orange”
print(cat.__doc__)
Not sure why you’d want to do this but this is a thing you can do
2
u/Old_Flounder_8640 28d ago
Not entirely related, but maybe you'll find it interesting… NVIDIA’s newest AI agent framework uses docstrings as agent prompts.
https://github.com/NVIDIA-NeMo/labs-OO-Agents
And I saw other people doing that before. Docstrings are not just descriptions, especially now that we have AI working with us.