The Art Of Writing Python Code
Last updated
Last updated
You've Probably Read Many Articles Praising The Python Software Language. "It's A Great Language, Very Easy And Fast To Write and Read..." We Often Hear Opinions Such As. One Of The Beautiful Features That The Python Language Has Developed is The Art Of Writing Beautiful Code That Confirms These Opinions.
"If There is No Error When I Run The Code, There is No Problem..." This is Usually The First Structure We Use When We Start Developing Software and We Continue To Develop Our Software For A Long Time Without Changing This Structure. When We Try To Read The Code We Wrote 3 Months Later, If We See Variables Such As x, y, z and We Started To Waste Time Understanding What These Variables Are, It is Time For Something To Change. This is Where Defining Proper Variable Names Can Save Us A Bit. When We Ask What About The Other Rules, I Can Hear You Say, "Which Rules?" It Can Be Very Difficult For Us To Familiarize Ourselves With The Spelling Rules Of Software Languages That Are Not In Our Culture and That We Learned Later, and To Keep Up With That Culture. This is Exactly Where Python, One Of The Easiest Languages To Read And Write, Comes In. PEP 8 And PEP 20 Offer Great To Understand The Python Language.
Ref:
Creation Date: 05/July/2001
In Many Software Languages, Even If The Code Does Not Look Pleasant To Our Eyes, The Code May Not Give An Error When We Run It, Even If We Do Not Understand It When We Look At It. But The Python Language Emphasizes The Importance Of Writing Readable Code With PEP8 Standards.
Python Standardizes Everything From How Spaces Should Be To The Number Of Characters In A Line With PEP8. If You Need To Use Indentation In Your Code, You Cannot Give 4 Spaces For One Indentation and 2 Spaces For The Other. They All Need To Be Standardized. These Standards Make It Easier For You and Others To Read The Code. It Also Allows You To Write Code Faster.
Creation Date: 19/August/2004
You Can Open And Read PEP20 From Within The Python Shell. So The Python Philosophy is Really Embedded In The Language and The Art Of Python Coding Will Draw You In As You Start To Code, Whether You Like It Or Not.
In The "Pep 20 By Examples" Document, Zen is Tried To Be Explained With Codes. I Will Use A Few Examples From This Document. To Review The Full Document:
When Writing Our Code, We Should Try To Write Code Like Poetry. After All, The Beautiful Appearance Of The Code We Write Will Give Us An Advantage When We Return To The Code Structure In The Future. Descriptive Code Offers An Easier Structure To Organize Code That Looks Good To The Eye And Increases Writing Motivation.
Python Recommends Not To Use Libraries That We Don't Need For Performance. When We Give The import * Command, All Libraries / Modules In Models Come. Instead, Only Calling The Structure We Need And Assigning A Good Name To The Structures We Call Will Provide Ease Of Use.
You Can Read And Review The PEP8 Standards More Easily At
Ref: