Re: include a file in a python program

2010-09-10 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) Why? Is it against the law to change it? *wink* how can i include it in my program ? import python.txt doesn't work You co

Re: include a file in a python program

2010-09-08 Thread bussiere bussiere
Thanks all for your response i will try out this week, you have give me sufficient hints. Thanks again. Bussiere -- http://mail.python.org/mailman/listinfo/python-list

Re: include a file in a python program

2010-09-07 Thread bussiere maillist
Thanks all for your response i will try out this week, you have give me sufficient hint. Thanks again. Bussiere On Mon, Sep 6, 2010 at 9:50 AM, Niklasro(.appspot) wrote: > On Sep 5, 10:57 pm, bussiere bussiere wrote: >> i've got a python.txt that contain python and it must stay as it (python.txt

Re: include a file in a python program

2010-09-06 Thread Niklasro(.appspot)
On Sep 5, 10:57 pm, bussiere bussiere wrote: > i've got a python.txt that contain python and it must stay as it (python.txt) > > how can i include it in my program ? > import python.txt doesn't work > is there a way : > a) to make an include("python.txt") > b) tell him to treat .txt as .py file th

Re: include a file in a python program

2010-09-05 Thread Steven D'Aprano
On Mon, 06 Sep 2010 00:27:13 +0100, MRAB wrote: > import imp > python = imp.load_source("python", "python.txt") Nice! -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: include a file in a python program

2010-09-05 Thread Terry Reedy
On 9/5/2010 7:12 PM, Steven D'Aprano wrote: fp = open("python.txt") text = fp.read() fp.close() exec(text) But keep in mind that the contents of python.txt will be executed as if you had typed it yourself. If you don't trust the source with your life (or at least with the contents of your compu

Re: include a file in a python program

2010-09-05 Thread Terry Reedy
On 9/5/2010 6:57 PM, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) If you are working for someone who is such an idiot as to impose such a condition on you, you have our condolences. how can i include it in my program ? import python.

Re: include a file in a python program

2010-09-05 Thread MRAB
On 05/09/2010 23:57, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) how can i include it in my program ? import python.txt doesn't work is there a way : a) to make an include("python.txt") b) tell him to treat .txt as .py file that i can ma

Re: include a file in a python program

2010-09-05 Thread Roy Smith
In article <4c8423d3$0$28657$c3e8...@news.astraweb.com>, Steven D'Aprano wrote: > fp = open("python.txt") > text = fp.read() > fp.close() > exec(text) > But keep in mind that the contents of python.txt will be executed as if > you had typed it yourself. If you don't trust the source with your

Re: include a file in a python program

2010-09-05 Thread Roy Smith
In article , bussiere bussiere wrote: > i've got a python.txt that contain python and it must stay as it (python.txt) > > how can i include it in my program ? > import python.txt doesn't work > is there a way : > a) to make an include("python.txt") > b) tell him to treat .txt as .py file that i

Re: include a file in a python program

2010-09-05 Thread Steven D'Aprano
On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote: > i've got a python.txt that contain python and it must stay as it > (python.txt) Why? Is it against the law to change it? *wink* > how can i include it in my program ? > import python.txt doesn't work You could write a custom impor