Golang path and filepath Examples.
Using filepath.Base
The number is the index of the last slash in the string. If you want to get the file's base name, use filepath.Base:
package main
import (
"fmt"
"path/filepath"
)
func main() {
path ...
In Python, using the __file__ is the easiest way to get name of current script.
Using Module Attributes
You can use __file__ to get the name of the current file. When used in the main module, this is the name of the script that was originally invoke...
In Python, there are 2 ways to get the filename without the extension from a path.
Using pathlib Module
You can use .stem from pathlib to get the filename without the extension from a path, it really simple. For example,
#!/usr/bin/python3
# Im...