Style question: Nicknames for deeply nested objects
Jean-Michel Pichavant
jeanmichel at sequans.com
Mon Jan 31 06:15:13 EST 2011
Gerald Britton wrote:
> Hi all,
>
> Today I was thinking about a problem I often encounter.
> [snip]
>
> 1. You need to call this thing many times with different arguments, so
> you wind up with:
>
> x = some.deeply.nested.object.method(some.other.deeply.nested.object.value1)
> y = some.deeply.nested.object.method(some.other.deeply.nested.object.value2)
> z = some.deeply.nested.object.method(some.other.deeply.nested.object.value3)
> [snip]
> --
> Gerald Britton
>
This is not solved by style but by design.
You simply don't use too much nested objects. That's a sign of something
wrong in your overall object model.
Since I do not encounter this problem as often as you are, I guess it is
a matter of habbits.
however, considering what
"import a.module.that.is.quite.nested as myModule"
is doing, I guess using a local variable to store your nested method is
just fine.
JM
More information about the Python-list
mailing list