From 32ed07996cfd1abb0a1dd85eba33f139b3d0c4ec Mon Sep 17 00:00:00 2001 From: Martin Mares <mj@ucw.cz> Date: Mon, 25 Nov 2019 00:38:26 +0100 Subject: [PATCH] Objekty: Dotazy na typy --- 09-objekty/09-objekty.tex | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/09-objekty/09-objekty.tex b/09-objekty/09-objekty.tex index 3064f49..5e2906b 100644 --- a/09-objekty/09-objekty.tex +++ b/09-objekty/09-objekty.tex @@ -213,6 +213,42 @@ Příšerka říká: Mňauuu % ---------------------------------------------------------------------- +\begin{frame}{Dotazy na typy} + +\py{% +type(k) is Kocka +}{% +True +} + +\py{% +type(k) is Zvire +}{% +False +} + +\py{% +isinstance(k, Kocka) +}{% +True +} + +\py{% +isinstance(k, Zvire) +}{% +True +} + +\py{% +issubclass(Kocka, Zvire) +}{% +True +} + +\end{frame} + +% ---------------------------------------------------------------------- + \begin{frame}{Jak to funguje uvnitř} {\bf Prostory jmen (namespaces):} -- GitLab