Interesting Python modules for Beginners | Daily Python #24
This article lists a few interesting modules to play around whilst learning Python.
This article is a part of Daily Python challenge that I have taken up for myself. I will be writing short python articles daily.
- Python 3.0
Install the following packages:
- pyperclip — Library to handle clipboard content
- emoji — Library to generate emojis
- howdoi — Library to guide through python
- wikipedia — Library to fetch wikipedia content
- dis — Library to uncover how Python works internally
I have discussed how to handle clipboard content using ‘pynput’. This library is an alternative to that and quite easy to implement. We just need to use the copy and paste functions to copy from or to write to the clipboard. Below is an example of how you can use ‘pyperclip’.
pyperclip.copy('Heyyy this is being copied to clipboard')
This library makes it easy to create emojis in Python. If you are building a chatbot and want to recommend emojis based on text, then you can suggest relevant emojis by applying regular expressions on the input string. The ‘emojize’ function returns the Unicode characters for the given emoji name.
from emoji import emojize
How Do I?
This library is quite handy if you want to avoid going to google and searching for how to do a particular operation in Python. You can directly access this module through the terminal or you can import it in a Python script and pass the required query. The following code snippet demonstrates how to open a file in Python using ‘howdoi ’module.
from howdoi import howdoi
query = "open a file in python"
parser = howdoi.get_parser()
args = vars(parser.parse_args(query.split(' ')))
output = howdoi.howdoi(args)
This library opens up a webpage that contains comics related to python. The reason this module is here is that 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.
As the name suggests, this module is built to easily access Wikipedia pages from Python. If you are building an application that needs to access Wikipedia pages, then this module is quite handy and easy to integrate into any application. You can also get the summary of the page by using the summary attribute of the Wikipedia page.
page = wikipedia.page("Python")
In simple terms, this module shows what happens under the hood of the Python interpreter. The dis module supports the analysis of CPython bytecode by disassembling it. The CPython bytecode which this module takes as an input is defined in the file Include/opcode.h and used by the compiler and the interpreter.
CPython implementation detail: Bytecode is an implementation detail of the CPython interpreter. No guarantees are made that bytecode will not be added, removed, or changed between versions of Python. The use of this module should not be considered to work across Python VMs or Python releases.
#6. Dissemble Python
return('Number to string : ',str(num))dis.dis(myfun)
I hope this article was helpful, do leave some claps if you liked it.
Follow the Daily Python Challenge here:
You can’t perform that action at this time. You signed in with another tab or window. You signed out in another tab or…