This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
@dataclass | |
class A: | |
value: str | |
@dataclass | |
class B: | |
value: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type State = "loading" | "loaded" | "error"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const x = "hi"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = "hi" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import sys | |
>>> def stuff(): | |
... print("calling stuff!") | |
... | |
>>> def printer(frame, event, arg): | |
... print(frame, event, arg) | |
... return printer # return itself to keep tracing | |
... | |
>>> sys.settrace(printer) # register the tracing function | |
>>> stuff() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countdown(n, times_called=[0],): | |
print(times_called[0], " ", n, " ") | |
# print "frame: %s" % id(inspect.currentframe()) | |
times_called[0] += 1 | |
if n == 1: | |
return times_called | |
else: | |
try: | |
return countdown(n-1) | |
except RuntimeError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countdown(n, times_called=[0]): | |
print times_called[0], " ", n, " " | |
times_called[0] += 1 | |
if n == 1: | |
return times_called | |
else: | |
try: | |
return countdown(n-1) | |
except RuntimeError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test ⚲ ./testopt | |
aflag = 0, bflag = 0, cvalue = (null) | |
test ⚲ ./testopt -a -b | |
aflag = 1, bflag = 1, cvalue = (null) | |
test ⚲ ./testopt -c | |
Option -c requires an argument. | |
test ⚲ ./testopt -ab | |
aflag = 1, bflag = 1, cvalue = (null) | |
test ⚲ ./testopt -c foo | |
aflag = 0, bflag = 0, cvalue = foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def depth_one(n): | |
def depth_two(n): | |
def countdown(n, times_called=[0]): | |
times_called[0] += 1 | |
if n == 0: | |
return times_called | |
else: | |
try: | |
return countdown(n-1) | |
except RuntimeError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int | |
_Py_CheckRecursiveCall(char *where) | |
{ | |
PyThreadState *tstate = PyThreadState_GET(); | |
#ifdef USE_STACKCHECK | |
if (PyOS_CheckStack()) { | |
--tstate->recursion_depth; | |
PyErr_SetString(PyExc_MemoryError, "Stack overflow"); | |
return -1; |