@decorator syntax is sugar, but for what exactly?
Mark Bottjer
mark_bottjer at hotmail.com
Wed Aug 11 14:05:40 EDT 2004
Avner Ben wrote:
> Properties do not look like functions but are implemented as functions.
> there is no requirement that a variable must hide behind a property, or
> that it Must allow both read and write access.
Agreed. I was providing what I thought might be a common case. The fact
that properties can distill functionality into something that looks like
a variable is partly why they're so powerful.
>> [Ship] property a:
>> def __init__( s, v):
>> __set__( s, v)
>
> Why property constructor?
Why not? It's as good a way as any to give a variable-backed property an
initial value. Setting it directly would break the encapsulation of the
property.
> I recall reading somewhere That the Beta language allowed subclassing
> anything
Yep. Because Beta has no classes, but rather works on a prototype
system. Everything is an object. The "class" of an object is the
interface it supports at that particular time. To create a new object,
clone an existing one, and modify it to taste.
Seriously powerful. Seriously hard to keep track of. Neat language.
-- Mark
More information about the Python-list
mailing list