+ 6

The "phythonic way": Is there a proper way of coding in python?

I've been checking some of the python codes in sololearn and I realized that some of them are coded in a much simpler pattern compared to mine. I haven't finished the python course so I did some research and found out about the term "pythonic way." Does anyone have any basic tips for beginners on making their code become more "pythonic"? Is it also necessary to be "pythonic" if you can at least solve the problem in your own way? Man, typing "pythonic" makes me thirsty for some reason.

5th Nov 2018, 2:36 PM
Lambda_Driver
Lambda_Driver - avatar
6 ответов
5th Nov 2018, 3:59 PM
David Ashton
David Ashton - avatar
+ 3
Python have a lot of way to do anything. So when people see some python code that seems to attached to Conventional programming thinking (Standard Imperative Programming or objects oriented Programming ) they say is not pythonic. Remember even we have a lot o ways to get result in python the ways of do it work different and have different performance. Take the best answer of the post below as example: https://stackoverflow.com/questions/39045396/where-does-the-performance-boost-of-map-or-list-comprehension-implementations-ov
5th Nov 2018, 3:00 PM
Anya
Anya - avatar
+ 2
Yes! There is an official standard for Python code to make it Pythonic! Look up "PEP 8" on Google.
5th Nov 2018, 9:06 PM
Lachlan
+ 1
Anya Is it common practice to make your code "pythonic"? Is it encouraged in the IT industry for example?
5th Nov 2018, 3:54 PM
Lambda_Driver
Lambda_Driver - avatar
+ 1
Yes. just see David Ashton post. Will complement very well.
5th Nov 2018, 4:02 PM
Anya
Anya - avatar
+ 1
Interesting, so it's like a coding style that python encourages from its coders
5th Nov 2018, 4:13 PM
Lambda_Driver
Lambda_Driver - avatar