include a file in a python program

MRAB python at
Mon Sep 6 01:27:13 CEST 2010

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 make an import python ?
> i'am using python3

import imp
python = imp.load_source("python", "python.txt")

> Regards
> Bussiere
> fan of torchwood
> Google Fan boy

A fan of Torchwood and Google, but not Python? :-)

More information about the Python-list mailing list