Thoughts inspiring. Inspiring thoughts
In PHP, there is the check for empty array elements using the empty() function. In Python there is no such one function and the same can be accomplished by a rather elegant try-catch block:
try:
new_var = array_var['element_name']
except KeyError:
new_var = 'default_value' # or None
I will say it is neat.
ThinkingNectar talks about the interest of Chin Yong, a PHP/Python/Web developer residing in Singapore. Life, society, and codes should entails most of what goes between the ears of this coffee drinker.
What makes you think?
Leave a reply