Re: I want to lirn pithon but pithon doesn't want me to do so
@54
If you'd like an example of properties, look into [OpenAL PyLite], alot of the classes use them. Though there are a few applications, lets say you want to get and set the volume of a given sound, you can use two functions for getting and setting the sound individually. A property descriptor though would give you a single keyword you can call with both functions for getting and setting said volume.
class Player(object):
...
#set volume - 1.0 float range only
def _set_volume(self,vol):
self._volume = vol
al.alSourcef(self.source, al.AL_GAIN, vol)
def _get_volume(self): return self._volume ... volume = property(_get_volume, _set_volume,doc="""get/set volume""")
As illustrated in the above segment, instead of having to call _get_volume() or _set_volume(), I can just call the descriptor "Player.volume" to get the current volume, or pass it a value like "Player.volume = 0.5" to set the volume. There's more on such descriptors [here], but you may not find much use for it in most applications.
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector