diff --git a/scopes/util.py b/scopes/util.py index a3d637c..52f353d 100644 --- a/scopes/util.py +++ b/scopes/util.py @@ -5,6 +5,23 @@ import hashlib from secrets import choice import string +# symbols and keywords + +class Symbol(str): + + def __repr__(self): + return f'' + +class Symbols: + + def __getattr__(self, k): + sym = Symbol(k) + setattr(self, k, sym) + return sym + +keywords = Symbols() + + # random strings, hashes, encodings # for authentication, encryption, and other purposes diff --git a/tests/test_util.py b/tests/test_util.py new file mode 100644 index 0000000..cc2c0f6 --- /dev/null +++ b/tests/test_util.py @@ -0,0 +1,13 @@ +# py-scopes: tests.test_util + +"""Tests for scopes.util package""" + +import pytest + +from scopes.util import keywords as k + +def test_keywords(): + assert k.dummy is k.dummy + assert k.dummy is not k.other + assert getattr(k, "abcd"[-2:]) is k.cd +