This is just a fun demo of how lists and sets handle the in
lookup.
class Testing:
def __init__(self, name):
self.name = name
import inspect | |
from enum import Enum, auto, EnumType | |
class EnumCaptureDict(dict): | |
def __getitem__(self, item): | |
if item in self or (item.startswith("__") and item.endswith("__")): | |
return super().__getitem__(item) | |
frame = inspect.currentframe().f_back |
from typing import Type, TypeVar | |
class Sentinel: | |
def __new__(cls): | |
instance = super().__new__(cls) | |
cls.__new__ = lambda _: instance | |
return instance | |
from typing import Generic, TypeVar | |
T = TypeVar("T") | |
class Node(Generic[T]): | |
def __init__(self, value: T, parent: "Node[T] | None" = None): | |
self._children = tuple() | |
self._parent = parent |
from typing import Generic, TypeVar | |
T = TypeVar("T") | |
class Node(Generic[T]): | |
def __init__(self, value: T, head: "Node | None" = None, next_node: "Node | None" = None): | |
self.head = self if head is None else head | |
self.next = next_node |
import asyncio | |
from state_machine import StateMachine, State | |
class CountBsAfterAs(StateMachine): | |
def __init__(self): | |
super().__init__() | |
self.num_bs_after_as = 0 | |
@State |
from __future__ import annotations | |
import json | |
from dataclasses import dataclass, MISSING, field as _field | |
from typing import Any, Callable | |
class MutationDescriptor: | |
def __init__(self, mutator: Callable[[Any], Any]): | |
self._mutator = mutator |
Syncopation means an emphasis on a weak beat of a bar of music; most commonly, beats 2 and 4 (and all other even-numbered beats if applicable).
s
is a line of music, represented as a string, where hashtags #
represent emphasized beats. Create a function that returns if the line of music contains any syncopation.
has_syncopation(".#.#.#.#") ➞ True
# There are Hash signs in the second, fourth, sixth and
The Revised Julian Calendar is a calendar system very similar to the familiar Gregorian Calendar, but slightly more accurate in terms of average year length. The Revised Julian Calendar has a leap day on Feb 29th of leap years as follows: