[Patches] [ python-Patches-480562 ] replace __slots__ with addmembers
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 11 Nov 2001 02:21:52 -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: Open
Resolution: None
Priority: 5
Submitted By: Michael McLay (mclay)
Assigned to: Nobody/Anonymous (nobody)
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: 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