faqts : Computers : Programming : Languages : Python : Language and Syntax

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

9 of 10 people (90%) answered Yes
Recently 4 of 5 people (80%) answered Yes

Entry

What's the Python equivalent for C's #include "myfile.h"?

Jul 12th, 2000 00:30
unknown unknown, Rainer Deyke, Matthew Schinckel


The standard substitute is:
>>> import myfile
or
>>> from myfile import *
However, this is not quite equivalent to #include.  If you really need
behavior identical to #include, you could try the following:
exec open("myfile.h").read()