Elektrine lite

← Feed

@ambv@mastodon.social

2026-08-01 06:46 UTC

@treyhunner@mastodon.social exceptions used to be strings. You would do stuff like: raise "Bad argument" This was only disabled in Python 2.6. Built-in exceptions were simply interned strings, and so to this day you can raise classes, like: raise KeyError That's because it used to just be a variable with a string value.

Replies (1)

  • @treyhunner@mastodon.social 2026-08-01 15:29

    @ambv@mastodon.social I now vaguely remember seeing raise "string" years ago, but never thought about the significance of that. I did not know that this is the reason raising an exception class works!

    Open ##5019060