Do you want to get over the regular monochrome command line? Interested in building visually appealing clis? …Or want to showcase your cli with cool enhancements? If you have any of these on your mind, then you should definitely try using python’s
Rich works on OSX, linux and windows platforms
≥ Python 3.6.1
pip install rich
Rich is a Python library for writing rich text (with color and style) to the terminal, and for displaying advanced content such as tables, markdown, and syntax highlighted code.
Without further ado, let’s start using the commands of the
I hope we all are familiar how plain Python classes work and their use cases. Python also provides an indirect way to implement immutable classes using namedtuples. Wait, why are we talking about
namedtuples here? Well, there is a reason why I am talking about them here.
For people, who are new to namedtuples please have a look here to understand more about it and it’s applications.
namedtuple is a container provided as part of the
collections module which has the same properties as a
tuple. The only difference is we can access the members of a
Command-line interfaces are quick and efficient tools to accomplish tasks. Not only that, but it’s also cool to have a command-line interface for any web application you develop to avoid having the end-user getting lost in the vast UI sitemap.
That’s why despite having a feature-rich console, aws has an amazing cli backed by its
botocore module doesn’t it?
If yes, then you should definitely read further.
We can build interactive and immersive command-line interfaces in python using
This article discusses about python’s copy module and the nuances of deep and shallow copies. Understanding deep and shallow copies in python was always challenging, especially when dealing with mutable and immutable data types during copy. I have tried my best to put forth the concealed differences of copy with mutable and immutable objects here.
For collections that are mutable or contain mutable items, a copy is sometimes needed so one can change one copy without changing the other.
From the docs:
A shallow copy constructs a new compound object and then (to the extent possible) inserts references into it…
Any Python application has to be packaged for a user to use it. Why package your application? Firstly, you may not want to expose your code directly to the customer. Secondly, your end-user may need a single executable or a binary file to use your application rather than digging along the script files.
If you have been working as Python developer for a while now, I am pretty sure you would have packaged your application into a binary or an installable file.The most common libraries we use are
py2exe etc. Although
pyinstaller is relatively more prevalent.
This is a popular interview question on Linked List and also one of the problem statements in cracking the coding interview.
Write code to remove duplicates from an unsorted linked list.
What is a Linked List?
A linked list is a linear data structure which consists of a node object and a reference to the next node.
A singly linked list looks something like this.
Let’s assume that you need to share files from your AWS S3 bucket(private) without providing AWS access to a user. How would you do that? Well, we have pre-signed URLs that are shortly lived, which can be shared and used to access the content shared.
What is a pre-signed URL?
A pre-signed URL gives you temporary access to the object identified in the URL, provided that the creator of the pre-signed URL has permissions to access that object.
That is, if you receive a pre-signed URL to upload an object, you can upload the object only if the creator of…
I always used to concatenate strings using the “+” operator irrespective of the language I code only to realize later that I was doing them wrong. To be precise, inefficient.
Today, we shall discuss string concatenation in python and how to do it efficiently.
x = "hello"
y = "world"
print(x + y)Output:
As we are aware of the fact that string objects are immutable in python, any concatenation operation using the “+” operator could prove to be costly.
Why is it so?
String objects are immutable in python and any concatenation operation creates a new string, copies…
Big O is a term used to represent the efficiency of an algorithm. It is mandatory for a programmer to master the basics of Big O to clearly specify how fast or slow his algorithm could perform.
Big O is also used to represent the space taken by a program in-memory during the program execution.
So, in short, Big O is used to represent both the time and space which are popularly identified as
This article predominantly focuses on the time-complexity though we may slightly touch-base on the space complexity too. …
Have you ever thought of using a NamedTuple in python?
Today we will discuss what a
namedtuple is and where do we use them. You would have used a
tuple quite often but am pretty sure you would not have used a
Named tuples are built-in data types in the
collections module. This could be an alternative for your class definitions except that the
NamedTuples are immutable.
Lets look at a quick overview of
tuples in python.
tuples are one of the built-in data structures/containers in python to store arbitrary objects. …