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
#!/usr/bin/env python | |
import argparse | |
import sys | |
def tokenize(source): | |
return list(source) | |
def parse(tokens): |
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 LinkedList: | |
next = None | |
val = None | |
def __init__(self, val): | |
self.val = val | |
def add(self, val): | |
if self.next is None: | |
self.next = LinkedList(val) |
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
#!/usr/bin/env python | |
# coding=utf-8 | |
# <a class="btn btn-default pull-right" href="https://gist.github.com/TylerShaw/48ead56c19ce905ac513"><i class="fa fa-git"></i> Download the gist here!</a> | |
# Py2Md started as a little project to do the magical "self documenting code". After thinking about it, I realized self documenting code is great, but it's really not the point. | |
# Commenting code properly, if only better, is the point. | |
# This script evolved from me wanting to code better. I often look at other peoples code, or even old code I've written, and it takes me a few minutes to even figure out what each section is doing. | |
# This will hopefully solve that, not only by forcing me to comment code better, but to publish my code with decent comments. | |
# This script reads in a python file (either itself, or anything it's | |
# imported into) and converts the python file into a markdown file. It |
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
# disclaimer: untested code ahead! see https://www.reddit.com/r/Python/comments/fk4wal/i_needed_an_object_that_can_with_one_instance/fkrbodb/ | |
from dataclasses import dataclass | |
from enum import Enum, auto | |
from typing import Any, Callable, Tuple | |
@dataclass | |
class CacheValue: | |
result: Any | |
times_changed: int = 1 |