Skip to content

Instantly share code, notes, and snippets.

@lassebenni
Created January 13, 2026 18:39
Show Gist options
  • Select an option

  • Save lassebenni/9e9398a8e7f4d0e2998975a6276d06b6 to your computer and use it in GitHub Desktop.

Select an option

Save lassebenni/9e9398a8e7f4d0e2998975a6276d06b6 to your computer and use it in GitHub Desktop.
Terminal Tutorial: Type Checking with type() in Python
{"version":2,"width":80,"height":24,"timestamp":1768329516,"command":"python3 type_check_actor.py","env":{"SHELL":"/bin/zsh"}}
[0.094466, "o", "\u001b[1;36m# Type Checking with type() in Python\u001b[0m\r\n\r\n"]
[1.094798, "o", ">>> t"]
[1.155136, "o", "y"]
[1.229516, "o", "p"]
[1.28968, "o", "e"]
[1.342689, "o", "("]
[1.411384, "o", "4"]
[1.467575, "o", "2"]
[1.526385, "o", ")"]
[1.563468, "o", "\r\n<class 'int'>\r\n"]
[2.363887, "o", ">>> t"]
[2.448163, "o", "y"]
[2.47985, "o", "p"]
[2.543268, "o", "e"]
[2.584842, "o", "("]
[2.61587, "o", "3"]
[2.674262, "o", "."]
[2.714778, "o", "1"]
[2.757481, "o", "4"]
[2.802694, "o", ")"]
[2.862695, "o", "\r\n<class 'float'>\r\n"]
[3.665146, "o", ">>> t"]
[3.7035, "o", "y"]
[3.757406, "o", "p"]
[3.837656, "o", "e"]
[3.918565, "o", "("]
[3.967906, "o", "\""]
[4.003376, "o", "h"]
[4.074903, "o", "e"]
[4.112808, "o", "l"]
[4.183462, "o", "l"]
[4.227449, "o", "o"]
[4.310057, "o", "\""]
[4.363977, "o", ")"]
[4.417665, "o", "\r\n<class 'str'>\r\n"]
[5.219612, "o", ">>> t"]
[5.26262, "o", "y"]
[5.335393, "o", "p"]
[5.40415, "o", "e"]
[5.442758, "o", "("]
[5.479037, "o", "T"]
[5.531144, "o", "r"]
[5.576732, "o", "u"]
[5.653958, "o", "e"]
[5.699635, "o", ")"]
[5.755567, "o", "\r\n<class 'bool'>\r\n"]
[6.75878, "o", "\r\n\u001b[1;33m# Collections\u001b[0m\r\n"]
[7.263098, "o", ">>> t"]
[7.318583, "o", "y"]
[7.353431, "o", "p"]
[7.427303, "o", "e"]
[7.4686, "o", "("]
[7.536612, "o", "["]
[7.617216, "o", "1"]
[7.668545, "o", ","]
[7.744467, "o", " "]
[7.78876, "o", "2"]
[7.835595, "o", ","]
[7.913113, "o", " "]
[7.991402, "o", "3"]
[8.045618, "o", "]"]
[8.096114, "o", ")"]
[8.172817, "o", "\r\n<class 'list'>\r\n"]
[8.97637, "o", ">>> t"]
[9.041665, "o", "y"]
[9.07925, "o", "p"]
[9.123831, "o", "e"]
[9.179521, "o", "("]
[9.225816, "o", "{"]
[9.259103, "o", "\""]
[9.292744, "o", "n"]
[9.375704, "o", "a"]
[9.425949, "o", "m"]
[9.508204, "o", "e"]
[9.562837, "o", "\""]
[9.600293, "o", ":"]
[9.66595, "o", " "]
[9.703648, "o", "\""]
[9.776235, "o", "A"]
[9.826706, "o", "l"]
[9.868055, "o", "i"]
[9.904988, "o", "c"]
[9.981959, "o", "e"]
[10.018612, "o", "\""]
[10.098655, "o", "}"]
[10.143408, "o", ")"]
[10.19045, "o", "\r\n<class 'dict'>\r\n"]
[11.193496, "o", "\r\n\u001b[1;33m# Validation with isinstance()\u001b[0m\r\n"]
[11.698311, "o", ">>> v"]
[11.742133, "o", "a"]
[11.795598, "o", "l"]
[11.852762, "o", "u"]
[11.895418, "o", "e"]
[11.933325, "o", " "]
[12.012728, "o", "="]
[12.092785, "o", " "]
[12.154184, "o", "4"]
[12.20032, "o", "2"]
[12.268643, "o", "\r\n"]
[12.573413, "o", ">>> i"]
[12.632702, "o", "s"]
[12.702495, "o", "i"]
[12.766325, "o", "n"]
[12.845975, "o", "s"]
[12.900626, "o", "t"]
[12.932034, "o", "a"]
[13.00083, "o", "n"]
[13.068051, "o", "c"]
[13.106629, "o", "e"]
[13.190424, "o", "("]
[13.237714, "o", "v"]
[13.298659, "o", "a"]
[13.373774, "o", "l"]
[13.411147, "o", "u"]
[13.482672, "o", "e"]
[13.544667, "o", ","]
[13.592585, "o", " "]
[13.631937, "o", "i"]
[13.691536, "o", "n"]
[13.732413, "o", "t"]
[13.775411, "o", ")"]
[13.85275, "o", "\r\nTrue\r\n"]
[14.657737, "o", ">>> i"]
[14.743748, "o", "s"]
[14.781642, "o", "i"]
[14.850946, "o", "n"]
[14.900526, "o", "s"]
[14.964151, "o", "t"]
[15.02431, "o", "a"]
[15.09252, "o", "n"]
[15.150494, "o", "c"]
[15.186085, "o", "e"]
[15.223898, "o", "("]
[15.282197, "o", "v"]
[15.323299, "o", "a"]
[15.38344, "o", "l"]
[15.442113, "o", "u"]
[15.510801, "o", "e"]
[15.555382, "o", ","]
[15.635356, "o", " "]
[15.68534, "o", "s"]
[15.726394, "o", "t"]
[15.806047, "o", "r"]
[15.882007, "o", ")"]
[15.915876, "o", "\r\nFalse\r\n"]
[16.717558, "o", ">>> i"]
[16.793017, "o", "s"]
[16.845864, "o", "i"]
[16.88778, "o", "n"]
[16.93993, "o", "s"]
[17.003467, "o", "t"]
[17.056521, "o", "a"]
[17.131414, "o", "n"]
[17.214122, "o", "c"]
[17.289718, "o", "e"]
[17.361093, "o", "("]
[17.413537, "o", "v"]
[17.447863, "o", "a"]
[17.501179, "o", "l"]
[17.573786, "o", "u"]
[17.64738, "o", "e"]
[17.700644, "o", ","]
[17.746318, "o", " "]
[17.824755, "o", "("]
[17.866423, "o", "i"]
[17.91132, "o", "n"]
[17.954233, "o", "t"]
[18.00017, "o", ","]
[18.050211, "o", " "]
[18.100589, "o", "f"]
[18.143008, "o", "l"]
[18.215981, "o", "o"]
[18.251865, "o", "a"]
[18.28823, "o", "t"]
[18.332026, "o", ")"]
[18.403619, "o", ")"]
[18.447458, "o", "\r\nTrue\r\n"]
[19.450888, "o", "\r\n\u001b[1;32m✓ Done!\u001b[0m\r\n"]
[19.459769, "x", "0"]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Terminal Tutorial: Type Checking</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/asciinema-player@3.6.3/dist/bundle/asciinema-player.css" />
<style>
body { margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; background: #121212; color: #eee; font-family: sans-serif; }
#player { width: 100%; max-width: 900px; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.error { color: #ff5555; text-align: center; padding: 20px; border: 1px solid #ff5555; border-radius: 4px; background: rgba(255,0,0,0.1); }
</style>
</head>
<body>
<div id="player"></div>
<script src="https://unpkg.com/asciinema-player@3.6.3/dist/bundle/asciinema-player.min.js"></script>
<script>
window.addEventListener('load', function() {
setTimeout(function() {
if (typeof AsciinemaPlayer === 'undefined') {
document.getElementById('player').innerHTML = '<div class="error"><strong>Error:</strong> AsciinemaPlayer failed to load.</div>';
return;
}
AsciinemaPlayer.create('type_check.cast', document.getElementById('player'), {
autoPlay: true, preload: true, rows: 18, cols: 60, theme: 'monokai', idleTimeLimit: 2
});
}, 100);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment