Cannot import a module from a variable
Gabriel Genellina
gagsl-py at yahoo.com.ar
Wed Oct 18 22:25:51 EDT 2006
At Wednesday 18/10/2006 22:51, Cameron Walsh wrote:
> previous_directory = os.getcwd()
> try:
> os.chdir(directory)
> [ ... ]
> return modules
> finally:
> os.chdir(previous_directory)
>
>Woah, that actually works? Having the "finally" after the "return"?
>That could make some things easier, and some things harder...
Note that moving the return statement after the finally does
*exactly* the same thing, generates shorter code, and is a lot more
readable (IMHO).
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas
More information about the Python-list
mailing list