= Treffen vom 10. 07. 2019 = * [[https://www.meetup.com/PYUGAT/events/262253008/|Meetup-Seite zu diesem Treffen]] == Agenda == * Begrüßung * Metalab * Vorstellungsrunde * [[FrontPage|Wiki]], MailingLists, [[https://twitter.com/pyugat|Twitter]], [[http://www.meetup.com/PYUGAT/|Meetup]], [[http://webchat.freenode.net/?channels=#pyugat|IRC: #pyugat on freenode]], [[https://flattr.com/thing/1804445/Python-User-Group-Austria|Flattr]] * Am Wiki anmelden & [[CategoryHomepage|persönliche Seite]] anlegen (Kontaktinfos, Name, Interessen, Foto,…) * Hands-on in Python: {{{#!highlight python >>> seq = [1,2,3,4,5,6,7] >>> val1, *_, num2, num3 = seq >>> _ [2, 3, 4, 5] >>> val1 1 >>> num2 6 >>> num3 7 >>> 3 + 6 9 >>> _ 9 # What does _ stand for? >>> import math >>> math.sin >>> _ >>> _(5) -0.9589242746631385 >>> _(5) Traceback (most recent call last): File "", line 1, in TypeError: 'float' object is not callable >>> -0.9589242746631385(5) Traceback (most recent call last): File "", line 1, in TypeError: 'float' object is not callable >>> _ -0.9589242746631385 >>> _ * 2 -1.917848549326277 >>> _ * 2 -3.835697098652554 >>> _ * 2 -7.671394197305108 >>> _ * 2 -15.342788394610215 >>> _ * 2 -30.68557678922043 >>> _ * 2 -61.37115357844086 >>> _ * 2 -122.74230715688172 >>> _ -122.74230715688172 >>> _ = 42 >>> 3 * 9 27 >>> _ 42 >>> del _ >>> _ 42 >>> 3 * 9 27 >>> _ 27 >>> math.sin(2*math.pi) -2.4492935982947064e-16 >>> math.isclose(math.sin(2*math.pi), 0) False >>> math.isclose(math.sin(2*math.pi), 0, 0.0000001) Traceback (most recent call last): File "", line 1, in TypeError: Function takes at most 2 positional arguments (3 given) >>> math.isclose(math.sin(2*math.pi), 0.000001) False >>> math.isclose(math.sin(2*math.pi), -0.000001) False >>> math.isclose(math.sin(2*math.pi), 1) False >>> math.sin(0) 0.0 >>> math.sin(math.pi) 1.2246467991473532e-16 >>> math.sin(math.pi*2) -2.4492935982947064e-16 # is math.sin(2*math.pi) close to zero? Lack of definition what is interpreted as close.... >>> def print_x_is_4(): ... x = 4 ... print(x) ... >>> x = 3 >>> x 3 >>> print_x_is_4() 4 >>> def print_x(): ... print(x) ... >>> print_x() 3 >>> def print_x_plus_x(): ... x += x ... print(x) ... >>> print_x_plus_x() Traceback (most recent call last): File "", line 1, in File "", line 2, in print_x_plus_x UnboundLocalError: local variable 'x' referenced before assignment >>> ergebnis = x + x >>> x = ergebnis >>> x 6 # x is defined in local scope >>> def print_local_scope(): ... x = 4 ... x += x ... print(x) ... >>> print_local_scope() 8 >>> x 6 # operation in local scope has no effect to global scope >>> def print_global_x(): ... global x ... x += x ... print(x) ... >>> x 6 >>> print_global_x() 12 >>> x 12 # x is defined in global scope out of the function >>> def draussen(): ... x = 8 ... def drinnen(): ... nonlocal x ... x += x ... print("drinnen:", x) ... print("vorher:", x) ... drinnen() ... print("nachher:", x) ... >>> draussen() vorher: 8 drinnen: 16 nachher: 16 >>> x 12 >>> drinnen() Traceback (most recent call last): File "", line 1, in NameError: name 'drinnen' is not defined # function drinnen() only exists in the function draussen() }}} ---- CategoryShownotes