[Edu-sig] Design patterns

Kirby Urner urnerk at qwest.net
Wed Aug 24 18:33:57 CEST 2005


> I might be a dead horse who is dead wrong, but the issue about how
> properties fit into Python is certainly not straightforward in the least,
> and responding as if it were is grossly unfair - to the question raised.
> 
> Art

I think use cases were described, and demonstrated, in which the property
feature made sense, e.g. we wanted an attributes-based API into our triangle
object, but sometimes the results were computed on the fly.  Martelli shows
this same use case with a rectangle object (Python in a Nutshell, pg. 85).

As for using decorator syntax to define properties, Scott has shown how this
might be done.  However, this approach is entirely optional.

Python coders may flag private attributes and methods with _ and __, with
the latter causing name mangling based on class name:

>>> class Foo(object):
	def __hidden(self):
		pass
	
>>> dir(Foo)
['_Foo__hidden'...]



Kirby




More information about the Edu-sig mailing list