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

Published: 18 May 2021
on channel: codevev
607
17

#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:
Blog: https://evgenyurubkov.com
Twitter:   / evgenyurubkov  
Instagram:   / evgenyurubkov  
Youtube:    / @codevev  


Watch video Python - Check If String is None, Empty or Whitespace in One Line!!! online without registration, duration hours minute second in high quality. This video was added by user codevev 18 May 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 607 once and liked it 17 people.