Search notes:

assert

Python: assert statement
assert condition
assert condition, expr
assert …. does nothing if __debug__ is False.
If __debug__ is True, assert condition checks if condition is True and raises an AssertionError exception otherwise.
If the optional expression expr is also present, it passes expr to the constructor of AssertionError.
lst = []

try:
   assert len(lst)

   print('-'.join(lst))

except AssertionError:
   print('assertion failed')
Github repository about-Python, path: /statements/assert/demo.py

See also

statements

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199200, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Python/statements/assert(62): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78