Note Every time you rebuild with the same tag, the old image loses its tag and becomes <none>:<none>. These pile up fast. Volumes from removed containers also linger. Schedule regular prune commands or add them to your CI cleanup steps.
result =Noneif result isNone:print("No result yet")# Common pattern: optional returndeffind_user(user_id:int)->str|None:returnNone
Output
No result yet
Note Always compare to None with 'is' or 'is not', never == or !=. None is a singleton object.
Frequently asked questions
How does Docker handle None?
This task is covered in 2 stacks on this page: Docker, Python. The "Dangling Images & Orphan Volumes" snippet in Docker uses `# Check dangling images:`.
Which command does the Docker example use?
The "Dangling Images & Orphan Volumes" snippet uses `# Check dangling images:`, from the Common Mistakes section of the Docker cheat sheet.
Which stacks cover "None" on this page?
Docker, Python. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Dangling Images & Orphan Volumes": Every time you rebuild with the same tag, the old image loses its tag and becomes <none>:<none>. These pile up fast. Volumes from removed containers also linger. Schedule regular prune commands or add them to your CI cleanup steps.