1

To my surprise, I learned a few months ago that

class MyException(Exception):
    ...

is valid Python. It is surprisingly difficult to find references to the "..." syntax in the Python Language Reference so I have had a lot of difficulty understanding the exact difference between the above syntax and

class MyException(Exception):
    pass

Is there a difference between the snippets above? Where is the first syntax ... documented?

martineau
  • 119,623
  • 25
  • 170
  • 301
Andrew F
  • 2,690
  • 1
  • 14
  • 25
  • 3
    For starters, pass is a keyword and elipses is an actual object. Conventionally, `pass` is used when no code is meant to be present somewhere. And elipses (although rarely seen in my experience) are used for a WIP. – Brian Jan 06 '20 at 15:40
  • You can substitute `pass` for any other expression that simply doesn't produce any result, e.g. `None`. `pass` just explicitly does absolutely nothing and is only there as a syntactic placeholder. – deceze Jan 06 '20 at 15:40

0 Answers0