Skip to content

Instantly share code, notes, and snippets.

@erikkaplun
Created January 26, 2011 19:29
Show Gist options
  • Save erikkaplun/797257 to your computer and use it in GitHub Desktop.
Save erikkaplun/797257 to your computer and use it in GitHub Desktop.
Moodulite importimine
def hello():
print('Hello!')
def say_greetings(name):
print('Greetings, %s!' % name)
# Python 3:
# print('Greetings, {0}!'.format(name))
import foo
foo.hello()
# ekraanile ilmub: Hello!
foo.say_greetings('Anton')
# ekraanile ilmub: Greetings, Anton!
foo.say_greetings('Erik')
foo.say_greetings('Juhan')
# alternatiiv-versioon:
#
# from foo import hello, say_greetings
# hello()
# say_greetings('Anton')
@erikkaplun
Copy link
Author

foo.py ja main.py tuleb panna samasse kausta ning seejärel käivitada skript main.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment