On 03/04/2012 10:34 AM, Vinay Sajip wrote: > https://bitbucket.org/vinay.sajip/uprefix/
>>>> import uprefix; uprefix.register_hook() >>>> import frob.subwob.subsubwob >>>> frob.subwob.subsubwob.w Hi, it's pretty cool that 150 lines is enough to have this functionality. This guard: if sys.version_info[0] < 3: raise NotImplementedError('This hook is implemented for Python 3 only') Wouldn't it be better if the hook did nothing when on python 2? I think it'll make it necessary to use something like import sys if sys.version_info[0] < 3: import uprefix uprefix.register_hook() in the calling code to enable the code to run unchanged on both branches. Also: have you though about providing a context manager which does register_hook() in __enter__() and unregister_hook() in __exit__()? I think that some code will want to enable the hook only for specific modules. The number of lines could be minimized with something like this: import uprefix with uprefix.hook: import abcde_with_u import bcdef_with_u import other_module_without_u Regards, Zbyszek _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com