1

There are literal that represent a built-in data type

Examples

"" represents a string

{} represents a dictionary

How can I make user-defined literals to represent a object of the type I want?

2
  • What is wrong with using the same symbols used in the class name followed by parenthesis? Can you give an example of exactly what you would like to use? Commented Jun 26, 2022 at 15:15
  • Are you trying to overwrite the behavior of operators on the object? Commented Jun 26, 2022 at 15:23

1 Answer 1

1

You can’t do that in python

Or most other languages. You would have to change the python parser and the source code. So this is sadly not possible.

Sign up to request clarification or add additional context in comments.

2 Comments

You kind of can in python but then again the question is if you want to ... pypi.org/project/custom-literals

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.