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

What is M.S.Project ?
MICROSOFT PROJECT contains project work and project groups, schedules and finances.Microsoft Project permits its users to line realistic goals for project groups and customers by making schedules, distributing...

5 Tips On How To Become A Web Developer
1. Have A Goal: Always first decide what you want to create. 2. Learn To Code : You should be passinate about coding. As you know practice makes a Man Perfect. 3. Google for Solutions : Someone once...

Two lists using Loops - Python Program 1
To generate a list of all possible combinations of two lists using loops, you can use nested loops to iterate through both lists and create a new list that contains all the combinations. list1 = list2...

Example of DependsOnMethod in TestNG
public class dependsonM { @Test public void login() { System.out.println("login"); } @Test (dependsOnMethods = {"login"}) public void email() { //Intentionally I am failing this testcase Assert.assertTrue(false);...
S

Sarthak C.

0 0
0

Python programming - Applications
If you’re thinking of learning Python? Or if you recently started learning it? You may be asking yourself: "What exactly can I use Python for?" There are so many applications for python, but there...
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