We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Python but it's trash

From Esolang
Jump to navigation Jump to search

I am User:LEOMOK, here to make Python trash.

How I made it trash

This programming language is exactly the same as normal Python, but:

  1. The underscore _ is not allowed, even in strings. Same for expressions and escape codes that produce an underscore, such as \u005f.
  2. All integers are 32 bit. There are no floats. Also, the only numeric literal is 0.
  3. math functions return truncated results. math.pi is 3.
  4. The only boolean is True. Expressions that evaluate to False are undefined behavior.
  5. All errors are called Error. That means no TypeErrors, no SyntaxErrors, just Error.
  6. The == operator is undefined.
  7. String literals may not contain whitespace, unless if that’s all it contains.
  8. Lists may not contain three instances of the same item, unless the list contains exactly three items.
  9. The stringification of None is the lyrics of Rick Astley’s Never Gonna Give You Up.
  10. The only variable names are foo, bar, baz and single characters.

Examples

Hello, world!

print("Hello,"+" "+"world!")

Print the lyrics to Never Gonna Give You Up

print(None)

Unbounded integer class (since PBIT’s integers are only 32 bit, does not support negative numbers)

class I:
    self.v = [] #initial value 0
    def i(self): #increment
        return I(self+[[]])
    def d(self): #decrement
        return I(self[not 0:])