Python __sizeof__() Method

Syntax object.__sizeof__(self, other) The Python __sizeof__() method returns the size of the object in bytes. The sys.getsizeof() method internally call’s __sizeof__() and adds some additional byte overhead, e.g., for garbage collection. Basic Example The following code snippet creates a list object x with three integers and measures its size in bytes (104) using the x.__sizeof__() … Read more

PowerShell Operators

Windows PowerShell uses variables to store values, and we have a large set of operators we can use to modify or compare those variables. PowerShell Assignment Operators Assignment Operators allow us to simply create variables and populate them with values in one command: When we call those variables, we can see the values they contain: … Read more

PowerShell Loops – A Simple Guide with Video

PowerShell foreach Loop Syntax: The keyword ‘foreach‘ is used in Windows PowerShell to iterate through a series or list of items, usually with the intent of performing operations using each item.  Example: In the following example, we use PowerShell to read the contents of a text file (C:\Temp\ServerList.txt) filled with server names, storing the values … Read more

Python Pandas Input/Output – Pickling

If you are leaning towards a career as a Data Scientist or just a coder looking to expand your skillset, the art of pickling is a must-have. This article focuses on creating, saving, and reading various object types to/from a pickle file. Syntax pandas.read_pickle(filepath_or_buffer, compression=’infer’, storage_options=None) The return value is an unpickled object of the … Read more

Correct Way to Write line To File in Python

Overview In Python, there are different strategies to create, open, close, read, write, update and delete the files. It permits the users to deal with the files, i.e., read and write, alongside numerous other file handling operations. In this article, we are going to look at the various methods to write text in a line … Read more

Find The Full Path of The Python Interpreter

[toc] Introduction Problem Statement: How to find the full path of the currently running Python interpreter? There are different ways to find the full path of Python interpreters. But first, let’s get the basics out of our way before we unearth the solution to our problem statement. So, what’s a Python Interpreter? This might be … Read more

Python Read Binary File

During your career as a Pythonista, you will most likely find yourself required to work with binary data. See the examples outlined below to efficiently read/write to a Binary file. Preparation Before any data manipulation can occur, one (1) new library will require installation. The NumPy library supports multi-dimensional arrays and matrices in addition to … Read more

What’s the Difference Between exit(0) and exit(1) in Python?

The function calls exit(0) and exit(1) are used to reveal the status of the termination of a Python program. The call exit(0) indicates successful execution of a program whereas exit(1) indicates some issue/error occurred while executing a program. What is the Exit Code? Let’s have a look at some examples to get a clear picture … Read more