Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Debug Python Project in Visual Studio Code

Ways to Open a Command Palette

  1. Use Menu Menu -> View -> Command Palette....
  2. Use the shortcut Shift + Command + P (on macOS).

Command Palette

You can search for commands in the Command Palette, which makes things very convenient.

Run Tests or a Python File

  1. Open the Command Palette.
  2. Search for Python: Run in the …

Ways to Download Files Using Selenium Webdrive

Selenium WebDrive cannot have no control of system Dialog, so you have to avoid the Dialog when downloading files using WebDrive.

The first way is to enable automatical download in the browser that you use with Seleniu WebDrive. So when click a file link, the file is automatically downloaded to …

Collections and Iterators in C++

Collections

  1. Prefer std::deque to std::vector when the size of the collection is unknow.

  2. Suppose set A and B are two set with the same type and set C is another set with the same value type but a different comparison function, then it is still valid to insert …

Python Logging

General Tips

  1. logging is a Python module for logging coming with the standard library while loguru is a popular 3rd-party logging library. Unless you do not want your Python package/script to depend on 3rd-party libraries, loguru is preferred to logging for multiple reasons.

    • loguru is easy and fun to …

Hands on the Python Module argparse

  1. argparse is the best library to use to parse command-line arguments in Python. It is included in Python standard libaries (which menas that you can use it out of the box).

  2. It is suggestedd that you always log a parsed Namespace object so that you can check whether it is as expected.

Special Characters to Avoid in Strings

This articles talks about special characters to avoid in various places. You might not encounter issues most of the time when violating rules stated below, however, you never know when things will break. It is more for a good-practice suggestion.

String for Shell

  1. When you pass parameters from one program …