[Tutor] Can anyone explain this

eryksun eryksun at gmail.com
Thu Aug 8 04:06:38 CEST 2013


On Wed, Aug 7, 2013 at 8:11 PM, Dave Angel <davea at davea.name> wrote:
> As for the code that's buried inside there, it seems to have no
> usefulness if the file is run directly as a script

Amandeep, adding '..' to sys.path is an unusual thing to do. That's
relative to the current working directory. What's the source for this?

plain text version:

    import sys
    import os

    if __name__ == '__main__':
        sys.path.insert(0, "..")
    else:
        sys.path.insert(0, os.path.join(
            os.path.split(__file__)[0], '..'))


More information about the Tutor mailing list