import sys.argv[1] 
Author Message
 import sys.argv[1]

Hi all,

this must have been a situation that lots of people have  come across
so there has to be a work around for it. If I define via a command
line arg what module(s) needs to be imported how do i then pass this
to the import statement without the import statement taking

sys.argv[1]

literally?

Thanks

Ben



Fri, 28 Nov 2003 15:15:30 GMT  
 import sys.argv[1]
look source code:
       # so something
       str = "import  mySuperModul"
       exec( str ) # executes a complete individual command

or

mod = __import__("mySuperModul")

func  = getattr(mod, "myFunc_in_SuperModul") #

func( 1, 2 ,3 ....)

i hope it helps



Quote:
> Hi all,

> this must have been a situation that lots of people have  come across
> so there has to be a work around for it. If I define via a command
> line arg what module(s) needs to be imported how do i then pass this
> to the import statement without the import statement taking

> sys.argv[1]

> literally?

> Thanks

> Ben



Fri, 28 Nov 2003 17:16:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Chosing between sys.argv and sys.stdin

2. understanding sys.argv[]

3. sys module - argv, but no argc ??

4. sys.argv and while loop

5. sys.argv not found

6. catch empty sys.argv

7. sys.argv in Python 2.0 does not work?

8. ?sys.argv values more literally?

9. Win32 problems: Popen3 and sys.argv[0]

10. Sys.argv

11. sys.argv attribute error

12. Specifiying a module from sys.argv?

 

 
Powered by phpBB® Forum Software