All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Know If an Object has an Attribute in Python

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/...
ada

How to Read a File Line-by-Line in Go

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...
Sambhav Khandelwal

How To Install Rust in Linux

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...
pooriabt

How to find the type of an object in Go

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...
Patcher56

How to format a string in Python

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 {...
Sambhav Khandelwal

How to check if string contains substring in Python

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...
Patcher56

How to convert string to json in Go

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 ...
aweis

How to use the curl command in Linux

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 ...

How to use the chmod command in Linux

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,...

How to use the cd command in Linux

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...

How to use the go build command line

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 ...