Python - Check If String is None, Empty or Whitespace in One Line!!!

preview_player
Показать описание
#Python #Shorts

One thing I miss quite a bit from C# is the "IsNullOrWhiteSpace" extension method on the "string" type. I don't think you can create an extension method for built-in types in Python (please correct me if I am wrong) but the good news is that we can define a function that we can reuse and we can perform such check just in one line. The bad news is that it requires separate checks for when the string is None or empty, and when the string only contains whitespace.

-------------------------------------------------------------------------------------
Links:
Рекомендации по теме