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 know if an object is iterable?
An object in python is said to be an iterable if it obeys one of the following two rules:- 1. Object must consist of __getitem__ method 2. Object must consist of __iter__ method. String objects generally...

VbScript Dictionary Objects
Dictionary objects are key value pairs object.One of the use of dictionary can be to find unique elements in a given set of data. Below is the example of the methods that can be used in dictionary: Set...

What You Need to Know About Test Automation In Agile
Software development has transformed over time. Developers have gone from executing a project in the “waterfall” method to the “agile” method. Due to digitization of businesses,...

Student Project Development: How To Go About It?
A lot of students (count me as well) in their final year of IT course are confused and overwhelmed about their Project development. Final Year IT Projects are a crucial milestone in every IT students educational...

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