[Zope-dev] Coding style clarifications

Jim Fulton jim at zope.com
Fri Feb 20 07:14:12 EST 2009


On Feb 19, 2009, at 4:07 PM, Shane Hathaway wrote:

> Fred Drake wrote:
>> On Thu, Feb 19, 2009 at 11:03 AM, Jim Fulton <jim at zope.com> wrote:
>>> BTW, I strongly discourage from imports. (I didn't always have this
>>> opinion, but have seen the error of my ways. Thanks to Fred Drake  
>>> for
>>> nudging me in this direction.) IMO, this is wildly more important  
>>> than
>>> any of the issues raised in this thread.
>>
>> You're welcome.  :-)
>
> You're saying that:
>
>     import zope.interface.Interface
>
>     class IFoo(zope.interface.Interface):
>         ...
>
> is better than:
>
>     from zope.interface import Interface
>
>     class IFoo(Interface):
>         ...


This is an interesting case.  This could make a good exception to the  
rule.  Interface is so commonly used, at least within the zope  
community it really wants to be a builtin, like list or tuple.  Most  
names are not nearly as common.

Even with this example, which I consider atypical, I think there are a  
couple of interesting things to note:

1. While Interface is well known to us, it isn't well known to other  
possible readers of the code.  When working on a project, certain  
names are very will known to me and don't seem to benefit from  
qualification, however, when I leave a project and come back to it  
much later, I appreciate the qualification that makes interpreting the  
no-longer familiar names much easier.

2. Depending on what code you might unearth, Interface could be either  
zope.interface.Interface, or the older version Interface.Interface.   
Package qualification makes this unambiguous.

Jim

--
Jim Fulton
Zope Corporation




More information about the Zope-Dev mailing list