Skip to content

Commit

Permalink
example for unliteral
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRace committed Mar 31, 2022
1 parent 1dc7844 commit 2290c65
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ class Duration:

print(30 .s + 0.5.m) # 0:01:00
```
Removing a custom literal:
```py
from custom_literals import literal, unliteral

@literal(str)
def u(self):
return self.upper()

print("hello".u) # "HELLO"

unliteral(str, "u")
assert not hasattr("hello", "u")
```
Context manager syntax:
```py
from custom_literals import literally
Expand Down
13 changes: 13 additions & 0 deletions custom_literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ def m(self):
print(30 .s + 0.5.m) # 0:01:00
```
Removing a custom literal:
```py
from custom_literals import literal, unliteral
@literal(str)
def u(self):
return self.upper()
print("hello".u) # "HELLO"
unliteral(str, "u")
assert not hasattr("hello", "u")
```
Context manager syntax:
```py
from custom_literals import literally
Expand Down

0 comments on commit 2290c65

Please sign in to comment.