Clean Code & Best Practice

KELAS DATA SCRAPING




Kampus Remote Worker Indonesia | 2024

Data Scraping | rianaditro

Introduction

Learning to write clean code is not just about personal skill development; it's about enhancing collaboration, improving software quality, and preparing for the future of software development. Whether you are working on personal projects or within a team, these skills will serve you well throughout your programming career.

if clean: print("Success!")
Data Scraping | rianaditro

PEP 8 - Style Guide for Python Code

PEP 8 is the Python Enhancement Proposal that provides guidelines and best practices for writing clean, readable, and consistent Python code. It is essentially the official style guide for Python code, helping developers write code that is easy to understand and maintain across different projects and teams.

Data Scraping | rianaditro

Key Aspects of PEP8
1.Indentation: Use 4 spaces per indentation level.
2.Line Length: Limit all lines to a maximum of 79 characters.
3.Blank Lines: Use 2 blank lines before top-level functions and class definitions, and 1 blank line inside functions to separate logic.
4.Imports: Group imports into three categories: standard library imports, third-party imports, and local imports. Import each module in separate lines.

Data Scraping | rianaditro

5.Whitespace: Avoid extra spaces inside parentheses, brackets, or around operators.
6.Naming Conventions:
-Variables, functions: Use snake_case.
-Classes: Use CamelCase.
-Constants: Use ALL_CAPS.
7. Comments and Docstrings: Use comments to explain why certain decisions were made, and use docstrings for functions, methods, and classes to describe their purpose.

Data Scraping | rianaditro

Class Activity

Evaluate Code Quality with Flake8
pip install flake8

flake8 your_script.py

Data Scraping | rianaditro

Learn More

Join us on this self-study journey! Click the link below to get started.

Data Scraping | rianaditro

Discover Advanced Topic

Master this advanced topic and supercharge your skills.

Data Scraping | rianaditro

Homework Assignment

Create an article on how to write a clean code!

Data Scraping | rianaditro




Thank you

Any Question?




Kampus Remote Worker Indonesia | 2024

Data Scraping | rianaditro

<br>

<br>