Code Snippets
Ben Bacarisse
ben.usenet at bsb.me.uk
Wed Nov 1 17:02:46 EDT 2017
ram at zedat.fu-berlin.de (Stefan Ram) writes:
> Wolfgang Maier <wolfgang.maier at biologie.uni-freiburg.de> writes:
>>If you're worried bout having things on separate lines, you could write:
>>import os; os.getcwd()
>>,etc., which is actually saving a few characters :)
>
> Yes, but there still is the risk of the identifier »os«
> already being used in the sorrounding code. While
>
> __import__( "os" ).getcwd()
>
> does not seem to "leak" names into the enclosing scope.
Also it's an expression which may be important in your "quick and dirty"
scripts.
--
Ben.
More information about the Python-list
mailing list