#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    29
    Rep Power
    0

    Get current file name and path


    Hi. In PHP it is commong to do something like this:

    include dirname(__FILE__).'/subdir/file.php');

    dirname() returns the full path to the directory that the current file is in; __FILE__ is the name of the file that this line is in.

    Something else that comes in handy in PHP too, is the __LINE__ constant, which gives you the line number that __LINE__ is on.

    Is there an equivalent in Python? Thanks.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    29
    Rep Power
    0
    I got it.

    os.path.dirname(__file__)

IMN logo majestic logo threadwatch logo seochat tools logo