[Dev] Re: [commits] (alecf) [9424] use import instead of schema.ns when you can!

Alec Flett alecf at osafoundation.org
Wed Feb 8 16:09:28 PST 2006


Well for one, you don't introduce parcel-loading dependencies and 
side-effects

i.e.

startup = schema.ns('osaf.startup')
may have the side-effect of loading and installing the osaf.startup parcel

whereas

from osaf import startup
only loads the python code.

Further, there are dependency-analysis tools for python out there that 
don't know anything about schema.ns, but they know loads about import. 
They can be used to track down circular dependencies, allowing us to 
make our code more modular.

My take is this: use schema.ns() only when you're actually accessing 
data in that parcel - if you're just loading code use import

Alec

Morgen Sagen wrote:
> Not that I necessarily disagree, but why is one way preferable to the 
> other?
>
> On Feb 8, 2006, at 9:47 AM, commits at osafoundation.org wrote:
>
>> Revision 9424 Author alecf Date 2006-02-08 09:47:57 -0800 (Wed, 08 
>> Feb 2006) Log Message
>> use import instead of schema.ns when you can!
>
> The relevant change was:
>
> + from osaf import startup
> - startup = schema.ns("osaf.startup", parcel)
>
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "Dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/dev



More information about the Dev mailing list