[Python-Dev] PEP 553: Built-in debug()
Christian Heimes
christian at python.org
Thu Sep 7 13:00:52 EDT 2017
On 2017-09-07 09:50, Barry Warsaw wrote:
> On Sep 6, 2017, at 23:10, Terry Reedy <tjreedy at udel.edu> wrote:
>>
>> Environmental variables are set to strings, not objects. It is not clear how you intend to handle the conversion.
>
> The environment variable names a module import path. Without quibbling about the details of the syntax (because honestly, I’m not convinced it’s a useful feature), it would work roughly like:
>
> * The default value is equivalent to PYTHONBREAKPOINTHOOK=pdb.set_trace
> * breakpoint() splits the value on the rightmost dot
> * modules on the LHS are imported, then the RHS is getattr’d out of that
> * That’s the callable breakpoint() calls
Setuptools' entry points [1] use colon between import and function, e.g.
"pdb:set_trace" would import pdb and then execute set_trace. The
approach can be augmented to allow calling a class method, too.
So
"package.module:myclass.classfunc"
would do :
from package.module import myclass
myclass.classfunc
Regards,
Christian
[1]
https://setuptools.readthedocs.io/en/latest/setuptools.html#automatic-script-creation
More information about the Python-Dev
mailing list