[Python-Dev] PEP 550 v4 (original) (raw)

David Mertz mertz at gnosis.cx
Sat Aug 26 15:12:02 EDT 2017


I'm convinced by the new section explaining why a single value is better than a namespace. Nonetheless, it would feel more "Pythonic" to me to create a property ContextVariable.val whose getter and setter was .lookup() and .set() (or maybe ._lookup() and ._set()).

Lookup might require a more complex call signature in rare cases, but the large majority of the time it would simply be var.val, and that should be the preferred API IMO. That provides a nice parallel between var.name and var.val also.

On Sat, Aug 26, 2017 at 11:22 AM, Barry Warsaw <barry at python.org> wrote:

On Aug 26, 2017, at 14:15, Yury Selivanov <yselivanov.ml at gmail.com> wrote: > > Elvis just added it: > https://www.python.org/dev/peps/pep-0550/#replication-of- threading-local-interface

Thanks, that’s exactly what I was looking for. Great summary of the issue. > >> That said, if we have to use method lookup, then I agree that .get() is a better choice than .lookup(). But in that case, would it be possible to add an optional default=None argument so that you can specify a marker object for a missing value? I worry that None might be a valid value in some cases, but that currently can’t be distinguished from “missing”. > > Nathaniel has a use case where he needs to know if the value is in the > topmost LC or not. > > One way to address that need is to have the following signature for lookup(): > > lookup(*, default=None, traverse=True) > > IMO "lookup" is a slightly better name in this particular context. Given that signature (which +1), I agree. You could add keywords for debugging lookup fairly easily too. Cheers, -Barry


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ mertz%40gnosis.cx

-- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170826/9df39797/attachment.html>



More information about the Python-Dev mailing list