[Tutor] include remote module
Patrick Sabin
patrick.just4fun at gmail.com
Sat Sep 12 16:59:37 CEST 2009
Maybe something like this helps you to solve your problem:
# get code via http, etc.
code = """
def blah():
print 'blah'
print 'hello'
blah()
"""
compiled_code = compile(code, 'filename', 'exec')
exec(compiled_code)
This way you could execute some code from a web client, but the client
would be able to execute any code, he could even delete your hard drive.
- Patrick
Patrick schrieb:
> Hi Wayne
>
> Thanks for your help. I was thinking of the latter but now that I think
> of it, once you import a module it won't help to modify that module on
> the fly later anyways, right? I would need to re-import it. Sounds like
> reading it via http would be simpler.
>
> Thanks again-Patrick
>
> Wayne wrote:
>> On Sat, Sep 12, 2009 at 7:55 AM, Patrick <optomatic at rogers.com
>> <mailto:optomatic at rogers.com>> wrote:
>>
>> Strange question.....
>>
>> Is it possible to include a module that is on another computer?
>>
>> I have been day-dreaming about a project that would allow web code to
>> drive a desktop App.
>>
>>
>> I know of one way, using sshfs, which allows you to mount an ssh
>> location as a directory on your computer. Then it would effectively be
>> a local filesystem. I don't know if there's something like that on
>> Windows.
>>
>> Of course, what do you mean when you say "web code to drive a desktop
>> app"? Do you mean you want to host some code that others can connect
>> to that will change? Or do you mean you want people to connect to your
>> server and it will run an app on your desktop?
>>
>> For the former it's not really necessary to include the mod on another
>> computer. Just use the http libraries and download the file when the
>> script runs. Then import it.
>>
>> HTH,
>> Wayne
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list