On Wed, Nov 15, 2017 at 10:14 PM, Nathaniel Smith <n...@pobox.com> wrote: > On Wed, Nov 15, 2017 at 4:27 PM, Ethan Furman <et...@stoneleaf.us> wrote: >> The second way is fairly similar, but instead of replacing the entire >> sys.modules entry, its class is updated to be the class just created -- >> something like sys.modules['mymod'].__class__ = MyNewClass . >> >> My request: Can someone write a better example of the second method? And >> include __getattr__ ?
Doh, I forgot to permalinkify those. Better links for anyone reading this in the future: > Here's a fairly straightforward example: > > https://github.com/python-trio/trio/blob/master/trio/_deprecate.py#L114-L140 https://github.com/python-trio/trio/blob/3edfafeedef4071646a9015e28be01f83dc02f94/trio/_deprecate.py#L114-L140 > (Intentionally doesn't include __dir__ because I didn't want > deprecated attributes to show up in tab completion. For other use > cases like lazy imports, you would implement __dir__ too.) > > Example usage: > > https://github.com/python-trio/trio/blob/master/trio/__init__.py#L66-L98 https://github.com/python-trio/trio/blob/3edfafeedef4071646a9015e28be01f83dc02f94/trio/__init__.py#L66-L98 > -n > > -- > Nathaniel J. Smith -- https://vorpus.org -- Nathaniel J. Smith -- https://vorpus.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com