import file without .py into another module

2014-01-21 Thread kevinbercaw
I have a python script that accepts two arguments: sys.argv[1] is the full directory path to a config script. The script is python but does not have a .py extension! sys.argv[2] is the file name of the config script For example: mainScript.py ./ a15800 The config script sets variables that I

Re: import file without .py into another module

2014-01-21 Thread MRAB
On 2014-01-21 14:44, kevinber...@gmail.com wrote: I have a python script that accepts two arguments: sys.argv[1] is the full directory path to a config script. The script is python but does not have a .py extension! sys.argv[2] is the file name of the config script For example: mainScript.py

Re: import file without .py into another module

2014-01-21 Thread kevinbercaw
On Tuesday, January 21, 2014 10:06:16 AM UTC-5, MRAB wrote: On 2014-01-21 14:44, wrote: I have a python script that accepts two arguments: sys.argv[1] is the full directory path to a config script. The script is python but does not have a .py extension! sys.argv[2] is the file

Re: import file without .py into another module

2014-01-21 Thread kevinbercaw
On Tuesday, January 21, 2014 9:44:13 AM UTC-5, kevin...@gmail.com wrote: I have a python script that accepts two arguments: sys.argv[1] is the full directory path to a config script. The script is python but does not have a .py extension! sys.argv[2] is the file name of the config script

Re: import file without .py into another module

2014-01-21 Thread Peter Otten
kevinber...@gmail.com wrote: How do I get the value of the config file variable myVar?? It seems it's interpreting the variable name as a string rather than a variable name. I don't see any python function stringToVariable. The line: configModuleObject =

Re: import file without .py into another module

2014-01-21 Thread Tim Chase
On 2014-01-21 07:13, kevinber...@gmail.com wrote: On Tuesday, January 21, 2014 10:06:16 AM UTC-5, MRAB wrote: configModuleObject = imp.load_source(fileName, filePath) imports the module and then binds it to the name configModuleObject, therefore: print configModuleObject.myVar

Re: import file without .py into another module

2014-01-21 Thread kevinbercaw
On Tuesday, January 21, 2014 10:40:09 AM UTC-5, Peter Otten wrote: kevin...@gmail.com wrote: How do I get the value of the config file variable myVar?? It seems it's interpreting the variable name as a string rather than a variable name. I don't see any python function

Re: import file without .py into another module

2014-01-21 Thread Mark Lawrence
On 21/01/2014 15:50, kevinber...@gmail.com wrote: [snipped the double line spaced stuff courtesy of google] Would you please read and action this https://wiki.python.org/moin/GoogleGroupsPython to prevent us seeing the double line spacing that google inserts, thanks. -- My fellow