[Tutor] "from this import *" or "import this"

Andrei Kulakov ak@silmarill.org
Mon, 03 Dec 2001 00:03:42 -0500

On Sun, Dec 02, 2001 at 05:01:43PM +0200, Jean Montambeault wrote:
>     Be ready for a whole lot of very newbie questions. I've never programmed
> before and do not intend to make a career out of what I am learning : pure
> amateurism here which does not necessarily implies triviality but that
> shouldn't be a surprise.
>     So :
>         is there a real use for the form "from this_module import * " since
>                 (a) there seems to be a real danger to get some functions or
> variables which would have the same name if more than one module are open
> that way
>                 (b) nothing shows the relation to the module which is to
> some extent documenting the program
>                 (c) it imports the whole module (I guess) just as "import
> this_module" seems to be doing
>         ?
>         Or is it much safer and wiser to avoid using it ?

Aside from all other things mentioned, from mod import * is useful in
the interactive interpreter. If you just started it up to check
something in 10 seconds, it'll save you time and isn't dangerous cause
you (hopefully) can remember what module you imported from for 10
seconds :-). If not, don't use it at all!

>         Thanks
>        Jean M.
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org