Structural Pattern Matching in Python 3.10

Structural pattern matching resembles the traditional switch statement, but it goes far beyond what the 'simple switch' can do. Some call the `match` statement a domain-specific language to match objects by their structure. `match` statement is a mini-language within Python. Structural pattern matching is clearer to read than long complicated switches or if ...else statements. However, switches and if ...else statements would still be better when there are not too complicated. In a Deep Dive course Part III by Fred Baptiste I learned about structural pattern matching. However, I wanted to get a deeper understanding of the subject. Therefore, I took additional four tutorials on this subject. o The first tutorial “Introduction to Structural Pattern Matching” is at Python Discord. The length of the tutorial is 00:55 total video hours. In this tutorial, I learned: • Matching against the type of the object • Matching against the type of the object and value by using the `guard` statement • Order of the cases matters • Sequence pattern matching using split(), *args keyword and or | • Dictionary pattern matching • Matching custom class instances • Be mindful of bound variables to the previous case You can find this tutorial at https://www.youtube.com/watch?v=n7rNgz4uyZk&ab_channel=PythonDiscord o The second tutorial “Introduction to Structural Pattern Matching” by ArjanCodes where the instructor showed how to use matching to parse arguments and interpret a variety of commands. The length of the tutorial is 00:17 total video hours. In this tutorial, I learned: • How to use a parameter `--force` and *args • Pattern matching on the attribute of the object You can find this tutorial at https://www.youtube.com/watch?v=scNNi4860kk&ab_channel=ArjanCodes o The third tutorial “Python 3.10 Structural Pattern Matching - 3 Examples To Get You Started | Better Data Science” by Better Data Science where I learned pattern matching in the method of a Class. The length of the tutorial is 00:13 total video hours. You can find this tutorial at https://www.youtube.com/watch?v=vAXWX2tCps8&ab_channel=BetterDataScience o The fourth tutorial “Python 3.10 Pattern Matching in Action” by Big Python where I learned how to use matching in JSON API. The length of the tutorial is 00:12 total video hours. You can find this tutorial at https://www.youtube.com/watch?v=SYTVSeTgL3s&ab_channel=BigPython

Introduction to JSON Schema

In a Deep Dive course Part III by Fred Baptiste I was introduced to the JSON Schema module in Python. The instructor also recommended getting a deeper understanding of this subject. Therefore, I completed the following tutorials: o I read the book "Understanding JSON Schema" at https://json-schema.org/understanding-json-schema. o I read the guide to JSON Schema on https://cswr.github.io/JsonSchema. o I read Schema Validation on https://python-jsonschema.readthedocs.io/en/stable/validate/ o Additional topics that I understood and exercised: • When and how to use $schema, $ref, $defs • How to use absolute and relative Pointers • Use a recursive approach in schemas • When to use validate.iter_errors and is its attributes • How to use jsonschema.ErrorTree() • How to validate multiple type at the same time • How to use debugging tools like context and best_match • How to activate format key by importing FormatChecker • Custom format and validator in Python • How to use META_SCHEMA • How to create conditional subschemas • How to use High Order Validators (allOf, anyOf, oneOf) o I also completed the following two tutorials: • “Julian Berman - Introduction to JSON Schema” by Julian Berman on PyCon Sweden. The length of the tutorial is 40:53 total video hours. You can find this tutorial at https://www.youtube.com/watch?v=PC-nVq9i-mA&ab_channel=PyConSweden • “So you think you understand JSON Schema? - Ben Hutton, Postman/JSON Schema” by Ben Hutton on openAPI Initiative. The length of the tutorial is 26:26 total video hours. You can find this tutorial at https://www.youtube.com/watch?v=vMG0NCDifI0&ab_channel=OpenAPIInitiative o Useful links: • Generating JSON Schema from JSON - https://jsonschema.net/ • Hyperjump - JSON Schema Validator at https://json-schema.hyperjump.io/ • JSON Schema Validator and Generator on https://extendsclass.com/json-schema-validator.html • JSON Schema store on https://www.schemastore.org/json/

Working With Files in Python

I completed the basic-level tutorial “Working With Files in Python” by Vuyisile Ndlovu at Real Python. In this tutorial I learned about: • Create single and multiple files using context manager or Bash commands • Creating single or multiple directories by using various options like os.mkdir(), pathlib.Path.mkdir() or os.makedirs() or use use Bash commands • Getting directories list through os.listdir(), os.scandir(), or pathlib.Path() • List all files or all subdirectories through os.listdir(), os.scandir(), or pathlib.Path() • Filename patter matching using fmatch module or glob • Traversing directories and procesing files • Getting file attributes through os.stat(), os.scandir(), or pathlib.Path() • Create temporary files or directories • Move, copying and delete files of directories • Create, read, retrieve ZIP, TAR files. Or use SHUTIL You can find this tutorial at https://realpython.com/working-with-files-in-python/

The Python pickle Module

In a Deep Dive course Part III by Fred Baptiste I learned about the pickle module in Python. However, I wanted to get a deeper understanding of the subject. Therefore, I took additional tutorials on this subject. o The first tutorial “The Python pickle Module: How to Persist Objects in Python” by Davide Mastromatteo at Real Python. In this tutorial, I learned: • Serialization in Python • Inside the Python pickle Module • How to use pickled object to restore the changed object • Protocol Formats of the Python pickle Module • Also how to use `__getstate__()`, and `__setstate__()` with pickle module for unserialized objects • How to serialize interpreter sessions • What can be pickled and unpickled? • Compression of Pickled Objects • Security Concerns With the Python pickle Module. You can find this tutorial at https://realpython.com/python-pickle-module/ o The second intermediary-level tutorial “Python Pickle: Serialize Your Objects” by Claudio Sabato at Codefather.tech. In this tutorial, I learned: • Save a Python Dictionary Using Pickle • Write Pickled Python Dictionary to a File • Pickle a Nested Dictionary Object • Using Pickle With a Custom Class • Save Multiple Objects with Pickle • Pickle and Python With Statement • Using Python Pickle with Lambdas • Error When Pickling a Class with a Lambda Attribute • Exclude Python Class Attribute from Pickling • Restore the Original Structure of a Python Object Using Pickle • Default Protocol for Python Pickle • Compression for Data Generated with Python Pickle • Python Pickle and Pandas DataFrames • Pickling is not secure! By implementation of the `__setstate__` method you can call any arbitrary command that can harm the system that unpickles the data. Pickling can be used for reverse shells for remote administration or malicious activities. You could use the os.system call to create a reverse shell and gain access to the target system • Protecting Pickled Data with HMAC module You can find this tutorial at https://codefather.tech/blog/python-pickle/

Python API Tutorials

If I want data from websites like Twitter, Facebook, or Youtube or something like that then it is better to use their public APIs instead of scraping the data manually. For this reason, I completed two tutorials offered by DataQuest to learn how to use public APIs to get data: o The first tutorial “Python API Tutorial: Getting Started with APIs” by Celeste Grupman at Dataquest. In this tutorial, I learned: • What an API is • Types of requests and response codes • How to make a get request • How to make a request with parameters • How to display and extract JSON data from an API Project: To query a simple API to retrieve data about the International Space Station (ISS). You can find this tutorial at https://www.dataquest.io/blog/python-api-tutorial/ o The second intermediary-level tutorial “Tutorial: Getting Music Data with the Last.fm API using Python” by Celeste Grupman at Dataquest. Project: Built a dataset of popular artists using the www.Last.fm API: • Authenticate with an API using an API key • Use pagination to collect larger responses from an API endpoint • Use rate-limiting to stay within the guidelines of an API • Augmenting the data using a second www.Last.fm API Endpoint • Process the data using panda You can find this tutorial at https://www.dataquest.io/blog/last-fm-api-python/

1 ... 7 8 9 ... 13

Our Sidebar

You can put any information here you'd like.

  • Latest Posts
  • Announcements
  • Calendars
  • etc