UrbanPro
true

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Black in Python

Logeswaran
31/01/2020 0 0
    When you are upturn in your career from beginner to experienced in programming world, your team will start looking at ‘how you are writing?’ Here the responsibility piling up.
 
    Okay, how to code in better standard? - PEP 8: It is a standard, the python community defined to follow by any programmer across the globe.
Are they huge, hard to remember? - May be, yes. But, by experience we can adopt to this convention.
 
Again, the hardness broken to some extent that enable the developers not to worry about concentrate on formatting.
Here is the way,

black - is a python library that helps to take care of these conventions. Let see how it works!
 
Sample program(sample.py):
 
------------------------------------------------------
print('black - is a python library that helps to take care of the code formatting work. Let see how it works!')
dummyDict={}
for item in (1,2,3,):
           dummyDict[item]=item

print(dummyDict)
------------------------------------------------------ 
 
Just assume that you have written the above program. If you are experienced enough, finding the flaw in the formatting is an easy task.
For ex:
  1. Any line should not exceed 72 characters
  2. have to apply space before and after any operator( = , == + )
  3. For indentation we can go up to 4 spaces
  4. (1,2,3,)-> Here, the trailing comma(,) is not needed, also the space after , is advisable.

Well, how the library 'black' is going to help us to auto-format?

step 1: Installation: pip install black
step 2: black {source_file_or_directory}(black sample.py)

And, the out come of the above program after applying black is below,
 
 
Contact:
Whatsapp: +91-9884085301
Email: dial4python@gmail.com
 
0 Dislike
Follow 1

Please Enter a comment

Submit

Other Lessons for You

How to become a self-taught programmer?
In this lesson, I will teach you the step by step process to becoming a self-taught programmer by learning all the programming concepts by yourself with the help of online resources. Step 1: Choose your...
A

Abraham Paul

1 0
0

C, C++, JAVA Tutor
* Program to swap two numbers using a temporary variable with each statement explained with comments * #include // headerfile for cout statement using namespace std; //...

Writing Simple programs in Python(cont.)
To start writing simple programs in Python, we have to know firstly the SW development process and then we also have to know a bit about the language in which we wish to code,in this case,python, to get...

5 Key Benefits of Internship
As many of my connects are about to complete their graduation and post graduation, its been my good advice to them to find internship. Let me throw some light in this article on that area. An internship...
S

Shekhar Pawar

0 0
0

Address Calculation in Two Dimensional Arrays
Addresses of Two Dimensional arrays can be calculated by using 1. Row Major representation 2. Column major Representation 1. Row Major representaion: Let X be an array of M Rows and N Columns Address...
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more