[Python-Dev] PEP 414 updated (original) (raw)
Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Sun Mar 4 13:25:06 CET 2012
- Previous message: [Python-Dev] PEP 414 updated
- Next message: [Python-Dev] PEP 414 updated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03/04/2012 10:34 AM, Vinay Sajip wrote:
import uprefix; uprefix.registerhook() 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
- Previous message: [Python-Dev] PEP 414 updated
- Next message: [Python-Dev] PEP 414 updated
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]