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

Python- Basic Concepts part 1
1. What is Python? Python is a high-level programming language, with applications in numerous areas, including web programming, scripting, scientific computing, and artificial intelligence. It is...

Advantages of C++ Language
Advantages of C++ - C++ is a profoundly convenient dialect and is frequently the dialect of decision for multi-gadget, multi-stage application advancement. - C++ is a protest situated programming dialect...

TestNG Annotations and its sequence
public class TestNGAnnotations { @BeforeMethod public void beforeM() { System.out.println("Before Method"); } @AfterMethod public void afterMethod() { System.out.println("After Method"); } @BeforeClass...
S

Sarthak C.

0 0
0

Python (Concepts and Importance)
Python is a general-purpose, interpreted, object-oriented programming language. Python was created by "G. V. Rossum" in the Netherlands in 1990. Python has become a famous programming language widely used...

Selenium Webdriver training institute in pune
eKnowledge Infotech is a leading software training company from Pune managed by working IT professionals. The aim is to help people acquire advance skills and get job into niche skills. Find below complete...
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