Syntax
Terry Hancock
hancock at anansispaceworks.com
Sun Nov 27 01:05:28 EST 2005
On Sat, 26 Nov 2005 20:54:49 -0800
Robert Kern <robert.kern at gmail.com> wrote:
> calad.sigilon at gmail.com wrote:
> > So, two options:
> >
> > from os import *
> > import os
> > One of these two ways you're not supposed to use for
> > security reasons, but I'm spacing on which one.
>
> I don't think there are any *security* reasons, but
> stylistically, "import os" is greatly preferred. When
> someone else reads your code, they will immediately know
> where getcwd() comes from.
It's not a question of "security" in the usual sense, but
the first syntax imports a lot of stuff into the current
namespace, increasing the risk of unintentionally clobbering
local names. So it's certainly "riskier" in the sense of
"likely to cause bugs".
--
Terry Hancock (hancock at AnansiSpaceworks.com)
Anansi Spaceworks http://www.AnansiSpaceworks.com
More information about the Python-list
mailing list