Steven D'Aprano added the comment: Your example works because random is a module:
py> from types import ModuleType py> import random py> type(random) is ModuleType True Since random is an instance of ModuleType, your class M is a subclass of ModuleType, and assigning to random.__class__ is allowed. I'm closing this issue, but if can demonstrate an actual problem, please feel free to re-open it. ---------- nosy: +steven.daprano resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29794> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com