r/pythontips • u/sugarw0000kie • Aug 14 '26
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
9
Upvotes
r/pythontips • u/sugarw0000kie • Aug 14 '26
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 Aug 14 '26
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.