#! /usr/bin/env python3

a = 10
b = 13

print(a, b)

# Inhalt der Variablen a und b vertauschen
tmp = a
a = b
b = tmp

print(a, b)

def foo(i):
    "Gibt 3 Werte als Tupel zurueck"
    inc = i + 1
    add = i + i
    mul = i * i

    ergebnis = [inc, add, mul]
    ergebnis = (inc, add, mul)

    # return ergebnis
    # Automatisches pack -> erzeugt Tupel
    return inc, add, mul

# Sieht aus wie Mehrfachzuweisung, ist es aber nicht ;-)
a, b = b, a
# Anwendung z.B. bei regulaeren Ausdruecken:
# ip_address, oktett = match.groups()

print(a, b)

a, b, c, d, e = 10, 20, 30, 40, 50
print(a, b, c, d, e)

# Automatisches pack -> erzeugt Tupel
whut = 10, 20, 30, 40, 50
print(whut)

mytuple = (10, 13, 14, 15, 16)
# Automatisches unpack, Werte werden paarweise zugewiesen
a, b, c, d, e = mytuple
print(a, b, c, d, e)

mylist = [23, 24, 25, 26, 27]
a, b, c, d, e = mylist
print(a, b, c, d, e)

*a, b, c, d, e = 10, 20, 30, 40, 50, 60
print(a, b, c, d, e)
a, b, c, d, *e = 10, 20, 30, 40, 50, 60
print(a, b, c, d, e)
a, b, c, *d, e = 10, 20, 30, 40, 50, 60
print(a, b, c, d, e)

a, b, c = foo(10)
result = foo(10)
print(a, b, c)
print(result)
print(*result) # *result erzeugt Menge von Positionsparametern

e = 6, 7, 8, 9, 10, 11, mytuple
print(e)
print(*e)
