In Python, there are 4 ways to know if an object has an attribute.
Using hasattr Method
The arguments are an object and a string. The result is True if the string is the name of one of the object’s attributes, False if not. For example,
#!/usr/...
In Golang, there are 2 ways to read a file line-by-line.
Using bufio.Scanner Function
Scanner provides a convenient interface for reading data such as a file of newline-delimited lines of text. The ones that are currently implemented are:
packa...
In Rust, there are two ways to install rust in Linux.Running the following in your terminal
If you’re running macOS, Linux, or another Unix-like OS. To download Rustup and install Rust, run the following in your terminal, then follow the on-screen i...
In Golang, there are three ways to find the type of an object.Using fmt.Sprintf Function
You can use fmt.Sprintf function to get a string representation. For example,
package main
import "fmt"
func main() {
i := 10
f := 2.0
var m map[s...
Python String Formatting Best Practices.Fancier Output Formatting
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark. Inside this string, you can write a Python expression between {...
Does Python have a string 'contains' substring method?.Using the in Operator
The easiest way to check if a Python string contains a substring is to use the in operator.
str = "Python"
if "th" in str:
print("Found!")
# case-insensitive
if "TH" no...
Converting Json to string in Golang.Decoding JSON Into Structs
Go offers built-in support for JSON encoding and decoding, including to and from built-in and custom data types.
Unmarshal parses the JSON-encoded data and stores the result in the value ...
command line tool and library for transferring data with URLs.
cURL (pronounced 'curl') is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name ...
chmod is the command and system call used to change the access permissions of file system objects (files and directories) sometimes known as modes.
The chmod command sets the file permissions flags on a file or folder. The flags define who can read,...
The cd (“change directory”) command is used to change the current working directory in Linux and other Unix-like operating systems.
The cd command, also known as chdir (change directory), is a command-line shell command used to change the current wo...
compile packages and dependencies.
Build compiles the packages named by the import paths, along with their dependencies, but it does not install the results.
Build
go build
go build hello.go
ls -lh
1.9M Jun 29 17:38 hello
...