I'm trying to create my own class that acts like a regular type, like this:
class CustomType:
def __init__(self, content):
self.content = content
def __str__(self):
return self.content
This means I can do something like this:
a = CustomType("hi there")
print(a) # 'hi there'
But the problem is that I have to use a = CustomType("hi there")
. Is there a way I can do something like a = /hi there\
or a similar solution that lets me create my own syntactic sugar?
Thanks.
No. Python does not support creating new syntax.