Skip to content

Instantly share code, notes, and snippets.

@ianfoo
Created September 30, 2018 17:59
Show Gist options
  • Save ianfoo/47b115a3a2b78345fd319643d74dbfaf to your computer and use it in GitHub Desktop.
Save ianfoo/47b115a3a2b78345fd319643d74dbfaf to your computer and use it in GitHub Desktop.
Simple example of defining and using Python modules
def dishroom():
return "Dishroom has 24 hour beans."
def huh():
return "You cooked beans for 24 hours? What's the matter with you?"
def sports():
return "¯\_(ツ)_/¯ Let's go watch sports."
class Foo:
def __init__(self, message):
self.message = message
def say(self):
return self.message
def status():
return "Luca is okay!"
from bar import dishroom, huh, sports
from foo import Foo
from residents import luca
def main():
foo = [ Foo(luca.status()),
Foo(dishroom()),
Foo(huh()),
Foo(sports()) ]
for f in foo:
print(f.say())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment