Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Alan Gauld
"bob gailer" <[EMAIL PROTECTED]> wrote > modname = raw_input() > exec "import " + modname > > That can be a security risk, in that a use could > enter "time; import os; os.rmdir('some_valuable_directory')" Even more risky is the fact that modules can contain executable code that is run when t

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Remco Gerlich
The input() function calls eval() on the value you give it. Eval() can evaluate any _expression_. That's generally insecure and not recommended - people could type in anything, as you're trying to do :-) But anyway, that is why 'import ...' directly doesn't work, import is a statement, not an expr

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread bob gailer
Mihai Iacob wrote: Hello, I was wondering if there is a way to import modules using the input() command. If i try to do it directly it gives me an error: input() import time The input function takes a character string and attempts to

Re: [Tutor] How to import modules using the input() command

2007-11-15 Thread Kent Johnson
Mihai Iacob wrote: > Hello, > > I was wondering if there is a way to import modules > using the input() command. If i try to do it directly > it gives me an error: > input() > import time > > Traceback (most recent call last): > File "", line 1, in > input() > File "", line 1 >

[Tutor] How to import modules using the input() command

2007-11-15 Thread Mihai Iacob
Hello, I was wondering if there is a way to import modules using the input() command. If i try to do it directly it gives me an error: >>> input() import time Traceback (most recent call last): File "", line 1, in input() File "", line 1 import time ^ SyntaxError: invalid s