import warnings
warnings.warn("Warning...........Message")

See the python documentation: here

Answer from necromancer on Stack Overflow
🌐
Python
docs.python.org › 3 › library › warnings.html
Warning control — Python 3.14.4 documentation
January 29, 2026 - Warning messages are typically ... uses an obsolete module. Python programmers issue warnings by calling the warn() function defined in this module....
🌐
GeeksforGeeks
geeksforgeeks.org › python › warnings-in-python
Warnings in Python - GeeksforGeeks
January 23, 2020 - Warnings are provided to warn the developer of situations that aren't necessarily exceptions. Usually, a warning occurs when there is some obsolete of certain programming elements, such as keyword, function or class, etc.
🌐
Python Module of the Week
pymotw.com › 2 › warnings
warnings – Non-fatal alerts - Python Module of the Week
... The warnings module was introduced in PEP 230 as a way to warn programmers about changes in language or library features in anticipation of backwards incompatible changes coming with Python 3.0. Since warnings are not fatal, a program may encounter the same warn-able situation many times ...
🌐
Cam
downloads.ccdc.cam.ac.uk › documentation › API › descriptive_docs › warnings.html
Warnings — CSD Python API 3.6.1 documentation
The warnings module in Python provides a way to control how warnings handled within a Python script. It allows developers to emit warning messages to alert users of potential issues or unexpected behavior in their code.
🌐
pytest
docs.pytest.org › en › stable › how-to › capture-warnings.html
How to capture warnings - pytest documentation
If warnings are configured at the interpreter level, using the PYTHONWARNINGS environment variable or the -W command-line option, pytest will not configure any filters by default.
🌐
Astropy
docs.astropy.org › en › latest › warnings.html
Python warnings system — Astropy v8.0.0.dev591+g306868627
Astropy uses the Python warnings module to issue warning messages. The details of using the warnings module are general to Python, and apply to any Python software that uses this system. The user can suppress the warnings using the python command line argument -W"ignore" when starting an ...
🌐
Medium
allwin-raju.medium.com › mastering-warnings-in-python-what-they-are-and-how-to-use-them-bf6fc670e3fb
Mastering Warnings in Python: What They Are and How to Use Them | by Allwin Raju | Medium
November 17, 2024 - Warnings are Python’s way of saying, “This might not be a problem now, but it could be later.” They are a softer alternative to exceptions, allowing your program to run while highlighting areas that may need your attention.
Find elsewhere
🌐
Tutorialspoint
tutorialspoint.com › python › python_warnings.htm
Python - Warnings
In Python, a warning is a message that indicates that something unexpected happened while running your code. Unlike an error, a warning will not stop the program from running. Warnings are used to alert the user about potential issues or deprecated
🌐
W3Schools
w3schools.com › python › ref_module_warnings.asp
Python warnings Module
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... import warnings warnings.warn('This is a warning message') print('Program continues...') Try it Yourself »
🌐
DEV Community
dev.to › hyperkai › warning-in-python-415g
Warning in Python - DEV Community
May 14, 2025 - A warning is the alert message which doesn't basically raise an exception and doesn't terminate program.
🌐
Coderz Column
coderzcolumn.com › tutorials › python › warnings-simple-guide-to-handle-warning-messages-in-python
warnings - Simple Guide to Handle Warning Messages in Python by Sunny Solanki
Warnings messages are generally raised when the situation is not that worse that the program should be terminated. It's generally raised to alert programmers. For example, a programmer might call some function whose signature is changing in ...
🌐
Reuven Lerner
lerner.co.il › home › blog › python › working with warnings in python (or: when is an exception not an exception?)
Working with warnings in Python (Or: When is an exception not an exception?) — Reuven Lerner
May 12, 2020 - After all, you could always use “print” to display a warning. Or if something is really wrong, then you could raise an exception. But that’s just the point: There are times when you want to get the user’s attention, but without stopping the program or forcing a try-except clause. And while “print” is often useful, it normally writes to standard output (aka “sys.stdout” in Python), which means that your warnings could get mixed up with the warnings themselves.
🌐
Note.nkmk.me
note.nkmk.me › home › python
How to Ignore Warnings in Python | note.nkmk.me
August 10, 2023 - In Python, you can use the warnings module from the standard library to control warnings, such as ignoring (suppressing) warnings or turning matching warnings into exceptions. warnings — Warning cont ...
🌐
Medium
medium.com › python-for-everything › writing-production-python-you-need-to-understand-warnings-in-python-53b541e7486f
Warnings in Python: A Complete Practical Guide
5 days ago - In Python, warnings are messages that Python generates when something unexpected happens during the execution of your program, without stopping it.
🌐
PyPI
pypi.org › project › pytest-warnings
pytest-warnings · PyPI
any warnings in your code are reported in the pytest report. You can use the -W option or --pythonwarnings exactly like for the python executable.
      » pip install pytest-warnings
    
Published   Sep 29, 2020
Version   0.3.1
🌐
GitHub
github.com › python › cpython › blob › main › Lib › warnings.py
cpython/Lib/warnings.py at main · python/cpython
from _py_warnings import ( WarningMessage, _DEPRECATED_MSG, _OptionError, _add_filter, _deprecated, _filters_mutated, _filters_mutated_lock_held, _filters_version, _formatwarning_orig, _formatwarnmsg, _formatwarnmsg_impl, _get_context, _get_filters, _getaction, _getcategory, _is_filename_to_skip, _is_internal_filename, _is_internal_frame, _lock, _new_context, _next_external_frame, _processoptions, _set_context, _set_module, _setoption, _setup_defaults, _showwarning_orig, _showwarnmsg
Author   python
🌐
pytest
docs.pytest.org › en › 7.1.x › how-to › capture-warnings.html
How to capture warnings — pytest documentation
If warnings are configured at the interpreter level, using the PYTHONWARNINGS environment variable or the -W command-line option, pytest will not configure any filters by default.