--==========1714979620========== Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline --On Sunday, February 02, 2003 10:56:29 +1300 Andrew McGregor=20 <andrew@indranet.co.nz> wrote: > Then: > > defmacro property(name, docstring, @get, @set, @delete): > def getter interpolate(get.arglist): > interpolate(get.block) > def setter interpolate(set.arglist): > interpolate(set.block) > def deleter interpolate(delete.arglist): > interpolate(delete.block) > return: > name =3D property(docstring, getter, setter, deleter) > > class Circle(object): > property circumference, """Circumference of the circle""": > get (self): > return self.radius*6.283 > set (self, value): > self.radius =3D value/6.283 > delete (self): > del self.radius > > would do the obvious thing using block keyword arguments (I can't think > how to express the anonymous scope implied here in regular Python; the > intention is that getter and friends are defined in the local namespace > of the macro invocation). > > Of course the proposed syntax is hypothetical, but I think it's quite > clean. Hmmm, maybe that should have been: defmacro property(name, docstring, @block): block() return: name =3D property(docstring, get, set, delete) class Circle(object): property(circumference, """Circumference of the circle"""): def get(self): return self.radius*6.283 def set(self, value): self.radius =3D value/6.283 def delete(self): del self.radius I still think block keyword arguments would be nice, but this can be done=20 without them. Andrew --==========1714979620========== Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (GNU/Linux) iD8DBQE+PIamHamGxvX4LwIRAjRXAKDOTgODINE1C6mxdLRb5qAeJf1w1ACg5AHZ OxiObNlVxp8SXUnOIb35AOE= =mjDP -----END PGP SIGNATURE----- --==========1714979620==========--
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4