#!/usr/bin/env python > 2.4?

rh0dium steven.klass at gmail.com
Tue Mar 20 12:22:25 EDT 2007


Hi Folks,

OK I love the logging module.  I use it everywhere.  I was happily
putting at the top of each of my scripts

------<snip>------
#!/usr/bin/env python2.4

import logging

LOGLEVEL=logging.INFO

# Set's up a basic logger
logging.basicConfig(level=LOGLEVEL, format="%(asctime)s %(name)s %
(levelname)-8s %(message)s",
                    datefmt='%d %b %Y %H:%M:%S', stream=sys.stderr)

try:
    module= os.path.basename(traceback.extract_stack(limit=2)[1]
[0]).split(".py")[0]+"."
except:
    module = os.path.basename(traceback.extract_stack(limit=2)[0]
[0]).split(".py")[0]+"."

def main(loglevel=False):
    """ """
    # Setup Logging
    log = logging.getLogger(module+sys._getframe().f_code.co_name )
    if loglevel is not False: log.setLevel(loglevel)
    else:log.setLevel(logging.WARN)

    log.debug("I LOVE LOGGING")

if __name__ == '__main__':
    sys.exit(main(loglevel=LOGLEVEL))


------<snip>------

But now you guys continued to make this cool language and 2.5 came
out. Great now how do I put /usr/bin/env python>2.4?

Or can you suggest a better way to skin this cat?

Thanks again!!




More information about the Python-list mailing list