How to Get and Format the Current Time in Python

Time Review Time as we know is represented by several components, some of which are numerical such as seconds, minutes and hours while others are strings such as timezone, AM and PM. Python provides an arsenal of utilities when dealing with time objects and strings. Therefore, it is relatively easy to get and format the […]

Read More

What is the difference between __str__ and __repr__ in Python

Purpose of __str__ and __repr__ in Python Before we dive into the discussion, let’s check out the official documentation of Python about these two functions: object.__repr__(self): called by the repr() built-in function and by string conversions (reverse quotes) to compute the “official” string representation of an object. object.__str__(self): called by the str() build-in function and […]

Read More

Add, Remove, and Search Packages in Python with pip

Using pip to Manage Python Packages Like many useful programming ecosystems, Python provides a powerful and easy-to-use package management system called pip. It is written to replace an older tool called easy_install. From a high-level point of view, pip has the following advantages over easy_install: All packages are downloaded before installation to prevent partial (thus […]

Read More

Measure Time in Python – time.time() vs time.clock()

A prerequisite before we dive into the difference of measuring time in Python is to understand various types of time in the computing world. The first type of time is called CPU or execution time, which measures how much time a CPU spent on executing a program. The second type of time is called wall-clock […]

Read More