Ben Chuanlong Du's Blog

It is never too late to learn.

Rust Error "error: expected item, found 'let'"

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

The error message "error: expected item, found 'let'" is commonly encountered in Rust when you mistakenly place a let statement in an invalid location. A let statement can only be used …

Tips on Python Module

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Import a Module

  1. There are 3 different ways to import Python modules.

    import module_name
    import module_name as alias
    from module import pkg_mod_or_fun
    
  2. The module importlib.resources (since Python 3.7+) leverages …

Bash Equivalent of the ifmain Pattern in Python

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/usr/bin/env bash

function install_icon.usage() {
    cat << EOF
NAME
    /scripts/sys/install_icon.sh - Download and install icon to /usr/local/bin/.
SYNTAX 
    /scripts/sys/install_icon.sh [-h]
EOF
}

function install_icon …

My List of Python Modules

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Awesome Python

Awesome Python Applications

Data Science

  1. pandas: data frame.

  2. scipy: scientific computing.

  3. numpy: multi-dimensional arrays, fundation of pandas and deep learning packages.

  4. re: regular expression

File System

  1. shutil: copy, move …

ImportError: Attempted Relative Import With No Known Parent Package

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Symptom

ImportError: Attempted Relative Import With No Known Parent Package

Solution

The best solution is to run the Python script as a Python module. However, you have to add the directory …

Modules in Rust

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!