[Patches] [ python-Patches-480562 ] replace __slots__ with addmembers
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 04 Dec 2001 11:12:59 -0800
Patches item #480562, was opened at 2001-11-11 01:53
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=480562&group_id=5470
Category: Core (C code)
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Michael McLay (mclay)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: replace __slots__ with addmembers
Initial Comment:
This patch replaces the __slots__ syntax in the
following example:
>>> class B(object):
"""class B's docstring
"""
__slots__ = ['a','b','c','d']
The new syntax includes support for docstrings, default
values, and optional typechecking (using isinstance).
>>> class B(object):
"""class B's docstring
"""
a = addmember(types=int, default=56, doc="a
docstring")
b = addmember(types=int, doc="b's docstring")
c = addmember(types=(int,float), default=5.0,
doc="c docstring")
d = addmember(types=(str,float), default="ham",
doc="d docstring")
>>> b = B()
>>> b.a
56
>>> b.d
'ham'
>>> b.b
Traceback (most recent call last):
File "<pyshell#8>", line 1, in ?
b.b
TypeError: The value of B.b is of type 'type'. This is
not one of the defined types
The addmembers.txt file in the attachment describes the
patch in more detail.
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-04 11:12
Message:
Logged In: YES
user_id=6380
I appreciate the work that went into this, but I'm rejecting
it anyway. I want to come up with a better syntax for
creating slots (and lots of other new 2.2 features) later,
but I don't want to hurry into this for 2.2, and I'm
positive that by the time I'll be ready, this patch will be
too outdated to apply.
----------------------------------------------------------------------
Comment By: Michael McLay (mclay)
Date: 2001-11-11 02:21
Message:
Logged In: YES
user_id=28214
Opps, forgot to check the box for the attachment.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=480562&group_id=5470