Run pyc file without specifying python path ?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Fri Jul 31 02:04:01 CEST 2009


En Thu, 30 Jul 2009 12:16:46 -0300, Unknown <unknown at unknown.invalid>  
escribió:
> On 2009-07-30, Barak, Ron <Ron.Barak at lsi.com> wrote:

>> On second thoughts, I may have a problem implementing the
>> wrapper solution, because my actual test_pyc.pyc, needs to
>> parse its command line. Namely, the actual call to
>> test_pyc.pyc looks something like this:
>>
>> $ python  test_pyc.py -U dave -PpasswoRD -C CreateMcGroupOnVolume  
>> --SVMs_IPs '10.1.1.1 , 10.1.1.2' -n "host1,host2" -g gn -j jn -s svn -t  
>> tvn -p pool1 -l -c
>>
>> And I don't know of a way to add these parameters to the
>> "import test_pyc" in wrapper
>>
>> Is there a way to pass information to an imported module ?
>> (Sorry if there's an obvious answer, I just cannot figure it
>> out).
>
> I don't understand your problem.  The module would parse
> sys.argv just like always.
>
> If you don't like that for some reason, you could define an
> entry point in the module and call it:
>
> #!/usr/bin/python
> import sys,test_pyc
> test_pyc.main(*sys.argv)

And you *should* do it that way, instead of just importing the other  
module and executing ALL the program as a side-effect of the import  
statement. In the first case, the import lock will prevent other threads  
to run.

-- 
Gabriel Genellina




More information about the Python-list mailing list