On Sat, Jan 12, 2002 at 11:36:33AM -0500, Tim Payne wrote:
> Since you guys brought it up, I was also wondering why WebKit uses this 
> style of importing (from module import object) over (import module)
> 
> I know that when you import the object(s) directly, you can use them 
> like foo() instead of module.foo(), but is there any other advantage? I 
> usually just import the module so that I don't get confused about where 
> everything is being loaded from.

It's a stylistic preference.  Why Chuck chose that style, you'd have to
ask him.  

I generally prefer the os.path.join() style, but when the module only
exists for a same-name class, I tend to use the "from module import
class" style.  

Occasionally, like with Pickle and cPickle, you have a choice of 
implementations of compatible objects.  In that case, it makes sense
to do "from cPickle import dump, load".  Then if you end up in a
situation where cPickle isn't available  (Jython, embedded systems,
etc), you just change "cPickle" to "Pickle" in that one line and
away yo go, rather than making changes all over the script.

-- 
-Mike (Iron) Orr, [EMAIL PROTECTED]  (if mail problems: [EMAIL PROTECTED])
   http://iron.cx/     English * Esperanto * Russkiy * Deutsch * Espan~ol

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to