DEV Community

Cover image for 7 Awesome Python Libraries To Play With 🕺
Mr. Unity Buddy
Mr. Unity Buddy

Posted on • Originally published at mr-unity-buddy.hashnode.dev

7 Awesome Python Libraries To Play With 🕺

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
Enter fullscreen mode Exit fullscreen mode

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()
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Code

from emoji import emojize
print(emojize(":laptop:"))
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

Emoji Cheat sheet

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
Enter fullscreen mode Exit fullscreen mode

Code

import wikipedia
result = wikipedia.page("Python Programming Language")
print(result.summary)
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Code,

howdoi make trees in Python
howdoi commit in git
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Code,

import antigravity
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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)
Enter fullscreen mode Exit fullscreen mode

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)

Enter fullscreen mode Exit fullscreen mode

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()
Enter fullscreen mode Exit fullscreen mode

So buddies, that's all for now. Happy Coding!

References

Top comments (4)

Collapse
 
nirav97120 profile image
Nirav Prajapati

Make a post on "all thing about API with examples"

Collapse
 
skelouse profile image
Samuel Stoltenberg

When it comes to emojis, depending on your compiler you can type emoji literals. I.e.
'''
Smile = "😁"

or

Winking_face = "\N{winking face}"

'''

Collapse
 
norweeg profile image
Brennen Raimer

Why are you pip installing urllib? It's in the standard library docs.python.org/3/library/urllib.html

Collapse
 
zabrad profile image
zabrad

Cool post