Python Classroom notes 06/May/2025

Static Code Analysis

  • Ensure the following extensions are installed
    • pylint | flake8 | mypy
    • autopep8 | black formatter
  • Refer Here for changes done to improve code quality

Property (oops)

class Person:
    def __init__(self, name):
        self._name = name

    @property
    def name(self):
        return self._name

    @name.setter
    def name(self, value):
        if not isinstance(value, str):
            raise TypeError('Name must be a string')
        self._name = value

p = Person("test")
p.name = "hello"

Persistence

  • To add persistence to our applications we have two approaches
    • unstructured:
      • data cannot be queried can only be searched
      • examples:
        • text
        • pdf
        • files
      • decision: file format
    • structured:
      • data can be queried
      • Examples:
        • databases
      • decision: database type

Findout What is the file format & when to use

  • CSV File Format
number, name, course
1, abc, python
2, abd, DevOps
3, abe, GenAI
  • JSON:
{
    "course": "Python",
    "students": [
        "abc", "bca"
    ],
    "address": {
       "flatno": 601,
       "building": "nigiri"
    }
}
  • YAML
---
course: Python
students:
  - abc
  - bca
address:
  flatno: 601
  building: nilgiri

Reading and Writing files in Python

  • Refer Here for python file handling
  • Lets write a dictionary into json
  • Refer Here for the examples done in the class
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%