Deferred to Python 2.1

This commit is contained in:
Barry Warsaw 2000-08-23 05:47:12 +00:00
parent 211538dfe9
commit 08414d30a6
1 changed files with 15 additions and 4 deletions

View File

@ -1,9 +1,12 @@
PEP: 213 PEP: 213
Title: Attribute Access Handlers Title: Attribute Access Handlers
Version: $Revision$ Version: $Revision$
Owner: paul@prescod.net (Paul Prescod) Author: paul@prescod.net (Paul Prescod)
Python-Version: 2.0 Status: Draft
Status: Incomplete Type: Standards Track
Python-Version: 2.1
Created: 21-Jul-2000
Post-History:
Introduction Introduction
@ -19,6 +22,7 @@ Introduction
This PEP describes a feature that makes it easier, more efficient This PEP describes a feature that makes it easier, more efficient
and safer to implement these handlers for Python instances. and safer to implement these handlers for Python instances.
Justification Justification
Scenario 1: Scenario 1:
@ -50,6 +54,7 @@ Justification
for whatever purpose. Again, this is not a new feature but for whatever purpose. Again, this is not a new feature but
merely a new syntax for an existing convention. merely a new syntax for an existing convention.
Current Solution Current Solution
To make some attributes read-only: To make some attributes read-only:
@ -85,6 +90,7 @@ Current Solution
mitigated through an extra level of method call but this is mitigated through an extra level of method call but this is
inefficient. inefficient.
Proposed Syntax Proposed Syntax
Special methods should declare themselves with declarations of the Special methods should declare themselves with declarations of the
@ -105,7 +111,8 @@ Proposed Syntax
x.foo=fooval+5 x.foo=fooval+5
del x.foo del x.foo
Semantics
Semantics
Attribute references of all three kinds should call the method. Attribute references of all three kinds should call the method.
The op parameter can be "get"/"set"/"del". Of course this string The op parameter can be "get"/"set"/"del". Of course this string
@ -125,6 +132,7 @@ Proposed Syntax
opposite choice seems fairly feasible also, however. The same opposite choice seems fairly feasible also, however. The same
goes for __del_y__. goes for __del_y__.
Proposed Implementation Proposed Implementation
There is a new object type called an attribute access handler. There is a new object type called an attribute access handler.
@ -169,6 +177,7 @@ Proposed Implementation
The implementation of delete is analogous to the implementation The implementation of delete is analogous to the implementation
of set. of set.
Caveats Caveats
1. You might note that I have not proposed any logic to keep 1. You might note that I have not proposed any logic to keep
@ -199,6 +208,8 @@ Caveats
on the object itself can cause an infinite loop (as with __getattr__) on the object itself can cause an infinite loop (as with __getattr__)
Once again, the solution is to use a special (typically private) Once again, the solution is to use a special (typically private)
variable such as __XXX. variable such as __XXX.
Local Variables: Local Variables:
mode: indented-text mode: indented-text