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
#include <stdio.h> | |
#include <stdlib.h> | |
void quicksort(int *array, int length); | |
void swap(int *a, int *b); | |
void print(int *array, int length); | |
int main() |
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
# This file must be used with "source bin/activate" *from bash* | |
# you cannot run it directly | |
deactivate () { | |
unset pydoc | |
# reset old environment variables | |
if [ -n "$_OLD_VIRTUAL_PATH" ] ; then | |
PATH="$_OLD_VIRTUAL_PATH" | |
export PATH |
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
# 2.7 | |
if (tstate->recursion_depth > recursion_limit) { | |
--tstate->recursion_depth; | |
PyErr_Format(PyExc_RuntimeError, | |
"maximum recursion depth exceeded%s", | |
where); | |
return -1; | |
# 3.4 |
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
>>> class Thing(object): | |
... def __init__(self, name, description): | |
... self.name = name | |
... self.desc = description | |
... | |
>>> b = Thing('box', 'empty') | |
>>> c = Thing('cat', 'fuzzy') | |
>>> collection = {'box': b, 'cat' : c} | |
>>> collection['box'] | |
<__main__.Thing object at 0x1073a2150> |
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
>>> class FalseContext(object): | |
... def __enter__(self): | |
... l.append('i') | |
... return self | |
... def __exit__(self, exc_type, exc_val, exc_tb): | |
... l.append('o') | |
... return False | |
... | |
>>> class TrueContext(object): | |
... def __enter__(self): |