Syntax

Robert Kern robert.kern at gmail.com
Sat Nov 26 23:54:49 EST 2005


calad.sigilon at gmail.com wrote:
> If you use 'from os import *' then you shouldn't preface the commands
> with os.
> 
> So, two options:
> 
> from os import *
> print "Working Path: %s" % getcwd()
> 
> OR
> 
> import os
> print "Working Path: %s" % os.getcwd()
> 
> 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.

-- 
Robert Kern
robert.kern at gmail.com

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list