Ridley5 opened this issue on Jul 26, 2010 · 1724 posts
bagginsbill posted Fri, 20 August 2010 at 10:12 PM
Quote - Coding-style for dictionaries should be parameter.get("Camera",
)
To be able to catch undefined/broken parameters and avoid program interruption etc. just because something couldn't be found. As it would if you're using attributes.
You should read about getattr
Quote -
How do you find out which parameters are available with an object? Something like dict.keys() for objects?
If key in obj.dict
or
for key in obj.dict.keys
But I would not do either of those things.
I'd write a method that hides such details.
Quote -
There is not more typing. Each line can be copied. Just the keywords have to be changed.
Yes there is more typing. I don't understand what you are saying here.
Quote -
Simple iteration over a parameter dictionary where possible if an entry would carry his own output-format (there are just a few) and his default value to fallback in case of errors. Even an object able to output what it stores in the right format.
An object has a dictionary inside it. You're just not aware of how to use objects to wrap them.
There is much more to objects than you know.
Did you ever wonder why inheritance works? How does an object inherit values?
Inheritance is just another word for how a default value is supplied when a value is not specified in a dictionary.
Object inheritance is a fabulous way to specify implied default values. Much better than
x.get(key, default)
This is stupid. It means that the caller must decide the default value. The caller has no business knowing this.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)