blob: 5aaaae7f460820c71fd38154694a2364aa565050 [file] [log] [blame]
Wenzel Jakob57082212015-09-04 23:42:12 +02001#!/usr/bin/env python
2from __future__ import print_function
Wenzel Jakob38bd7112015-07-05 20:05:44 +02003import sys
4sys.path.append('.')
5
6from example import Pet
7from example import Dog
8from example import dog_bark
9from example import pet_print
10
11polly = Pet('Polly', 'parrot')
12molly = Dog('Molly')
13print(polly.name() + " is a " + polly.species())
14pet_print(polly)
15print(molly.name() + " is a " + molly.species())
16pet_print(molly)
17dog_bark(molly)
18try:
19 dog_bark(polly)
20except Exception as e:
21 print('The following error is expected: ' + str(e))
22
23from example import test_callback1
24from example import test_callback2
25from example import test_callback3
Wenzel Jakob281aa0e2015-07-30 15:29:00 +020026from example import test_callback4
Wenzel Jakob38bd7112015-07-05 20:05:44 +020027
28def func1():
29 print('Callback function 1 called!')
30
Wenzel Jakob7b8e0322015-08-28 17:49:15 +020031def func2(a, b, c, d):
32 print('Callback function 2 called : ' + str(a) + ", " + str(b) + ", " + str(c) + ", "+ str(d))
Wenzel Jakoba2f6fde2015-10-01 16:46:03 +020033 return d
Wenzel Jakob38bd7112015-07-05 20:05:44 +020034
35print(test_callback1(func1))
36print(test_callback2(func2))
37
Wenzel Jakoba2f6fde2015-10-01 16:46:03 +020038test_callback3(lambda i: i + 1)
39f = test_callback4()
Wenzel Jakob281aa0e2015-07-30 15:29:00 +020040print("func(43) = %i" % f(43))