Skip to content

A breeze through some of the ingenious, but not so popular python functions

License

Notifications You must be signed in to change notification settings

vignesh99/Handy-python-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Listed below are a set of functions from existing python libraries. Some of them are for enhancing computational speed, and others are for convinience.

Pickle

from pickle import dump
from pickle import load
                                    #Use load to feed data to variable
names = load(open('greekgods.pkl', 'rb'))
print(names)
                                    #Store required data using dump
flip = shuffle(names)
dump(flip, open('flipped.pkl', 'wb'))

Subprocess

import subprocess
                                    #String containing your command to run on terminal
filename = "HelloWorld.py"
args = ["python3 "+filename]        #We want to run "python3 HelloWorld.py"

                                    #Run the command on terminal using subprocess
popen = subprocess.Popen(args, stdout=subprocess.PIPE,shell=True)
popen.wait()
                                    #Read the output given from the terminal
output = popen.stdout.read()
output = output.decode("utf-8")

Will add more such functions as and when I come across them..

About

A breeze through some of the ingenious, but not so popular python functions

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages