I am sure most of you would have used pyinstaller for generating executables. This article does not cover what a pyinstaller is. However, the focus of the article will be on how to add external data files to your pyinstaller binaries and their use cases.
Usually, we generate a one file executable in pyinstaller using the following command.
$pyinstaller --onefile --clean <file_name.py>
Let’s say you have a help file for your application which needs to be packed along with your executable. Your application needs to read the file at runtime and display it to the user.
How do we do…
Security in your code is considered to be of paramount importance today, especially when we work remotely. We do a lot of proof-of-concepts, implement business logic with multiple libraries. Though most of them are open source, there could be vulnerabilities, license issues when we productize the code for commercial use. It is almost impossible to keep an eye on every single library and their possibility for commercial use. That’s why we have vulnerability scanners to make lives easier.
Ochrona security provides solution for validating dependencies of your python project.
Ochrona gives users access to a centralized web portal to manage…
Recently, I was given a task of refactoring our legacy command line application. I was thinking what more could we do to improvise a legacy command line application that’s working just fine.
Remembering the commands and their respective flags, optional parameters etc is bit hectic. Of course you could copy all the commands in a notepad and use ’em as needed. But that’s still annoying if you ask me.
So what did I do?
I came across this library called PyInquirer and
rich with which we could make colorful command line applications that are interactive.To …
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
Pip has been the package installer for Python libraries for a long time. However, pip has a few limitations. We don’t have a single solution to download, install, package, build and publish in Python.
Traditionally we download and install dependencies using
pip in Python. However, we have to rely on
setuptools to build and distribute packages in Python.
We use the following commands to build a source distribution/binary distribution or a wheel file.
$python setup.py bdist
$python setup.py bdist_wheel
$python setup.py sdist
To publish to PyPI, we may have to use
twine. As just discussed, we don’t have a one-stop…
The most common mistakes we make in interviews are the most silly ones. Do you agree? This happens because we ignore the ones which we are quite familiar. During interviews, we prepare the most difficult data structure and algo questions and seldom give importance to fibonacci or prime number programs. However, sometimes we get stuck during interviews in these petty programs. This article is a refresher for fibonacci series generation using python.
🆗 Now, let’s cut to the chase!
pip is the package manager for python.pip can be used to install python libraries from PyPI. In other words,
pip is the
python. We use pip to install and manage python libraries that are not part of the python standard library.
Any python developer predeminantly uses
pip day in and out.However, the usage is limited to just install and occasionally upgrade.
This article is a consolidated non-exhaustive list of all the pip commands every python developer should know. This could be a reference for any future pip commands.
The install command is used to install the specified library…
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.
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