We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This post is targeted towards aspiring "python programmers".
Code in python usually looks elegant and clear. "High-readability" is one of the reasons behind its growing popularity. Though, at times, you'll find python-version of code looking worse. This mostly happens if the code is written by inexperienced python programmer (usually coming from other languages). For such times, I encourage you to find the "pythonic way" of coding it instead of using "plain translation from other languages". It will surely benefit you in the long run.
Just to give an example, a pythonista would always use while queue: instead of while queue != None :, former being far clear and concise. I hope this post gives some tips regarding "python-way" of coding and encourages you to find better ways to code.
Day 23: BST Level-Order Traversal
You are viewing a single comment's thread. Return to all comments →
For Python coders, here's how you can code it "pythonic" way:
This post is targeted towards aspiring "python programmers".
Code in python usually looks elegant and clear. "High-readability" is one of the reasons behind its growing popularity. Though, at times, you'll find python-version of code looking worse. This mostly happens if the code is written by inexperienced python programmer (usually coming from other languages). For such times, I encourage you to find the "pythonic way" of coding it instead of using "plain translation from other languages". It will surely benefit you in the long run.
Just to give an example, a pythonista would always use
while queue:
instead ofwhile queue != None :
, former being far clear and concise. I hope this post gives some tips regarding "python-way" of coding and encourages you to find better ways to code.Informative Tweets for Inquisitive Minds