in reply to Dual personality: Module and script

It sounds like you're trying to be too clever. Modules are generally meant to be sourced in from other entities, like scripts. I wouldn't have executable modules, personally.

------
We are the carpenters and bricklayers of the Information Age.

Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

I shouldn't have to say this, but any code, unless otherwise stated, is untested

  • Comment on Re: Dual personality: Module and script

Replies are listed 'Best First'.
Re^2: Dual personality: Module and script
by japhy (Canon) on Aug 03, 2004 at 16:18 UTC
    In the Python world, the sentiment is exactly the opposite. I remember reading in "Programming Python" this common idiom:
    #!/usr/bin/env python # module mymod2.py def cube(n): return n ** 3 # when 'import'ed, __name__ is 'mymod2' # when executed, __name__ is '__main__' if __name__ == '__main__': if cube(15) != 3375: print "Error, cube(15) is not correct"
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart