Amo Chen

Python dotenv introduction and tutorial

Storing important data in environment variables is a common practice when developing, not only to avoid accidentally committing important data into the codebase, but also to use environment variables to store system or program settings. It is also often used in practice to separate development environment from production environment, for example:

if os. getenv('MODE') == 'development':
    # do development-related things
    pass
else:
    # do production-related things
    pass

But as the number of environment variables to be set increases, it may lead to a lot of environment variables to be filled every time you do development. If you have encountered such a situation, why not give python-dotenv a try!

Last updated on  Mar 13, 2023  in  Useful Python Modules  by  Amo Chen  ‐ 2 min read

Pyenv - A great tool for Python version management

Python has been evolving for nearly 10 years, so the development of Python projects also needs to consider the issue of version.

Especially now that Python 2 has retired, most Python projects now use Python 3 as the main version, but some of the old projects in companies still use Python 2 for development, so developers must switch between Python 2 and 3.

If you have trouble switching between Python versions, then pyenv will be your best friend!

Last updated on  Mar 13, 2023  in  Python Programming - Beginner Level , Useful Python Modules  by  Amo Chen  ‐ 3 min read

Learning Google Protocol Buffers with Python - Part 3

This article is part of a tutorial series:

In the last article, we introduced some key syntax and features of proto3 with Google Protocol Buffers. This time, we’ll delve into how to write more complex messages, and introduce some convenient data types along with how to use them.

Posted on  Nov 9, 2018  in  Python Programming - Advanced Level  by  Amo Chen  ‐ 5 min read

Learning Google Protocol Buffers with Python - Part 2

This post is part of a tutorial series:

In the previous post, we introduced the basics of using Google Protocol Buffers (proto3) with Python. In this post, we’ll delve further into some key syntax and features of proto3.

Posted on  Nov 3, 2018  in  Python Programming - Advanced Level  by  Amo Chen  ‐ 4 min read

Learning Google Protocol Buffers with Python - Part 1

This article is part of a series:

The blog post What I Learned from Quip on How to Build a Product on 8 Different Platforms with Only 13 Engineers explains how Quip managed to build products for 8 different platforms with only a 13-member team. It’s definitely something worth learning from.

A key concept from the post is Build once, use multiple times. It encourages minimizing the repetition of creating the same components, thereby increasing the reusability of components. The article also reveals that Quip heavily uses Google Protocol Buffers. By defining data structures using Google Protocol Buffers, automatic code generation can occur for reading and writing the same data structure across various languages or platforms. It can even act as a data exchange format to transfer between different platforms, reducing repetitive development costs and thus improving development efficiency.

With such a handy tool, let’s learn Google Protocol Buffers using Python!

Posted on  Oct 27, 2018  in  Python Programming - Advanced Level  by  Amo Chen  ‐ 5 min read

Python Module - jsonschema Part 3

This post is part of a series on the Python module - jsonschema:

In Part 2 of the Python Module - jsonschema, we covered the complex usage of types like number, string, array, and object. However, most examples focused on validating individual data types, while in practice, JSON data can often involve a mixture of multiple data types. For example, an array might contain object elements, and an object might include nested objects. Consider the following JSON data:

[
    {
        "user_id": 1,
        "preference": {
            "cooking": True,
            "fishing": False,
        }
    },
    {
        "user_id": 1,
        "preference": {
            "cooking": True,
            "fishing": False,
        }
    },
]

This section will introduce how to write JSON Schemas that are more practical for real-world use and easier to maintain.

Posted on  Mar 28, 2018  in  Python Module/Package Recommendations  by  Amo Chen  ‐ 4 min read

Python Module - jsonschema Part 2

This article is a part of a series on the Python module - jsonschema:

In the previous article, Python Module - jsonschema Part 1, we introduced six data types defined by JSON Schema and covered some basic validation techniques.

In this post, we will dive deeper into more complex usages of several types, namely number, string, array, and object.

Posted on  Mar 23, 2018  in  Python Module/Package Recommendations  by  Amo Chen  ‐ 6 min read