[Python-Dev] A Desperate Plea For Introspection (aka: BDFAP Needed) (original) (raw)
Yury Selivanov yselivanov.ml at gmail.com
Fri Jun 22 22:48:59 CEST 2012
- Previous message: [Python-Dev] A Desperate Plea For Introspection (aka: BDFAP Needed)
- Next message: [Python-Dev] A Desperate Plea For Introspection (aka: BDFAP Needed)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 2012-06-22, at 3:25 PM, Christian Heimes wrote:
Am 22.06.2012 21:10, schrieb Yury Selivanov:
I think that if a function lacks an annotation, that should be reflected in the same way for its signature.
Currently: if hasattr(signature, 'returnannotation'): If we use Signature.empty: if signature.returnannotation is not signature.empty: So (in my humble opinion) it doesn't simplify things too much. And also you can use 'try .. except AttributeError .. else' blocks, which make code even more readable. The second form has two benefits: * you get a sensible error message when you mistype the name of the attribute. hasattr(signature, 'returnannotatoin') is clearly an error, hard to notice with the naked eye and passes silently. * modern Python IDEs have code completion. "signature.re is not signature.em" safes key strokes.
Agree on both.
This change also cut 20 lines from the implementation. So I guess it is a good decision after all ;)
- Yury
- Previous message: [Python-Dev] A Desperate Plea For Introspection (aka: BDFAP Needed)
- Next message: [Python-Dev] A Desperate Plea For Introspection (aka: BDFAP Needed)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]