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

File Handling in Python - Basic Concept
File (Flat) Handling in Python Types of files in python: 1: Text file: Stores data in the form of characters. Customarily used to store text/string data. 2: Binary file: Stores data in the form of bytes....

FUNDAMENTALS OF COMPUTER ALGORITHMS
INTRODUCTION: The word algorithm is named after the ninth century scholar 'Abu Jafar Muhammad Ibn Musa Al-Khwarizmi'. An algorithm is a step-by-step procedure by which a computer can produce the required...
M

Mukesh Tekwani

2 0
0

STORAGE CLASSES
A storage class defines the scope (visibility) and life-time of variables and/or functions within a C Program. They precede the type that they modify. We have four different storage classes in a C program: auto register static extern ...

Python Demo
https://www.youtube.com/watch?v=8AEhpZ4lbOI

Python Important Operation Formats and Sytnax.
Hello Python Enthusiast, Though Python is considered as one of the easisest language to learn in the market, many freshers and beginners will find great difficulty in understansing the syntax and also...
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