python - raise ConnectionError in python2.7 -


i want raise connectionerror (a python 3 subclass) when program fails connect local service. i'm using python2.7. testing out though, looks have import module working:

>>> raise connectionerror("test") traceback (most recent call last):   file "<stdin>", line 1, in <module> nameerror: name 'connectionerror' not defined 

how can raise type of exception?

connectionerror not exist in python 2, can see the python 2 documentation. can of course create own subclass of oserror (and call connectionerror if want), no such thing built in.


Comments

Popular posts from this blog

how to do line continuation in perl debugger for entering raw multi-line text (EOT)? -

javascript - Create websocket without connecting -

sharepoint - Accessing files across a shared directory using a Windows service -