Skip to main content

Posts

Showing posts from July 13, 2020

The missing guide to useful Python 3 features

Numerous people started to shift their Python version from 2 to 3 due to Python EOL. One of the most well-known changes is;  print  function in Python 2 is replaced by the  print()  function in Python 3. However, parentheses work in Python 2 if a space is added after  print  keyword because the interpreter evaluates it as an expression. Below, I introduce a few illustrations of amazing features you can find only in Python 3 in the hopes that it will solve your Python problems easily. All examples are coded in python 3.8.0 f-strings (3.6 +) It is hard to perform anything in whatever programming language without strings and you expect a structured way to work with strings to stay productive. Most people who use Python prefer to use the  format  method. user = “Prince” action = “coding” log_message = ‘User {} has logged in and did an action {}.’.format( user, action ) print (log_message) # User Prince has logged in and did an action coding. In addition to the format, Python 3 provides