[Python-Dev] Extended Function syntax
Wiktor Sadowski
Wiktor Sadowski" <art@wiktorsadowski.com
Wed, 29 Jan 2003 07:54:25 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_00DC_01C2C76B.A4AB19E0
Content-Type: text/plain;
charset="windows-1250"
Content-Transfer-Encoding: quoted-printable
>It's a bad idea to have to go through all the motions of defining the
>property on each object creation.
Sorry for typo(no def),should be:
class Foo(object):
__init__(class): #class section
class.v =3D []
class.myprop:
"""A computed property on Foo objects."""
def __get__(class_instance):
return ...
def __set__(class_instance):
...
def __delete__(class_instance):=20
...
def class_method(class,a,b):
................
w.s.
------=_NextPart_000_00DC_01C2C76B.A4AB19E0
Content-Type: text/html;
charset="windows-1250"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1250">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>>It's a bad idea to have to go through all the motions of =
defining=20
the<BR>>property on each object creation.</DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV>Sorry for typo(no def),should be:</DIV>
<DIV><FONT face=3DArial size=3D2></FONT><BR></DIV>
<DIV>class Foo(object):<BR> =20
__init__(class): #class=20
section<BR> &n=
bsp; =20
class.v =3D=20
[]<BR> &=
nbsp;=20
class.myprop:<BR> &n=
bsp; =20
"""A computed property on Foo=20
objects."""<BR> &nbs=
p; =20
def=20
__get__(class_instance):<BR> &nb=
sp; &nbs=
p; =20
return=20
...<BR> =
=20
def=20
__set__(class_instance):<BR> &nb=
sp; &nbs=
p; =20
...<BR> =
=20
def __delete__(class_instance): </DIV>
<DIV> &n=
bsp; =20
...<BR> =
=20
def class_method(class,a,b):</DIV>
<DIV> &n=
bsp; =20
................</DIV>
<DIV> </DIV>
<DIV><FONT face=3D"Times New Roman">w.s.</FONT></DIV>
<DIV><BR><BR></DIV></BODY></HTML>
------=_NextPart_000_00DC_01C2C76B.A4AB19E0--