About us nbDEV is a website that shares tutorial and guide about programming in many languages, platforms… for especially newbiew developer. We know, as a beginner, you have a lot of question as well as have difficult to find the answer for those questions. At nbDEV, we collect a lot of useful materials, all of them are free as open source under MIT or Apache license. We also write tutorials, step-by-step series so that, as a beginner, you can follow and do it yourself. [Read more]

Getting started with PyTorch

Before You Begin Make sure you have Python installed in your system, otherwise, take a look at Setting up Python development environment notification Note This guide is a practical guide that I followed from PyTorch tutorial Introduction PyTorch is a Python-based scientific computing package targeted at two sets of audiences: A replacement for NumPy to use the power of GPUs a deep learning research platform that provides maximum flexibility and speed Installation To install PyTorch, please take a look at Install PyTorch [Read more]

6 ways to call external command in python

In this tutorial, I will list number of the ways (6 at the moment) to call external programs and the advantages and disadvantages of each: os.system(command) Execute the command (a string) in a subshell. This is implemented by calling the Standard C function system(), and has the same limitations. Changes to sys.stdin, etc. are not reflected in the environment of the executed command. Advantage: This is nice because you can actually run multiple commands at once in this manner and set up pipes and input/output redirection. [Read more]

Sort Python dictionary by value

With Python list, you can sort it by calling sorted built-in function. With dictionary, the thing is kind of similar notification Note It is noticable that we can not sort a dictionary, only to get a representation of a dictionary that is sorted, in this case, it is a sorted list of tuple original_dict = {'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5} Using sorted function and operator module import operator sorted_x = sorted(original_dict. [Read more]

How to sort list of dictionary by value python

Introduction Consider we have a Python list that contains 3 dictionaries: [{'name':'John', 'age':20}, {'name':'Bob', 'age':15}, {'name':'Charles', 'age':30}] When sorted by name, should become: [{'name':'Bob', 'age':15}, {'name':'Charles', 'age':30}, {'name':'John', 'age':20}] Using sorted funciton with lambda original_list = [{ 'name': 'John', 'age': 20 }, { 'name': 'Bob', 'age': 15 }, { 'name': 'Charles', 'age': 30 }] newlist = sorted(original_list, key=lambda k: k['name']) print(newlist) Output: [{'name': 'Bob', 'age': 15}, {'name': 'Charles', 'age': 30}, {'name': 'John', 'age': 20}] If sort using age: [Read more]

Receive and Send Gmail Using Python

In this tutorial, I will show a simple way to receive and send email using Python. Receive email using imaplib Python imaplib.IMAP4 class implements the actual IMAP4 protocol. The connection is created and protocol version (IMAP4 or IMAP4rev1) is determined when the instance is initialized. If host is not specified, “ (the localhost) is used. If port is omitted, the standard IMAP4 port (143) is used import email import imaplib import sys from email. [Read more]

Numpy quick start

Before You Begin notification Note Make sure you installed NumPy in your system, if not, please take a look at Install scipy The Basics NumPy’s main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In NumPy dimensions are called axes. For example, the coordinates of a point in 3D space [1, 2, 1] has one axis. [Read more]

Install SciPy

There are some ways to install SciPy. This guide will show you how to install SciPy on Windows, Linux and macOS platform. Scientific Python distributions The easiest way to install SciPy is download the coressponding install bundle one of these below distribution. Mose of them support Windows, Linux and macOS Anaconda: The Most Popular Python Data Science Distribution. There are distributions for Windows, Linux and macOS, chose one that match your system. [Read more]