Just for my own edification (not being versed in python), what's the point of knowing that?
On Sep 18, 3:46 am, Kelvin Ward <kelvin.d.w...@googlemail.com> wrote: > java -cp clojure.jar clojure.main foo.clj > > I'm wondering if the code in foo.clj has anyway to know it is being > executed as a script. In python there's the idiom: > > def main(): ... > > if __name__ == "__main__": > main() > > I can then import the file at the repl and execute main() only if > want. I can also have main called by executing it as a script. > > I'm guessing passing a property to the clojure script is the best way > to do this, e.g.: > > java -cp clojure.jar -Dclojure.mainscript=foo.clj clojure.main foo.clj > > foo.clj: > > (defn main [] > ; ... > ) > > (if (= (System/getProperty "clojure.mainscript") "foo.clj") > (main)) > > Any thoughts? > > Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---