Size: a a a

Сообщество Python Программистов

2020 August 02

CJ

Corny Jenefier in Сообщество Python Программистов
Georold of America🇺🇸
Evaluated expression:
return Exception
Return value:
<class 'Exception'>
Мастер йода
источник

YC

Yung Cherry in Сообщество Python Программистов
да вот же
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Language:
py3


Source:
def get_subclasses(cls):
   for chld in cls.__subclasses__():
       yield chld
       yield from get_subclasses(chld)

for e in get_subclasses(Exception):
   print("{}: {}\n".format(e.__name__, e.__doc__))


Result:
TypeError: Inappropriate argument type.

StopAsyncIteration: Signal the end from iterator.__anext__().

StopIteration: Signal the end from iterator.__next__().

ImportError: Import can't find module, or can't find name in module.

ModuleNotFoundError: Module not found.

ZipImportError: None

OSError: Base class for I/O related errors.

ConnectionError: Connection error.

BrokenPipeError: Broken pipe.

ConnectionAbortedError: Connection aborted.

ConnectionRefusedError: Connection refused.

ConnectionResetError: Connection reset.

BlockingIOError: I/O operation would block.

ChildProcessError: Child process error.

FileExistsError: File already exists.

FileNotFoundError: File not found.

IsADirectoryError: Operation doesn't work on directories.

NotADirectoryError: Operation only works on directories.

InterruptedError: Interrupted by signal.

PermissionError: Not enough permissions.

ProcessLookupError: Process not found.

TimeoutError: Timeout expired.

UnsupportedOperation: None

ItimerError: None

EOFError: Read beyond end of file.

RuntimeError: Unspecified run-time error.

RecursionError: Recursion limit exceeded.

NotImplementedError: Method or function hasn't been implemented yet.

_DeadlockError: None

NameError: Name not found globally.

UnboundLocalError: Local name referenced but not bound to a value.

AttributeError: Attribute not found.

SyntaxError: Invalid syntax.

IndentationError: Improper indentation.

TabError: Improper mixture of spaces and tabs.

LookupError: Base class for lookup errors.

IndexError: Sequence index out of range.

KeyError: Mapping key not found.

CodecRegistryError: None

ValueError: Inappropriate argument value (of correct type).

UnicodeError: Unicode related error.

UnicodeEncodeError: Unicode encoding error.

UnicodeDecodeError: Unicode decoding error.

UnicodeTranslateError: Unicode translation error.

UnsupportedOperation: None

AssertionError: Assertion failed.

ArithmeticError: Base class for arithmetic errors.

FloatingPointError: Floating point operation failed.

OverflowError: Result too large to be represented.

ZeroDivisionError: Second argument to a division or modulo operation was zero.

SystemError: Internal error in the Python interpreter.

Please report this to the Python maintainer, along with the traceback,
the Python version, and the hardware/OS platform and version.

CodecRegistryError: None

ReferenceError: Weak ref proxy used after referent went away.

BufferError: Buffer error.

MemoryError: Out of memory.

Warning: Base class for warning categories.

UserWarning: Base class for warnings generated by user code.

DeprecationWarning: Base class for warnings about deprecated features.

PendingDeprecationWarning: Base class for warnings about features which will be deprecated
in the future.

SyntaxWarning: Base class for warnings about dubious syntax.

RuntimeWarning: Base class for warnings about dubious runtime behavior.

FutureWarning: Base class for warnings about constructs that will change semantically
in the future.

ImportWarning: Base class for warnings about probable mistakes in module imports

UnicodeWarning: Base class for warnings about Unicode related problems, mostly
related to conversion problems.

BytesWarning: Base class for warnings about bytes and buffer related problems, mostly
related to conversion from str or comparing to str.

ResourceWarning: Base class for warnings about resource usage.

Error: None
источник

Go

Georold of America🇺🇸... in Сообщество Python Программистов
удали
источник

YC

Yung Cherry in Сообщество Python Программистов
источник

Go

Georold of America🇺🇸... in Сообщество Python Программистов
Evaluated expression:
return str(Exception)
Return value:
<class 'Exception'>
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Не, это самая мякотка
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Рекурсивно получает всех чилдов
источник

Go

Georold of America🇺🇸... in Сообщество Python Программистов
пфф
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Yung Cherry
Какие по канону вызывать исключения, к примеру, если в считываемом файле некорректная запись
Language:
py3


Source:
class IncorrectFileError(Exception):
   pass

raise IncorrectFileError("File have incorrect format")


Errors:
Traceback (most recent call last):
 File "175105677/source.py", line 4, in <module>
   raise IncorrectFileError("File have incorrect format")
__main__.IncorrectFileError: File have incorrect format
источник

Go

Georold of America🇺🇸... in Сообщество Python Программистов
слишком длинное
источник

YC

Yung Cherry in Сообщество Python Программистов
источник

YC

Yung Cherry in Сообщество Python Программистов
во как
источник

YC

Yung Cherry in Сообщество Python Программистов
норм?
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Yung Cherry
норм?
Выше смотри пример с кастомных ошибки
источник

CJ

Corny Jenefier in Сообщество Python Программистов
Georold of America🇺🇸
Evaluated expression:
return str(Exception)
Return value:
<class 'Exception'>
Решил второй раз попробовать объект вернуть?
источник

CJ

Corny Jenefier in Сообщество Python Программистов
Первого не хватило ?
источник

Go

Georold of America🇺🇸... in Сообщество Python Программистов
Corny Jenefier
Решил второй раз попробовать объект вернуть?
как строку)
источник

YC

Yung Cherry in Сообщество Python Программистов
Бензофуран Гетероцикл
Language:
py3


Source:
class IncorrectFileError(Exception):
   pass

raise IncorrectFileError("File have incorrect format")


Errors:
Traceback (most recent call last):
 File "175105677/source.py", line 4, in <module>
   raise IncorrectFileError("File have incorrect format")
__main__.IncorrectFileError: File have incorrect format
да зачем мне лишний класс
источник

БГ

Бензофуран Гетероцик... in Сообщество Python Программистов
Бензофуран Гетероцикл
Language:
py3


Source:
class IncorrectFileError(Exception):
   pass

raise IncorrectFileError("File have incorrect format")


Errors:
Traceback (most recent call last):
 File "175105677/source.py", line 4, in <module>
   raise IncorrectFileError("File have incorrect format")
__main__.IncorrectFileError: File have incorrect format
Вопрос к просвещённым @borntohack @k4m454k
Как убрать подпись __main__.?
источник