[Tutor] does python have something like "#include" in C?
Alan Gauld
alan.gauld at btinternet.com
Mon Jun 29 18:39:16 CEST 2009
"Robert Lummis" <robert.lummis at gmail.com> wrote
> I'm looking for a way to get boiler plate code into the main program
> file. Of course I could copy and paste it with an editor but I was
> hoping for something more pythonic. I know about import but that's not
> the same.
Others have already pointed out import.
Its also worth pointing out that #include is a pretty horrible hack in C
that most modern commentators agree would be better removed.
Bjarne Stroustrup tried very hard to remove it completely from
C++ (apart from including class headers obviously which is akin
to Pythons import). But #define and #ifdef etc are all better done
in other ways.
Pythons import mechanism with namespaces is a far more elegant
solution all round.
Alan G.
More information about the Tutor
mailing list