Shawn,
Please find some questions at the bottom.
On 05/17/11 09:15 PM, Shawn Walker wrote:
On 05/17/11 11:16 AM, Keith Mitchell wrote:
On 05/17/11 11:12 AM, William Schumann wrote:
Keith,
I have one preliminary question:

On 05/16/11 07:29 PM, Keith Mitchell wrote:
...
ns_info.py:
...
225: This dict should be statically defined.

265-276: Statically define this somewhere.
What you mean by 'statically', and why?

I guess "global" would be more precise. Or rather, at the module level.

As written, every time the function is called, the dictionary is
reconstructed; and since the objects seemed to be only read-from, never
written-to, it seemed like they should be defined at the module level,
instead of as locals.

That's not true. Lists, dictionaries, tuples, etc. that can be completely interpreted at compile time will be the same object every time:

#!/usr/bin/python2.6
def test():
        propdict = { 'key': 'value' }
        print "propdict id: %s" % id(propdict)
for i in range(3):
        test()

$ python /tmp/test.py
propdict id: 135258836
propdict id: 135258836
propdict id: 135258836

With that said, you're right that a dictionary like this may be more appropriately 
defined as a "constant" at the module level.
You're the third reviewer who has asserted this without explanation using terms that don't exist in Python (e.g., static, constant, feel, bikeshed ;) ). Please explain why it is more appropriate to define it at a module level. It is executed only once, read-only, only locally. Why should the maintainer of the code have to look elsewhere for the assignment of the dict (where it requires extra commenting because it appears completely out of context)?

Thank you,
William
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

Reply via email to