A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2007-February/071069.html below:

[Python-Dev] New syntax for 'dynamic' attribute access

[Python-Dev] New syntax for 'dynamic' attribute access [Python-Dev] New syntax for 'dynamic' attribute accessCollin Winter collinw at gmail.com
Tue Feb 13 22:46:41 CET 2007
On 2/13/07, Nick Coghlan <ncoghlan at gmail.com> wrote:
[snip]
> I've tried this out on Brett's urllib & urllib2 examples below. (calling
> the new builtin attrview() to emphasise the fact that it retains a
> reference to the original instance). I don't consider it any uglier than
> the proposed syntax changes, and it provides a few other benefits:
>
>    - the two-argument form is naturally available as the .get() method
> on the resulting dict-like object (e.g. "attrview(obj).get(some_attr,
> None)")
>
>    - hasattr() is naturally replaced by containment testing (e.g.
> "some_attr in attrview(obj)")
>
>    - keywords/builtins are easier to look up in the documentation than
> symbolic syntax
>
> With this approach, performance would be attained by arranging to create
> the view objects once, and then performing multiple dynamic attribute
> accesses using those view objects.

This changes my vote: +1 on including attrview(), -1 on the syntax proposal.

Collin Winter
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4