Search code examples
pythonliterals

Creating user defined literals representing a data type


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?


Solution

  • 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.