Hello, buddies! While playing with Python for a time, I found some quite interesting modules that are considered worthy of sharing with others. So today we're going to see 7 Interesting and Awesome Python libraries(modules;) that are useful too!
1. Pyperclip
This module was created to enable cross-platform copy-pasting in Python which was earlier absent. The pyperclip module has copy()
and paste()
functions that can send a text to and receive text from your computer’s clipboard. Sending the output of your program to the clipboard will make it easy to paste it on an email, word processor, or some other software
Install
pip install pyperclip
Code
# Python program to
# demonstrate pyperclip module
# This will import pyperclip
import pyperclip
pyperclip.copy("Hello, buddies!")
pyperclip.paste()
pyperclip.copy("This is an interesting module!")
pyperclip.paste()
2. Emoji 😉
Emojis have become a way to express and to enhance simple boring texts. Now, the same gems can be used in Python programs too. Yes, really! You now have the ultimate power to use emojis in your code. For this, emoji module is needed to be installed.
Install
pip install emoji
Code
from emoji import emojize
print(emojize(":laptop:"))
Alternatively, encode()
function can be used from emojis module to convert Unicode to emojis:
import emojis
emojified = emojis.encode("There is a :snake: in my boot !")
print(emojified)
3. Wikipedia
Now import Wikipedia in Python using Wikipedia module. Use the incessant flow of knowledge with Python for daily needs.
Install,
pip install wikipedia
Code
import wikipedia
result = wikipedia.page("Python Programming Language")
print(result.summary)
4. Howdoi
Stuck on a coding problem? Wish to visit StackOverflow without leaving the terminal? With howdoi, you can do it!
Install,
pip install howdoi
Code,
howdoi make trees in Python
howdoi commit in git
Ask whatever question you have and it will try it’s best to answer it. From now, you don’t need to open those browsers for a quick search and get those hefty amounts of ads and distractions. Just howdoi
!
5. Antigravity
The reason this module is here is because this is quite fun! It’s basically an Easter egg in Python 3 which is used in Google App Engines. It was added to Google App Engines just as a medium to amuse the users.
Install
pip install antigravity
Code,
import antigravity
See the magic!
6. urllib
Urllib module is the URL handling module for python. It is used to fetch URLs (Uniform Resource Locators). It uses the urlopen function and is able to fetch URLs using a variety of different protocols.
Urllib is a package that collects several modules for working with URLs, such as:
-
urllib.request
for opening and reading. -
urllib.robotparser
for parsing robot.txt files -
urllib.parse
for parsing URLs -
urllib.error
for the exceptions raised
Install
pip install urllib
Code
# This will import urlopen
# class from urllib module
from urllib.request import urlopen
page = urlopen("https://mr-unity-buddy.hashnode.dev/")
print(page.headers)
You can also see the coding of the website by using read()
function:
# This will import urlopen
# class from urllib module
from urllib.request import urlopen
page=urlopen("http://hashnode.com")
# Fetches the code
# of the web page
content = page.read()
print(content)
7. Turtle
Yes, a turtle can be imported. Don’t worry it’s not slow. Turtle is a Python module to draw. It has a huge application and a number of methods which you can learn about in here. But with just a few basics, pretty cool stuff can be done. This module comes built-in with Python so there is no need to install it.
Code
# This will import turtle module
import turtle
myTurtle = turtle.Turtle()
myWin = turtle.Screen()
# Turtle to draw a spiral
def drawSpiral(myTurtle, linelen):
myTurtle.forward(linelen)
myTurtle.right(90)
drawSpiral(myTurtle, linelen-10)
drawSpiral(myTurtle, 80)
myWin.exitonclick()
So buddies, that's all for now. Happy Coding!