from words import (fetch_words, print_items, main) #Print print_items(fetch_words('http://sixty-north.com/c/t.txt')) #Call main method main('http://sixty-north.com/c/t.txt') #Pirnt string print_items("This is a sample string")
from words import (fetch_words, print_items) #from words import * words = fetch_words('https://www.w3.org/TR/PNG/iso_8859-1.txt') words.append('shiiiiiiiiiiiiieeeeeettttt') print_items(words)
# Dunder # __name__ - specially named variable allowing us to detect whether a module is run as a script or imported into another module. # Import the created words function in words.py import words words.fetch_words()
# Main Functions and command line arguments ################################################################################ # import multile object from module from words import (fetch_words, print_words) print_words(fetch_words()) # import everything from module from words import * fetch_words() print_words( ['Any', 'list', 'of', 'words'] ) main() print_words( [1, 7, 3] ) print_words("Strings are iterable too") # refactor words.py # give url from command line python3 words.py http://sixty-north.com/c/t.txt # change words.py to take system arguments from words import * main('http://sixty-north.com/c/t.txt') ################################################################################