> No, the above code should work with classinstance.leds. Maybe you are > confusing __setattr__ - which affects attributes like .leds - with > __setitem__ which is used for classinstance['leds'] Ah, yes. You hit the hail on the nead there, Kent. Thanks for clarifying that for me. > >> >> Is this properties method acceptable Python form or is it more proper >> to have modifying member functions like Alan said? > > Alan and I don't always agree on questions like this. I don't take > such a hard position about direct attribute access. IMO using a > property is more Pythonic than making an explicit method. But I think > one of the nice things about Python is you don't have to write > explicit getters and setters; you can use plain attribute access to > get at plain data, then if you need to add some behaviour just change > the attribute to a property. I can see how some people might be surprised to know that changing classinstance.leds automagically sends a communication packet to the wii remote without their knowledge, but if they're aware of the side-effect, it seems to be a more elegant way of doing things to me (with properties vs. an explicit method), at least in this case. > >> Or is it really up to me on how I want to implement it? > > Of course, it's your code, right? Yes, but it's code I plan on open-sourcing, so I'm trying to make it clear what's happening in case I get other developers to help in the future.
-Luke _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor